r20340 - gnucash/trunk/src - Set a printer job name when printing reports and cheques

Geert Janssens gjanssens at code.gnucash.org
Fri Feb 25 18:59:21 EST 2011


Author: gjanssens
Date: 2011-02-25 18:59:21 -0500 (Fri, 25 Feb 2011)
New Revision: 20340
Trac: http://svn.gnucash.org/trac/changeset/20340

Modified:
   gnucash/trunk/src/gnome-utils/print-session.c
   gnucash/trunk/src/gnome-utils/print-session.h
   gnucash/trunk/src/gnome/dialog-print-check.c
   gnucash/trunk/src/html/gnc-html-gtkhtml.c
   gnucash/trunk/src/html/gnc-html-webkit.c
   gnucash/trunk/src/html/gnc-html.c
   gnucash/trunk/src/html/gnc-html.h
   gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
Set a printer job name when printing reports and cheques

Modified: gnucash/trunk/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-print-check.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/gnome/dialog-print-check.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -2441,7 +2441,7 @@
 
     print = gtk_print_operation_new();
 
-    gnc_print_operation_init(print);
+    gnc_print_operation_init(print, "GnuCash-Checks");
     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), pcd);

Modified: gnucash/trunk/src/gnome-utils/print-session.c
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/gnome-utils/print-session.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -57,7 +57,7 @@
 }
 
 void
-gnc_print_operation_init(GtkPrintOperation *op)
+gnc_print_operation_init(GtkPrintOperation *op, const gchar* jobname)
 {
     g_return_if_fail(op);
 
@@ -72,6 +72,8 @@
     if (page_setup)
         gtk_print_operation_set_default_page_setup(op, page_setup);
     G_UNLOCK(page_setup);
+
+    gtk_print_operation_set_job_name ( op, jobname);
 }
 
 void

Modified: gnucash/trunk/src/gnome-utils/print-session.h
===================================================================
--- gnucash/trunk/src/gnome-utils/print-session.h	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/gnome-utils/print-session.h	2011-02-25 23:59:21 UTC (rev 20340)
@@ -50,8 +50,9 @@
  * GtkPrintOperation @a op.  Set the default page setup as well.
  *
  * @param op non-NULL print operation
+ * @param jobname non-NULL print job name
  */
-void gnc_print_operation_init(GtkPrintOperation *op);
+void gnc_print_operation_init(GtkPrintOperation *op, const gchar* jobname);
 
 /**
  * Run a page setup dialog and save the resulting GtkPageSetup in a static

Modified: gnucash/trunk/src/html/gnc-html-gtkhtml.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-gtkhtml.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/html/gnc-html-gtkhtml.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -104,7 +104,7 @@
 static void impl_gtkhtml_reload( GncHtml* self );
 static void impl_gtkhtml_copy_to_clipboard( GncHtml* self );
 static gboolean impl_gtkhtml_export_to_file( GncHtml* self, const gchar* filepath );
-static void impl_gtkhtml_print( GncHtml* self );
+static void impl_gtkhtml_print( GncHtml* self, const gchar* jobname );
 static void impl_gtkhtml_cancel( GncHtml* self );
 static void impl_gtkhtml_set_parent( GncHtml* self, GtkWindow* parent );
 
@@ -937,7 +937,7 @@
 }
 
 static void
-impl_gtkhtml_print( GncHtml* self )
+impl_gtkhtml_print( GncHtml* self, const gchar* jobname )
 {
     GtkPrintOperation *print;
     GtkPrintOperationResult res;
@@ -946,7 +946,7 @@
     priv = GNC_HTML_GTKHTML_GET_PRIVATE(self);
     print = gtk_print_operation_new();
 
-    gnc_print_operation_init(print);
+    gnc_print_operation_init(print, jobname);
     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);

Modified: gnucash/trunk/src/html/gnc-html-webkit.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-webkit.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/html/gnc-html-webkit.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -106,7 +106,7 @@
 static void impl_webkit_reload( GncHtml* self );
 static void impl_webkit_copy_to_clipboard( GncHtml* self );
 static gboolean impl_webkit_export_to_file( GncHtml* self, const gchar* filepath );
-static void impl_webkit_print( GncHtml* self );
+static void impl_webkit_print( GncHtml* self, const gchar* jobname );
 static void impl_webkit_cancel( GncHtml* self );
 static void impl_webkit_set_parent( GncHtml* self, GtkWindow* parent );
 
@@ -1060,7 +1060,7 @@
  * @param self HTML renderer object
  */
 static void
