r17610 - gnucash/trunk/src - Unite report and check print settings.
Andreas Köhler
andi5 at cvs.gnucash.org
Sun Sep 28 11:31:51 EDT 2008
Author: andi5
Date: 2008-09-28 11:31:50 -0400 (Sun, 28 Sep 2008)
New Revision: 17610
Trac: http://svn.gnucash.org/trac/changeset/17610
Modified:
gnucash/trunk/src/gnome-utils/Makefile.am
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:
Unite report and check print settings.
If Gtk+ includes GtkPrint support, i.e. HAVE_GTK_2_10 is defined, and GtkHTML
uses it, i.e. GTKHTML_USES_GTKPRINT, then we currently save and restore print
settings in two different locations, namely static variables in gnc-html.c and
dialog-print-check.c.
Instead, add the function gnc_print_operation_{save,restore}_print_settings() to
print-session.[ch] to have a unique global location for them.
Modified: gnucash/trunk/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-print-check.c 2008-09-28 15:31:39 UTC (rev 17609)
+++ gnucash/trunk/src/gnome/dialog-print-check.c 2008-09-28 15:31:50 UTC (rev 17610)
@@ -95,14 +95,6 @@
#define KF_KEY_TEXT "Text"
#define KF_KEY_FILENAME "Filename"
-/* Do not treat -Wstrict-aliasing warnings as errors because of problems of the
- * G_LOCK* macros as declared by glib. See
- * http://bugzilla.gnome.org/show_bug.cgi?id=316221 for additional information.
- */
-#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
-# pragma GCC diagnostic warning "-Wstrict-aliasing"
-#endif
-
/**< This enum specifies the columns used in the check format combobox. */
typedef enum format_combo_col_t {
COL_NAME = 0, /**< This column holds a copy of the check
@@ -119,8 +111,6 @@
#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
@@ -1988,11 +1978,7 @@
print = gtk_print_operation_new();
- G_LOCK(print_settings);
- if (print_settings)
- gtk_print_operation_set_print_settings(print, print_settings);
- G_UNLOCK(print_settings);
-
+ gnc_print_operation_restore_print_settings(print);
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);
@@ -2002,13 +1988,8 @@
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
pcd->caller_window, NULL);
- 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);
- }
+ if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
+ gnc_print_operation_save_print_settings(print);
g_object_unref(print);
}
Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am 2008-09-28 15:31:39 UTC (rev 17609)
+++ gnucash/trunk/src/gnome-utils/Makefile.am 2008-09-28 15:31:50 UTC (rev 17610)
@@ -52,6 +52,7 @@
gnc-dense-cal.c \
gnc-dense-cal-model.c \
gnc-dense-cal-store.c \
+ gnc-dialog.c \
gnc-druid-gnome.c \
gnc-druid-provider-edge-gnome.c \
gnc-druid-provider-file-gnome.c \
@@ -94,7 +95,7 @@
gncmod-gnome-utils.c \
misc-gnome-utils.c \
search-param.c \
- gnc-dialog.c \
+ print-session.c \
swig-gnome-utils.c \
window-main-summarybar.c
@@ -217,12 +218,9 @@
${gncmod_DATA} \
${gncscm_DATA}
-if GTKHTML_USES_GTKPRINT
- EXTRA_DIST += print-session.c
-else
+if !GTKHTML_USES_GTKPRINT
AM_CFLAGS += ${GNOME_PRINT_CFLAGS}
libgncmod_gnome_utils_la_LIBADD += ${GNOME_PRINT_LIBS}
- libgncmod_gnome_utils_la_SOURCES += print-session.c
endif
## We borrow guile's convention and use @-...-@ as the substitution
Modified: gnucash/trunk/src/gnome-utils/gnc-html.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html.c 2008-09-28 15:31:39 UTC (rev 17609)
+++ gnucash/trunk/src/gnome-utils/gnc-html.c 2008-09-28 15:31:50 UTC (rev 17610)
@@ -53,15 +53,6 @@
#include "gnc-ui.h"
#include "gnc-ui-util.h"
-/* Do not treat -Wstrict-aliasing warnings as errors because of problems of the
- * G_LOCK* macros as declared by glib. See
- * http://bugzilla.gnome.org/show_bug.cgi?id=316221 for additional information.
- */
-#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
-# pragma GCC diagnostic warning "-Wstrict-aliasing"
-#endif
-
-
struct gnc_html_struct {
GtkWidget * window; /* window this html goes into */
GtkWidget * container; /* parent of the gtkhtml widget */
@@ -115,12 +106,7 @@
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)
{
@@ -1248,11 +1234,7 @@
print = gtk_print_operation_new();
- G_LOCK(print_settings);
- if (print_settings)
- gtk_print_operation_set_print_settings(print, print_settings);
- G_UNLOCK(print_settings);
-
+ gnc_print_operation_restore_print_settings(print);
gtk_print_operation_set_use_full_page(print, FALSE);
gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
gtk_print_operation_set_n_pages(print, 1);
@@ -1261,13 +1243,8 @@
res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
GTK_WINDOW(html->window), NULL);
- 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);
- }
+ if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
+ gnc_print_operation_save_print_settings(print);
g_object_unref(print);
}
Modified: gnucash/trunk/src/gnome-utils/print-session.c
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.c 2008-09-28 15:31:39 UTC (rev 17609)
+++ gnucash/trunk/src/gnome-utils/print-session.c 2008-09-28 15:31:50 UTC (rev 17610)
@@ -22,14 +22,63 @@
#include "config.h"
-#include <gnome.h>
-#include <glib/gi18n.h>
-#include <libgnomeprint/gnome-font.h>
-#include <libgnomeprintui/gnome-print-job-preview.h>
+#ifdef HAVE_GTK_2_10
+# include <gtk/gtkprintoperation.h>
+#endif
+#ifndef GTKHTML_USES_GTKPRINT
+# include <gnome.h>
+# include <glib/gi18n.h>
+# include <libgnomeprint/gnome-font.h>
+# include <libgnomeprintui/gnome-print-job-preview.h>
+#endif
+
#include "print-session.h"
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "gnc.printing"
+#ifdef HAVE_GTK_2_10
+/* Do not treat -Wstrict-aliasing warnings as errors because of problems of the
+ * G_LOCK* macros as declared by glib. See
+ * http://bugzilla.gnome.org/show_bug.cgi?id=316221 for additional information.
+ */
+# if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
+# pragma GCC diagnostic warning "-Wstrict-aliasing"
+# endif
+
+static GtkPrintSettings *print_settings = NULL;
+G_LOCK_DEFINE_STATIC(print_settings);
+#endif
+
+
+#ifdef HAVE_GTK_2_10
+void
+gnc_print_operation_save_print_settings(GtkPrintOperation *op)
+{
+ g_return_if_fail(op);
+
+ G_LOCK(print_settings);
+ if (print_settings)
+ g_object_unref(print_settings);
+ print_settings = g_object_ref(gtk_print_operation_get_print_settings(op));
+ G_UNLOCK(print_settings);
+}
+
+void
+gnc_print_operation_restore_print_settings(GtkPrintOperation *op)
+{
+ g_return_if_fail(op);
+
+ G_LOCK(print_settings);
+ if (print_settings)
+ gtk_print_operation_set_print_settings(op, print_settings);
+ G_UNLOCK(print_settings);
+}
+#endif /* HAVE_GTK_2_10 */
+
+
+#ifndef GTKHTML_USES_GTKPRINT
PrintSession *
gnc_print_session_create(gboolean hand_built_pages)
{
@@ -105,3 +154,4 @@
break;
}
}
+#endif /* !GTKHTML_USES_GTKPRINT */
Modified: gnucash/trunk/src/gnome-utils/print-session.h
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.h 2008-09-28 15:31:39 UTC (rev 17609)
+++ gnucash/trunk/src/gnome-utils/print-session.h 2008-09-28 15:31:50 UTC (rev 17610)
@@ -24,8 +24,6 @@
#ifndef PRINT_SESSION_H
#define PRINT_SESSION_H
-#ifndef GTKHTML_USES_GTKPRINT
-
/** @addtogroup Printing
@{ */
/** @file print-session.h
@@ -33,6 +31,35 @@
@author Copyright (C) 2000 Bill Gribble <grib at billgribble.com>
*/
+/** @addtogroup Basic Session Functions
+ @{ */
+
+#ifdef HAVE_GTK_2_10
+
+#include <gtk/gtkprintoperation.h>
+
+/**
+ * Retrieve the print settings from the GtkPrintOperation @a op and save them in
+ * a static variable.
+ *
+ * @param op non-NULL print operation
+ */
+void gnc_print_operation_save_print_settings(GtkPrintOperation *op);
+
+/**
+ * If print settings have been saved by
+ * gnc_print_operation_save_print_settings(), then set them on the given
+ * GtkPrintOperation @a op.
+ *
+ * @param op non-NULL print operation
+ */
+void gnc_print_operation_restore_print_settings(GtkPrintOperation *op);
+
+#endif /* HAVE_GTK_2_10 */
+
+
+#ifndef GTKHTML_USES_GTKPRINT
+
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-job.h>
#include <libgnomeprintui/gnome-print-dialog.h>
@@ -48,9 +75,6 @@
} PrintSession;
-/** @addtogroup Basic Session Functions
- @{ */
-
/** Create a new print 'session'. Once created, a series of commands
* can be issued on the session to create the output page. The
* output will be printed when the session is done. This function
@@ -84,9 +108,9 @@
*/
void gnc_print_session_done(PrintSession * ps);
+#endif /* !GTKHTML_USES_GTKPRINT */
+
/** @} */
/** @} */
-#endif /* GTKHTML_USES_GTKPRINT */
-
#endif
More information about the gnucash-changes
mailing list