mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'Bug-787018' of https://github.com/EvansMike/gnucash into maint
This commit is contained in:
commit
51ffcae9b8
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user