2008-10-09 [colin] 3.6.0cvs18
[claws.git] / src / gedit-print.c
index cef288edb6cf07ffa8c11f23a17ec1c1c589cb57..4592fd25a5e3b91a1eb094d0e911c38eb9cfa741 100644 (file)
@@ -8,7 +8,7 @@
  *
  * 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
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -17,9 +17,7 @@
  * 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 the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, 
- * Boston, MA 02111-1307, USA. 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
  
 /*
 #include <string.h>    /* For strlen */
 
 #include <glib/gi18n.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkprogressbar.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 #include <libgnomeprintui/gnome-print-job-preview.h>
 
@@ -92,6 +83,7 @@ struct _GeditPrintJobInfo
        GtkWidget         *progressbar;
 
        GtkWindow         *parent;
+       gboolean           done;
 };
 
 static GeditPrintJobInfo* gedit_print_job_info_new     (GtkTextView       *view);
@@ -200,7 +192,7 @@ gedit_print_dialog_response (GtkWidget *dialog, int response, GeditPrintJobInfo
 
        default:
                gtk_widget_destroy (dialog);
-               gedit_print_job_info_destroy (pji, FALSE);
+               pji->done = TRUE;
         }
 } 
 
@@ -215,7 +207,7 @@ show_printing_dialog (GeditPrintJobInfo *pji, GtkWindow *parent)
        GtkWidget *label;
        GtkWidget *progressbar;
 
-       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "gedit-print");
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
        gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
        gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
@@ -304,7 +296,7 @@ preview_finished_cb (GtkSourcePrintJob *job, GeditPrintJobInfo *pji)
        gtk_widget_destroy (pji->dialog);
 
        if (pji->preview == PREVIEW)
-               gedit_print_job_info_destroy (pji, FALSE);
+               pji->done = TRUE;
        else
        {
                g_signal_handlers_disconnect_by_func (pji->pjob, (GCallback) page_cb, pji);
@@ -327,7 +319,7 @@ print_finished_cb (GtkSourcePrintJob *job, GeditPrintJobInfo *pji)
 
        gtk_widget_destroy (pji->dialog);
 
-       gedit_print_job_info_destroy (pji, TRUE);
+       pji->done = TRUE;
 }
 
 void 
@@ -355,6 +347,10 @@ gedit_print (GtkTextView *view)
                          pji);
 
        gtk_widget_show (dialog);
+       while (pji->done != TRUE)
+               gtk_main_iteration();
+       gedit_print_job_info_destroy (pji, pji->preview ? FALSE:TRUE);
+       
 }
 
 static void 
@@ -397,25 +393,6 @@ gedit_print_real (GeditPrintJobInfo *pji,
        }
 }
 
-void 
-gedit_print_preview (GtkTextView *view)
-{
-       GeditPrintJobInfo *pji;
-       GtkTextIter start, end;
-
-       gedit_debug (DEBUG_PRINT, "");
-               
-       g_return_if_fail (view != NULL);
-
-       pji = gedit_print_job_info_new (view);
-
-       gtk_text_buffer_get_bounds (pji->doc, &start, &end);
-
-       pji->preview = PREVIEW;
-       gedit_print_preview_real (pji, &start, &end, 
-                                 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))));
-}
-
 static GeditPrintJobInfo *
 gedit_print_job_info_new (GtkTextView* view)
 {      
@@ -457,9 +434,20 @@ gedit_print_job_info_new (GtkTextView* view)
        gtk_source_print_job_set_print_footer (pjob, TRUE);
 
        pango_context = gtk_widget_get_pango_context (GTK_WIDGET (view));
-       font_desc = pango_context_get_font_description (pango_context);
+       if (prefs_common.use_different_print_font) 
+       {
+               font_desc = pango_font_description_from_string (prefs_common.printfont);
+       }
+       else
+       {
+               font_desc = pango_context_get_font_description (pango_context);
+       }
 
        gtk_source_print_job_set_font_desc (pjob, font_desc);
+       if (prefs_common.use_different_print_font) 
+       {
+               pango_font_description_free (font_desc);
+       }
 
        pji = g_new0 (GeditPrintJobInfo, 1);