Set a printer job name when printing reports and cheques

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20340 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2011-02-25 23:59:21 +00:00
parent 3ab9bbd16f
commit f19e1d0d4c
8 changed files with 36 additions and 14 deletions

View File

@@ -57,7 +57,7 @@ gnc_print_operation_save_print_settings(GtkPrintOperation *op)
}
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 @@ gnc_print_operation_init(GtkPrintOperation *op)
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

View File

@@ -50,8 +50,9 @@ void gnc_print_operation_save_print_settings(GtkPrintOperation *op);
* 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

View File

@@ -2441,7 +2441,7 @@ gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog * pcd)
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);

View File

@@ -104,7 +104,7 @@ static void impl_gtkhtml_show_data( GncHtml* self, const gchar* data, int datale
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 @@ draw_page_cb(GtkPrintOperation *operation, GtkPrintContext *context,
}
static void
impl_gtkhtml_print( GncHtml* self )
impl_gtkhtml_print( GncHtml* self, const gchar* jobname )
{
GtkPrintOperation *print;
GtkPrintOperationResult res;
@@ -946,7 +946,7 @@ impl_gtkhtml_print( GncHtml* self )
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);

View File

@@ -106,7 +106,7 @@ static void impl_webkit_show_data( GncHtml* self, const gchar* data, int datalen
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 @@ impl_webkit_export_to_file( GncHtml* self, const char *filepath )
* @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 @@ impl_webkit_print( GncHtml* self )
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

View File

@@ -525,14 +525,14 @@ gnc_html_export_to_file( GncHtml* self, const gchar* filepath )
}
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
{

View File

@@ -135,7 +135,7 @@ struct _GncHtmlClass
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 @@ gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename );
*
* @param html GncHtml object
*/
void gnc_html_print( GncHtml* html );
void gnc_html_print( GncHtml* html, const gchar* jobname );
/**
* Cancels the current operation

View File

@@ -1570,9 +1570,28 @@ static void
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