-impl_webkit_print( GncHtml* self )
+impl_webkit_print( GncHtml* self, const gchar* jobname )
 {
 #if !HAVE(WEBKIT_WEB_FRAME_PRINT_FULL)
     extern void webkit_web_frame_print( WebKitWebFrame * frame );
@@ -1077,7 +1077,7 @@
     frame = webkit_web_view_get_main_frame( priv->web_view );
 
 #if HAVE(WEBKIT_WEB_FRAME_PRINT_FULL)
-    gnc_print_operation_init( op );
+    gnc_print_operation_init( op, jobname );
 #ifdef G_OS_WIN32
     gtk_print_operation_set_unit( op, GTK_UNIT_POINTS );
 #endif

Modified: gnucash/trunk/src/html/gnc-html.c
===================================================================
--- gnucash/trunk/src/html/gnc-html.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/html/gnc-html.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -525,14 +525,14 @@
 }
 
 void
-gnc_html_print( GncHtml* self )
+gnc_html_print( GncHtml* self, const gchar* jobname )
 {
     g_return_if_fail( self != NULL );
     g_return_if_fail( GNC_IS_HTML(self) );
 
     if ( GNC_HTML_GET_CLASS(self)->print != NULL )
     {
-        GNC_HTML_GET_CLASS(self)->print( self );
+        GNC_HTML_GET_CLASS(self)->print( self, jobname );
     }
     else
     {

Modified: gnucash/trunk/src/html/gnc-html.h
===================================================================
--- gnucash/trunk/src/html/gnc-html.h	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/html/gnc-html.h	2011-02-25 23:59:21 UTC (rev 20340)
@@ -135,7 +135,7 @@
     void (*reload)( GncHtml* html );
     void (*copy_to_clipboard)( GncHtml* html );
     gboolean (*export_to_file)( GncHtml* html, const gchar* file );
-    void (*print)( GncHtml* html );
+    void (*print)( GncHtml* html, const gchar* jobname );
     void (*cancel)( GncHtml* html );
     URLType (*parse_url)( GncHtml* html, const gchar* url,
                           gchar** url_location, gchar** url_label );
@@ -200,7 +200,7 @@
  *
  * @param html GncHtml object
  */
-void gnc_html_print( GncHtml* html );
+void gnc_html_print( GncHtml* html, const gchar* jobname );
 
 /**
  * Cancels the current operation

Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2011-02-25 07:11:16 UTC (rev 20339)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2011-02-25 23:59:21 UTC (rev 20340)
@@ -1570,9 +1570,28 @@
 gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report )
 {
     GncPluginPageReportPrivate *priv;
+    gchar *report_name = NULL;
+    gchar *job_name = NULL;
+    gchar *job_date = qof_print_date( time( NULL ) );
 
     priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
-    gnc_html_print(priv->html);
+
+    if (priv->cur_report == SCM_BOOL_F)
+        report_name = g_strdup ( "GnuCash-Report");
+    else
+    {
+        report_name = gnc_option_db_lookup_string_option(priv->cur_odb, "General",
+               "Report name", NULL);
+        if (!report_name)
+            report_name = g_strdup ( "GnuCash-Report");
+    }
+    job_name = g_strjoin ( "_", report_name, job_date, NULL );
+
+    gnc_html_print(priv->html, job_name);
+
+    g_free (report_name);
+    g_free (job_name);
+    g_free (job_date);
 }
 
 static void



More information about the gnucash-changes mailing list