gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu May 30 08:58:49 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/dfc3d274 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/51ffcae9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9e43f6bc (commit)
	from  https://github.com/Gnucash/gnucash/commit/4ffc4d04 (commit)



commit dfc3d2749017cfeac6d3f5e86db353ca150022be
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu May 30 14:58:41 2019 +0200

    Bug 797104 - Translations not showing in receipt options
    
    Mark thank you string as translatable as well.

diff --git a/gnucash/report/business-reports/receipt.scm b/gnucash/report/business-reports/receipt.scm
index 4f2079e95..3c0f1db6e 100644
--- a/gnucash/report/business-reports/receipt.scm
+++ b/gnucash/report/business-reports/receipt.scm
@@ -185,7 +185,7 @@
                 headingpage2 optname-amount-due "b" "" (_ "Amount Due")))
   (add-option (gnc:make-string-option
                 headingpage2 optname-payment-recd "c" ""
-                (N_ "Payment received, thank you!")))
+                (_ "Payment received, thank you!")))
 
   (add-option (gnc:make-text-option
                 notespage optname-extra-notes "a"

commit 51ffcae9b886b54a43343ba7fd6b37911b945ce1
Merge: 4ffc4d046 9e43f6bc4
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Tue May 28 17:48:18 2019 +0200

    Merge branch 'Bug-787018' of https://github.com/EvansMike/gnucash into maint


commit 9e43f6bc42fd47c283b98fcb3344ba69ece24fc7
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Sun May 5 14:19:34 2019 +0100

    Implement "printing" to a pdf.
    
    This removes the export to PDF button and uses the standard print
    dialog with an option to print tp pdf.
    The filename is pre-populated, with the path set to the default, $HOME
    on linux.
    There is no remembering of past output directories.  Maybe a later
    update will do this.

diff --git a/gnucash/html/gnc-html-webkit2.c b/gnucash/html/gnc-html-webkit2.c
index b2ce26c64..d9ab09f45 100644
--- a/gnucash/html/gnc-html-webkit2.c
+++ b/gnucash/html/gnc-html-webkit2.c
@@ -56,6 +56,9 @@
 #include "gnc-html-webkit.h"
 #include "gnc-html-history.h"
 #include "print-session.h"
+#include "gnc-state.h"
+#include "print-session.h"
+
 
 G_DEFINE_TYPE(GncHtmlWebkit, gnc_html_webkit, GNC_TYPE_HTML )
 
@@ -119,7 +122,7 @@ static void impl_webkit_show_data( GncHtml* self, const gchar* data, int datalen
 static void impl_webkit_reload( GncHtml* self, gboolean force_rebuild );
 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 );
 static void impl_webkit_default_zoom_changed(gpointer prefs, gchar *pref, gpointer user_data);
@@ -1112,20 +1115,44 @@ impl_webkit_export_to_file( GncHtml* self, const char *filepath )
  * webkit_web_view_get_snapshot for each page.
  */
 static void
-impl_webkit_print (GncHtml* self)
+impl_webkit_print (GncHtml* self,const gchar* jobname)
 {
      WebKitPrintOperation *op = NULL;
      GtkWindow *top = NULL;
      GncHtmlWebkitPrivate *priv;
-
+     GtkPrintSettings *print_settings = NULL;
+     WebKitPrintOperationResponse print_response;
+     gchar *export_dirname = NULL;
+     gchar *export_filename = NULL;
+     gchar* basename = NULL;
+     GKeyFile *state_file = gnc_state_get_current();
+     
      g_return_if_fail (self != NULL);
      g_return_if_fail (GNC_IS_HTML_WEBKIT (self));
-
      priv = GNC_HTML_WEBKIT_GET_PRIVATE (self);
      op = webkit_print_operation_new (priv->web_view);
-     top = GTK_WINDOW(priv->base.parent);
-     webkit_print_operation_run_dialog (op, top);
+     basename = g_path_get_basename(jobname);
+     print_settings = gtk_print_settings_new();
+     webkit_print_operation_set_print_settings(op, print_settings);
+     export_filename = g_strdup(jobname);
+     g_free(basename);
+     gtk_print_settings_set(print_settings,
+                    GTK_PRINT_SETTINGS_OUTPUT_BASENAME,
+                    export_filename);
+     webkit_print_operation_set_print_settings(op, print_settings);
+     // Open a print dialog
+     top = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (priv->web_view)));
+     print_response = webkit_print_operation_run_dialog (op, top);
+     if (print_response == WEBKIT_PRINT_OPERATION_RESPONSE_PRINT)
+     {
+          // Get the newly updated print settings
+          g_object_unref(print_settings);
+          print_settings = g_object_ref(webkit_print_operation_get_print_settings(op));
+     }
+     g_free(export_dirname);
+     g_free(export_filename);
      g_object_unref (op);
+     g_object_unref (print_settings);
 }
 
 static void
