Uncouple print settings for reports and checks again.

Remove gnc_{save,restore}_print_settings, revert part of r15733.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15735 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-03-18 17:58:58 +00:00
parent a0e5db4497
commit 3fe6b64c95
4 changed files with 34 additions and 57 deletions

View File

@ -107,6 +107,12 @@ static char error_404_title[] = N_("Not found");
static char error_404_body[] = static char error_404_body[] =
N_("The specified URL could not be loaded."); N_("The specified URL could not be loaded.");
#ifdef GTKHTML_USES_GTKPRINT
static GtkPrintSettings *print_settings = NULL;
G_LOCK_DEFINE_STATIC(print_settings);
#endif
static char * static char *
extract_machine_name(const gchar * path) extract_machine_name(const gchar * path)
{ {
@ -1210,8 +1216,7 @@ gnc_html_export(gnc_html * html, const char *filepath)
return TRUE; return TRUE;
} }
#if GTKHTML_USES_GTKPRINT #ifdef GTKHTML_USES_GTKPRINT
static void static void
draw_page_cb(GtkPrintOperation *operation, GtkPrintContext *context, draw_page_cb(GtkPrintOperation *operation, GtkPrintContext *context,
gint page_nr, gpointer user_data) gint page_nr, gpointer user_data)
@ -1228,15 +1233,25 @@ gnc_html_print(gnc_html *html)
GtkPrintOperationResult res; GtkPrintOperationResult res;
print = gtk_print_operation_new(); print = gtk_print_operation_new();
gnc_restore_print_settings(print);
G_LOCK(print_settings);
if (print_settings)
gtk_print_operation_set_print_settings(print, print_settings);
G_UNLOCK(print_settings);
gtk_print_operation_set_n_pages(print, 1); gtk_print_operation_set_n_pages(print, 1);
g_signal_connect(print, "draw_page", G_CALLBACK(draw_page_cb), html); g_signal_connect(print, "draw_page", G_CALLBACK(draw_page_cb), html);
res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
GTK_WINDOW(html->window), NULL); GTK_WINDOW(html->window), NULL);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY) if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
gnc_save_print_settings(print); G_LOCK(print_settings);
if (print_settings)
g_object_unref(print_settings);
print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
G_UNLOCK(print_settings);
}
g_object_unref(print); g_object_unref(print);
} }

View File

@ -105,35 +105,3 @@ gnc_print_session_done(PrintSession * ps)
break; break;
} }
} }
#ifdef HAVE_GTK_2_10
static GtkPrintSettings *print_settings = NULL;
G_LOCK_DEFINE_STATIC(print_settings);
void
gnc_save_print_settings(GtkPrintOperation *print)
{
g_return_if_fail(print);
G_LOCK(print_settings);
if (print_settings)
g_object_unref(print_settings);
print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
G_UNLOCK(print_settings);
}
void
gnc_restore_print_settings(GtkPrintOperation *print)
{
g_return_if_fail(print);
G_LOCK(print_settings);
if (print_settings)
gtk_print_operation_set_print_settings(print, print_settings);
G_UNLOCK(print_settings);
}
#endif /* HAVE_GTK_2_10 */

View File

@ -82,23 +82,6 @@ void gnc_print_session_destroy(PrintSession * ps);
*/ */
void gnc_print_session_done(PrintSession * ps); void gnc_print_session_done(PrintSession * ps);
#if HAVE_GTK_2_10
/** Get the print settings of a given GtkPrintOperation and store them in a
* static variable. Previous values will be overwritten.
*
* @param print A pointer to a print operation.
*/
void gnc_save_print_settings(GtkPrintOperation *print);
/** After a previous call to gnc_save_print_settings, set the print settings of a
* given GtkPrintOperation to the stored value. Otherwise, do nothing.
*
* @param print A pointer to a print operation.
*/
void gnc_restore_print_settings(GtkPrintOperation *print);
#endif
/** @} */ /** @} */
/** @} */ /** @} */

View File

@ -110,6 +110,8 @@ typedef enum format_combo_col_t {
#if USE_GTKPRINT #if USE_GTKPRINT
# define GncPrintContext GtkPrintContext # define GncPrintContext GtkPrintContext
static GtkPrintSettings *print_settings = NULL;
G_LOCK_DEFINE_STATIC(print_settings);
#else #else
# define GncPrintContext GnomePrintContext # define GncPrintContext GnomePrintContext
# define GNOMEPRINT_CLIP_EXTRA 2 # define GNOMEPRINT_CLIP_EXTRA 2
@ -1909,7 +1911,11 @@ gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog * pcd)
print = gtk_print_operation_new(); print = gtk_print_operation_new();
gnc_restore_print_settings(print); G_LOCK(print_settings);
if (print_settings)
gtk_print_operation_set_print_settings(print, print_settings);
G_UNLOCK(print_settings);
gtk_print_operation_set_unit(print, GTK_UNIT_POINTS); gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
gtk_print_operation_set_use_full_page(print, TRUE); gtk_print_operation_set_use_full_page(print, TRUE);
g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL); g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL);
@ -1919,8 +1925,13 @@ gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog * pcd)
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
pcd->caller_window, NULL); pcd->caller_window, NULL);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY) if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
gnc_save_print_settings(print); G_LOCK(print_settings);
if (print_settings)
g_object_unref(print_settings);
print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
G_UNLOCK(print_settings);
}
g_object_unref(print); g_object_unref(print);
} }