mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #531871: Add a page setup dialog.
Save the page setup in a static variable in print-session.c and use it when initializing a GtkPrintOperation. Add gnc_ui_page_setup() and offer access to it from a File > Pa_ge Setup... menu entry. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17611 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
b8aeba4079
commit
235db3e5a1
@ -1234,7 +1234,7 @@ gnc_html_print(gnc_html *html)
|
||||
|
||||
print = gtk_print_operation_new();
|
||||
|
||||
gnc_print_operation_restore_print_settings(print);
|
||||
gnc_print_operation_init(print);
|
||||
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);
|
||||
|
@ -67,6 +67,9 @@
|
||||
// +JSLED
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-autosave.h"
|
||||
#ifdef HAVE_GTK_2_10
|
||||
# include "print-session.h"
|
||||
#endif
|
||||
|
||||
/** Names of signals generated by the main window. */
|
||||
enum {
|
||||
@ -121,6 +124,9 @@ static void gnc_main_window_plugin_added (GncPlugin *manager, GncPlugin *plugin,
|
||||
static void gnc_main_window_plugin_removed (GncPlugin *manager, GncPlugin *plugin, GncMainWindow *window);
|
||||
|
||||
/* Command callbacks */
|
||||
#ifdef HAVE_GTK_2_10
|
||||
static void gnc_main_window_cmd_page_setup (GtkAction *action, GncMainWindow *window);
|
||||
#endif
|
||||
static void gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_file_close (GtkAction *action, GncMainWindow *window);
|
||||
static void gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window);
|
||||
@ -236,6 +242,14 @@ static GtkActionEntry gnc_menu_actions [] =
|
||||
{ "FileExportAction", NULL, N_("_Export"), NULL, NULL, NULL },
|
||||
{ "FilePrintAction", GTK_STOCK_PRINT, N_("_Print..."), "<control>p",
|
||||
N_("Print the currently active page"), NULL },
|
||||
#ifdef HAVE_GTK_2_10
|
||||
# ifndef GTK_STOCK_PAGE_SETUP
|
||||
# define GTK_STOCK_PAGE_SETUP NULL
|
||||
# endif
|
||||
{ "FilePageSetupAction", GTK_STOCK_PAGE_SETUP, N_("Pa_ge Setup..."), "<control><shift>p",
|
||||
N_("Specify the page size and orientation for printing"),
|
||||
G_CALLBACK (gnc_main_window_cmd_page_setup) },
|
||||
#endif
|
||||
{ "FilePropertiesAction", GTK_STOCK_PROPERTIES, N_("Proper_ties"), "<Alt>Return",
|
||||
N_("Edit the properties of the current file"),
|
||||
G_CALLBACK (gnc_main_window_cmd_file_properties) },
|
||||
@ -3142,6 +3156,20 @@ gnc_main_window_plugin_removed (GncPlugin *manager,
|
||||
|
||||
|
||||
/* Command callbacks */
|
||||
#ifdef HAVE_GTK_2_10
|
||||
static void
|
||||
gnc_main_window_cmd_page_setup (GtkAction *action,
|
||||
GncMainWindow *window)
|
||||
{
|
||||
GtkWindow *gtk_window;
|
||||
|
||||
g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
|
||||
|
||||
gtk_window = gnc_window_get_gtk_window(GNC_WINDOW(window));
|
||||
gnc_ui_page_setup(gtk_window);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window)
|
||||
{
|
||||
|
@ -48,7 +48,9 @@
|
||||
# endif
|
||||
|
||||
static GtkPrintSettings *print_settings = NULL;
|
||||
static GtkPageSetup *page_setup = NULL;
|
||||
G_LOCK_DEFINE_STATIC(print_settings);
|
||||
G_LOCK_DEFINE_STATIC(page_setup);
|
||||
#endif
|
||||
|
||||
|
||||
@ -66,14 +68,59 @@ gnc_print_operation_save_print_settings(GtkPrintOperation *op)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_print_operation_restore_print_settings(GtkPrintOperation *op)
|
||||
gnc_print_operation_init(GtkPrintOperation *op)
|
||||
{
|
||||
g_return_if_fail(op);
|
||||
|
||||
/* Restore print settings */
|
||||
G_LOCK(print_settings);
|
||||
if (print_settings)
|
||||
gtk_print_operation_set_print_settings(op, print_settings);
|
||||
G_UNLOCK(print_settings);
|
||||
|
||||
/* Restore page setup */
|
||||
G_LOCK(page_setup);
|
||||
if (page_setup)
|
||||
gtk_print_operation_set_default_page_setup(op, page_setup);
|
||||
G_UNLOCK(page_setup);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ui_page_setup(GtkWindow *parent)
|
||||
{
|
||||
GtkPrintSettings *settings = NULL;
|
||||
GtkPageSetup *old_page_setup, *new_page_setup;
|
||||
|
||||
/* Get a reference to the current print settings */
|
||||
G_LOCK(print_settings);
|
||||
settings = print_settings;
|
||||
if (settings)
|
||||
g_object_ref(settings);
|
||||
G_UNLOCK(print_settings);
|
||||
|
||||
/* Get a reference to the current page setup */
|
||||
G_LOCK(page_setup);
|
||||
old_page_setup = page_setup;
|
||||
if (old_page_setup)
|
||||
g_object_ref(old_page_setup);
|
||||
G_UNLOCK(page_setup);
|
||||
|
||||
/* Run dialog */
|
||||
new_page_setup = gtk_print_run_page_setup_dialog(parent, old_page_setup,
|
||||
settings);
|
||||
|
||||
/* Save new page setup */
|
||||
G_LOCK(page_setup);
|
||||
if (page_setup)
|
||||
g_object_unref(page_setup);
|
||||
page_setup = new_page_setup;
|
||||
G_UNLOCK(page_setup);
|
||||
|
||||
/* Release references */
|
||||
if (settings)
|
||||
g_object_unref(settings);
|
||||
if (old_page_setup)
|
||||
g_object_unref(old_page_setup);
|
||||
}
|
||||
#endif /* HAVE_GTK_2_10 */
|
||||
|
||||
|
@ -49,11 +49,19 @@ void gnc_print_operation_save_print_settings(GtkPrintOperation *op);
|
||||
/**
|
||||
* If print settings have been saved by
|
||||
* gnc_print_operation_save_print_settings(), then set them on the given
|
||||
* GtkPrintOperation @a op.
|
||||
* GtkPrintOperation @a op. Set the default page setup as well.
|
||||
*
|
||||
* @param op non-NULL print operation
|
||||
*/
|
||||
void gnc_print_operation_restore_print_settings(GtkPrintOperation *op);
|
||||
void gnc_print_operation_init(GtkPrintOperation *op);
|
||||
|
||||
/**
|
||||
* Run a page setup dialog and save the resulting GtkPageSetup in a static
|
||||
* variable.
|
||||
*
|
||||
* @param parent Transient parent, or NULL
|
||||
*/
|
||||
void gnc_ui_page_setup(GtkWindow *parent);
|
||||
|
||||
#endif /* HAVE_GTK_2_10 */
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
<placeholder name="FileSavePlaceholder"/>
|
||||
<separator name="FileSep2"/>
|
||||
<menuitem name="FilePrint" action="FilePrintAction"/>
|
||||
<menuitem name="FilePageSetup" action="FilePageSetupAction"/>
|
||||
<placeholder name="FilePrintPlaceholder"/>
|
||||
<menu name="FileExport" action="FileExportAction">
|
||||
<placeholder name="FileExportPlaceholder"/>
|
||||
|
@ -1978,7 +1978,7 @@ gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog * pcd)
|
||||
|
||||
print = gtk_print_operation_new();
|
||||
|
||||
gnc_print_operation_restore_print_settings(print);
|
||||
gnc_print_operation_init(print);
|
||||
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), NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user