diff --git a/gnucash/html/gnc-html-webkit2.h b/gnucash/html/gnc-html-webkit2.h
index c2cec5858..f19f234a3 100644
--- a/gnucash/html/gnc-html-webkit2.h
+++ b/gnucash/html/gnc-html-webkit2.h
@@ -39,6 +39,9 @@ typedef struct _GncHtmlWebkit GncHtmlWebkit;
 typedef struct _GncHtmlWebkitClass GncHtmlWebkitClass;
 typedef struct _GncHtmlWebkitPrivate GncHtmlWebkitPrivate;
 
+/** Key for saving the PDF-export directory in the print settings */
+#define GNC_GTK_PRINT_SETTINGS_EXPORT_DIR "gnc-pdf-export-directory"
+
 struct _GncHtmlWebkit
 {
     GncHtml parent_instance;
diff --git a/gnucash/html/gnc-html.c b/gnucash/html/gnc-html.c
index f2c8a535c..bff658a64 100644
--- a/gnucash/html/gnc-html.c
+++ b/gnucash/html/gnc-html.c
@@ -535,10 +535,11 @@ void
 gnc_html_print (GncHtml* self, const char *jobname, gboolean export_pdf)
 #else
 void
-gnc_html_print (GncHtml* self)
+gnc_html_print (GncHtml* self, const char *jobname)
 #endif
 {
     g_return_if_fail( self != NULL );
+     g_return_if_fail( jobname != NULL );
     g_return_if_fail( GNC_IS_HTML(self) );
 
     if ( GNC_HTML_GET_CLASS(self)->print != NULL )
@@ -546,7 +547,7 @@ gnc_html_print (GncHtml* self)
 #ifdef WEBKIT1
       GNC_HTML_GET_CLASS(self)->print (self, jobname, export_pdf);
 #else
-        GNC_HTML_GET_CLASS(self)->print (self);
+        GNC_HTML_GET_CLASS(self)->print (self, jobname);
 #endif
     }
     else
diff --git a/gnucash/html/gnc-html.h b/gnucash/html/gnc-html.h
index ffb8aebe7..67eaf7373 100644
--- a/gnucash/html/gnc-html.h
+++ b/gnucash/html/gnc-html.h
@@ -141,7 +141,7 @@ struct _GncHtmlClass
 #ifdef WEBKIT1
   void (*print) (GncHtml* html, const gchar* jobname, gboolean export_pdf);
 #else
-    void (*print) (GncHtml* html);
+    void (*print) (GncHtml* html, const gchar* jobname);
 #endif
     void (*cancel)( GncHtml* html );
     URLType (*parse_url)( GncHtml* html, const gchar* url,
@@ -220,7 +220,7 @@ void gnc_html_print (GncHtml* html, const char* jobname, gboolean export_pdf);
  *
  * @param html GncHtml object
  */
-void gnc_html_print (GncHtml* html);
+void gnc_html_print (GncHtml* html, const char* jobname);
 #endif
 /**
  * Cancels the current operation
diff --git a/gnucash/report/report-gnome/gnc-plugin-page-report.c b/gnucash/report/report-gnome/gnc-plugin-page-report.c
index be2997629..5140a99bf 100644
--- a/gnucash/report/report-gnome/gnc-plugin-page-report.c
+++ b/gnucash/report/report-gnome/gnc-plugin-page-report.c
@@ -1166,11 +1166,7 @@ gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint report
             N_("Print the current report"),
             G_CALLBACK(gnc_plugin_page_report_print_cb)
         },
-        {
-            "FilePrintPDFAction", GNC_ICON_PDF_EXPORT, N_("Export as P_DF..."), NULL,
-            N_("Export the current report as a PDF document"),
-            G_CALLBACK(gnc_plugin_page_report_exportpdf_cb)
-        },
+
         {
             "EditCutAction", "edit-cut", N_("Cu_t"), "<primary>X",
             N_("Cut the current selection and copy it to clipboard"),
@@ -1870,11 +1866,9 @@ gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report
 
     //g_warning("Setting job name=%s", job_name);
 
-#ifdef WEBKIT1
-    gnc_html_print (priv->html, job_name, FALSE);
-#else
-    gnc_html_print (priv->html);
-#endif
+
+    gnc_html_print (priv->html, job_name);
+
 
     g_free (job_name);
 }
@@ -1916,7 +1910,7 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep
 #ifdef WEBKIT1
     gnc_html_print (priv->html, job_name, TRUE);
 #else
-    gnc_html_print (priv->html);
+    gnc_html_print (priv->html, job_name);
 #endif
 
     if (owner)



Summary of changes:
 gnucash/html/gnc-html-webkit2.c                    | 39 ++++++++++++++++++----
 gnucash/html/gnc-html-webkit2.h                    |  3 ++
 gnucash/html/gnc-html.c                            |  5 +--
 gnucash/html/gnc-html.h                            |  4 +--
 gnucash/report/business-reports/receipt.scm        |  2 +-
 .../report/report-gnome/gnc-plugin-page-report.c   | 16 +++------
 6 files changed, 47 insertions(+), 22 deletions(-)



More information about the gnucash-changes mailing list