/*------------------------------------------------------------------------- * Copyright (c) 1999-2002 Kenneth W. Sodemann (stufflehead@bigfoot.com) *------------------------------------------------------------------------- * print_prog_dlg * * Synopsis: * Printing progress dialog box * * $Id: print_prog_dlg.c,v 1.10 2002/12/14 03:15:30 stuffle Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * *------------------------------------------------------------------------- */ #ifdef HAVE_CONFIG_H # include #endif /* * Only bother compiling this stuff if printing is supported. */ #ifdef PRINTING_SUPPORTED #include #include "gtkutils.h" #define MAIN_TEXT "main_text_widget" #define DISMISS_BTN "dismiss_btn" #define WARNING_TAG "warn" static void on_print_dlg_response (GtkDialog *dlg, gint btn_cd, gpointer user_data) { switch (btn_cd) { case GTK_RESPONSE_CLOSE: gtk_widget_destroy (GTK_WIDGET (dlg)); break; case GTK_RESPONSE_DELETE_EVENT: break; default: g_assert_not_reached (); } } void print_prog_dlg_printing_complete (GtkWidget *dlg) { gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg), GTK_RESPONSE_CLOSE, TRUE); } void print_prog_dlg_output_message (GtkWidget *dlg, const gchar *str, gboolean warning) { GtkTextView *view; GtkTextBuffer *buff; GtkTextIter iter; view = GTK_TEXT_VIEW (lookup_widget (dlg, MAIN_TEXT)); g_assert (view != NULL); buff = gtk_text_view_get_buffer (view); gtk_text_buffer_get_end_iter (buff, &iter); if (warning) { gtk_text_buffer_insert_with_tags_by_name (buff, &iter, str, -1, WARNING_TAG, NULL); } else { gtk_text_buffer_insert (buff, &iter, str, -1); } } GtkWidget* create_print_prog_dlg (GtkWidget *parent) { GtkWidget *print_dlg; GtkWidget *vbox1; GtkWidget *scrolledwindow1; GtkWidget *text1; GtkTextBuffer *buff; print_dlg = gtk_dialog_new_with_buttons (_("Printing Progress"), NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); GLADE_HOOKUP_OBJECT_NO_REF (print_dlg, print_dlg, "print_dlg"); gtk_window_set_resizable (GTK_WINDOW (print_dlg), TRUE); gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dlg), 0, FALSE); g_signal_connect (print_dlg, "response", G_CALLBACK (on_print_dlg_response), NULL); vbox1 = GTK_DIALOG (print_dlg)->vbox; gtk_widget_show (vbox1); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); GLADE_HOOKUP_OBJECT (print_dlg, scrolledwindow1, "scrolledwindow1"); gtk_widget_show (scrolledwindow1); gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1), 5); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); text1 = gtk_text_view_new (); GLADE_HOOKUP_OBJECT (print_dlg, text1, MAIN_TEXT); gtk_widget_show (text1); gtk_text_view_set_editable (GTK_TEXT_VIEW (text1), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text1), GTK_WRAP_NONE); gtk_container_add (GTK_CONTAINER (scrolledwindow1), text1); gtk_widget_set_size_request (text1, 400, 150); /* * Create some tags for the text buffer... */ buff = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text1)); gtk_text_buffer_create_tag (buff, WARNING_TAG, "weight", PANGO_WEIGHT_BOLD, "foreground", "red", NULL); return print_dlg; } #endif