r15735 - gnucash/trunk/src - Uncouple print settings for reports and checks again.

Andreas Köhler andi5 at cvs.gnucash.org
Sun Mar 18 13:59:04 EDT 2007


Author: andi5
Date: 2007-03-18 13:58:58 -0400 (Sun, 18 Mar 2007)
New Revision: 15735
Trac: http://svn.gnucash.org/trac/changeset/15735

Modified:
   gnucash/trunk/src/gnome-utils/gnc-html.c
   gnucash/trunk/src/gnome-utils/print-session.c
   gnucash/trunk/src/gnome-utils/print-session.h
   gnucash/trunk/src/gnome/dialog-print-check.c
Log:
Uncouple print settings for reports and checks again.

Remove gnc_{save,restore}_print_settings, revert part of r15733.


Modified: gnucash/trunk/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-print-check.c	2007-03-18 17:37:53 UTC (rev 15734)
+++ gnucash/trunk/src/gnome/dialog-print-check.c	2007-03-18 17:58:58 UTC (rev 15735)
@@ -110,6 +110,8 @@
 
 #if USE_GTKPRINT
 #    define GncPrintContext GtkPrintContext
+static GtkPrintSettings *print_settings = NULL;
+G_LOCK_DEFINE_STATIC(print_settings);
 #else
 #    define GncPrintContext GnomePrintContext
 #    define GNOMEPRINT_CLIP_EXTRA 2
@@ -1909,7 +1911,11 @@
 
     print = gtk_print_operation_new();
 
-    gnc_restore_print_settings(print);
+    G_LOCK(print_settings);
+    if (print_settings)
+        gtk_print_operation_set_print_settings(print, print_settings);
+    G_UNLOCK(print_settings);
+
     gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
     gtk_print_operation_set_use_full_page(print, TRUE);
     g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL);
@@ -1919,8 +1925,13 @@
                                   GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                   pcd->caller_window, NULL);
 
-    if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
-        gnc_save_print_settings(print);
+    if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
+        G_LOCK(print_settings);
+        if (print_settings)
+            g_object_unref(print_settings);
+        print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
+        G_UNLOCK(print_settings);
+    }
 
     g_object_unref(print);
 }

Modified: gnucash/trunk/src/gnome-utils/gnc-html.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html.c	2007-03-18 17:37:53 UTC (rev 15734)
+++ gnucash/trunk/src/gnome-utils/gnc-html.c	2007-03-18 17:58:58 UTC (rev 15735)
@@ -107,6 +107,12 @@
 static char error_404_body[] = 
 N_("The specified URL could not be loaded.");
 
+#ifdef GTKHTML_USES_GTKPRINT
+static GtkPrintSettings *print_settings = NULL;
+G_LOCK_DEFINE_STATIC(print_settings);
+#endif
+
+
 static char * 
 extract_machine_name(const gchar * path)
 {
@@ -1210,8 +1216,7 @@
   return TRUE;
 }
 
-#if GTKHTML_USES_GTKPRINT
-
+#ifdef GTKHTML_USES_GTKPRINT
 static void
 draw_page_cb(GtkPrintOperation *operation, GtkPrintContext *context,
              gint page_nr, gpointer user_data)
@@ -1228,15 +1233,25 @@
     GtkPrintOperationResult res;
 
     print = gtk_print_operation_new();
-    gnc_restore_print_settings(print);
+
+    G_LOCK(print_settings);
+    if (print_settings)
+        gtk_print_operation_set_print_settings(print, print_settings);
+    G_UNLOCK(print_settings);
+
     gtk_print_operation_set_n_pages(print, 1);
     g_signal_connect(print, "draw_page", G_CALLBACK(draw_page_cb), html);
 
     res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                   GTK_WINDOW(html->window), NULL);
 
-    if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
-        gnc_save_print_settings(print);
+    if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
+        G_LOCK(print_settings);
+        if (print_settings)
+            g_object_unref(print_settings);
+        print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
+        G_UNLOCK(print_settings);
+    }
 
     g_object_unref(print);
 }

Modified: gnucash/trunk/src/gnome-utils/print-session.c
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.c	2007-03-18 17:37:53 UTC (rev 15734)
+++ gnucash/trunk/src/gnome-utils/print-session.c	2007-03-18 17:58:58 UTC (rev 15735)
@@ -105,35 +105,3 @@
       break;
   }
 }
-
-#ifdef HAVE_GTK_2_10
-
-static GtkPrintSettings *print_settings = NULL;
-G_LOCK_DEFINE_STATIC(print_settings);
-
-void
-gnc_save_print_settings(GtkPrintOperation *print)
-{
-    g_return_if_fail(print);
-
-    G_LOCK(print_settings);
-    if (print_settings)
-        g_object_unref(print_settings);
-
-    print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
-    G_UNLOCK(print_settings);
-}
-
-void
-gnc_restore_print_settings(GtkPrintOperation *print)
-{
-    g_return_if_fail(print);
-
-    G_LOCK(print_settings);
-    if (print_settings)
-        gtk_print_operation_set_print_settings(print, print_settings);
-
-    G_UNLOCK(print_settings);
-}
-
-#endif /* HAVE_GTK_2_10 */

Modified: gnucash/trunk/src/gnome-utils/print-session.h
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.h	2007-03-18 17:37:53 UTC (rev 15734)
+++ gnucash/trunk/src/gnome-utils/print-session.h	2007-03-18 17:58:58 UTC (rev 15735)
@@ -82,23 +82,6 @@
  */
 void gnc_print_session_done(PrintSession * ps);
 
-
-#if HAVE_GTK_2_10
-/** Get the print settings of a given GtkPrintOperation and store them in a
- *  static variable.  Previous values will be overwritten.
- *
- *  @param print A pointer to a print operation.
- */
-void gnc_save_print_settings(GtkPrintOperation *print);
-
-/** After a previous call to gnc_save_print_settings, set the print settings of a
- *  given GtkPrintOperation to the stored value.  Otherwise, do nothing.
- *
- *  @param print A pointer to a print operation.
- */
-void gnc_restore_print_settings(GtkPrintOperation *print);
-#endif
-
 /** @} */
 /** @} */
 



More information about the gnucash-changes mailing list