|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * print-session.c -- simple printing manager for gnucash * 00003 * Copyright (C) 2000 Bill Gribble <grib@billgribble.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License* 00016 * along with this program; if not, contact: * 00017 * * 00018 * Free Software Foundation Voice: +1-617-542-5942 * 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00020 * Boston, MA 02110-1301, USA gnu@gnu.org * 00021 \********************************************************************/ 00022 00023 #include "config.h" 00024 00025 #include <gtk/gtk.h> 00026 00027 #include "print-session.h" 00028 #include "gnc-gconf-utils.h" /* for gnc_gconf_set_string() */ 00029 00030 #undef G_LOG_DOMAIN 00031 #define G_LOG_DOMAIN "gnc.printing" 00032 00033 /* Do not treat -Wstrict-aliasing warnings as errors because of problems of the 00034 * G_LOCK* macros as declared by glib. See 00035 * http://bugzilla.gnome.org/show_bug.cgi?id=316221 for additional information. 00036 */ 00037 #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2) 00038 # pragma GCC diagnostic warning "-Wstrict-aliasing" 00039 #endif 00040 00041 static GtkPrintSettings *print_settings = NULL; 00042 static GtkPageSetup *page_setup = NULL; 00043 G_LOCK_DEFINE_STATIC(print_settings); 00044 G_LOCK_DEFINE_STATIC(page_setup); 00045 00046 00047 void 00048 gnc_print_operation_save_print_settings(GtkPrintOperation *op) 00049 { 00050 g_return_if_fail(op); 00051 00052 G_LOCK(print_settings); 00053 if (print_settings) 00054 g_object_unref(print_settings); 00055 print_settings = g_object_ref(gtk_print_operation_get_print_settings(op)); 00056 G_UNLOCK(print_settings); 00057 } 00058 00059 void 00060 gnc_print_operation_init(GtkPrintOperation *op, const gchar* jobname) 00061 { 00062 g_return_if_fail(op); 00063 00064 /* Restore print settings */ 00065 G_LOCK(print_settings); 00066 if (print_settings) 00067 gtk_print_operation_set_print_settings(op, print_settings); 00068 G_UNLOCK(print_settings); 00069 00070 /* Restore page setup */ 00071 G_LOCK(page_setup); 00072 if (page_setup) 00073 gtk_print_operation_set_default_page_setup(op, page_setup); 00074 G_UNLOCK(page_setup); 00075 00076 gtk_print_operation_set_job_name ( op, jobname); 00077 } 00078 00079 void 00080 gnc_ui_page_setup(GtkWindow *parent) 00081 { 00082 GtkPrintSettings *settings = NULL; 00083 GtkPageSetup *old_page_setup, *new_page_setup; 00084 00085 /* Get a reference to the current print settings */ 00086 G_LOCK(print_settings); 00087 settings = print_settings; 00088 if (settings) 00089 g_object_ref(settings); 00090 G_UNLOCK(print_settings); 00091 00092 /* Get a reference to the current page setup */ 00093 G_LOCK(page_setup); 00094 old_page_setup = page_setup; 00095 if (old_page_setup) 00096 g_object_ref(old_page_setup); 00097 G_UNLOCK(page_setup); 00098 00099 /* Run dialog */ 00100 new_page_setup = gtk_print_run_page_setup_dialog(parent, old_page_setup, 00101 settings); 00102 00103 /* Save new page setup */ 00104 G_LOCK(page_setup); 00105 if (page_setup) 00106 g_object_unref(page_setup); 00107 page_setup = new_page_setup; 00108 G_UNLOCK(page_setup); 00109 00110 /* Release references */ 00111 if (settings) 00112 g_object_unref(settings); 00113 if (old_page_setup) 00114 g_object_unref(old_page_setup); 00115 } 00116 00117 GtkPrintSettings *gnc_print_get_settings() 00118 { 00119 return print_settings; 00120 }
1.7.4