almanah r123 - in trunk: . data src
- From: pwithnall svn gnome org
- To: svn-commits-list gnome org
- Subject: almanah r123 - in trunk: . data src
- Date: Sat, 20 Dec 2008 00:11:20 +0000 (UTC)
Author: pwithnall
Date: Sat Dec 20 00:11:20 2008
New Revision: 123
URL: http://svn.gnome.org/viewvc/almanah?rev=123&view=rev
Log:
2008-12-20 Philip Withnall <philip tecnocode co uk>
* data/almanah.ui:
* src/main-window.c (mw_page_setup_activate_cb),
(mw_print_preview_activate_cb), (mw_print_activate_cb):
* src/main.c (storage_manager_disconnected_cb), (main):
* src/main.h:
* src/printing.c (custom_widget_apply_cb), (almanah_print_entries),
(almanah_print_page_setup):
* src/printing.h: Add Page Setup and Print Preview menu entries,
and improve the print settings code. (Helps: #564706)
Modified:
trunk/ChangeLog
trunk/data/almanah.ui
trunk/src/main-window.c
trunk/src/main.c
trunk/src/main.h
trunk/src/printing.c
trunk/src/printing.h
Modified: trunk/data/almanah.ui
==============================================================================
--- trunk/data/almanah.ui (original)
+++ trunk/data/almanah.ui Sat Dec 20 00:11:20 2008
@@ -10,11 +10,27 @@
</object>
</child>
<child>
+ <object class="GtkAction" id="almanah_ui_page_setup">
+ <property name="stock-id">gtk-page-setup</property>
+ <property name="name">file-page-setup</property>
+ <signal name="activate" handler="mw_page_setup_activate_cb"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="almanah_ui_print_preview">
+ <property name="stock-id">gtk-print-preview</property>
+ <property name="name">file-print-preview</property>
+ <signal name="activate" handler="mw_print_preview_activate_cb"/>
+ </object>
+ <accelerator key="P" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
+ </child>
+ <child>
<object class="GtkAction" id="almanah_ui_print">
<property name="stock-id">gtk-print</property>
<property name="name">file-print</property>
<signal name="activate" handler="mw_print_activate_cb"/>
</object>
+ <accelerator key="P" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
<object class="GtkAction" id="almanah_ui_quit">
@@ -22,6 +38,7 @@
<property name="name">file-quit</property>
<signal name="activate" handler="mw_quit_activate_cb"/>
</object>
+ <accelerator key="Q" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
<object class="GtkAction" id="almanah_ui_edit">
@@ -159,7 +176,10 @@
<ui>
<menubar name="almanah_mw_menu_bar">
<menu action="almanah_ui_file">
+ <menuitem action="almanah_ui_page_setup"/>
+ <menuitem action="almanah_ui_print_preview"/>
<menuitem action="almanah_ui_print"/>
+ <separator/>
<menuitem action="almanah_ui_quit"/>
</menu>
<menu action="almanah_ui_edit">
Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c (original)
+++ trunk/src/main-window.c Sat Dec 20 00:11:20 2008
@@ -674,9 +674,21 @@
}
void
+mw_page_setup_activate_cb (GtkAction *action, gpointer user_data)
+{
+ almanah_print_page_setup ();
+}
+
+void
+mw_print_preview_activate_cb (GtkAction *action, gpointer user_data)
+{
+ almanah_print_entries (TRUE);
+}
+
+void
mw_print_activate_cb (GtkAction *action, gpointer user_data)
{
- almanah_print_entries ();
+ almanah_print_entries (FALSE);
}
void
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Sat Dec 20 00:11:20 2008
@@ -33,6 +33,8 @@
{
g_object_unref (almanah->storage_manager);
g_object_unref (almanah->gconf_client);
+ g_object_unref (almanah->page_setup);
+ g_object_unref (almanah->print_settings);
g_free (almanah);
@@ -153,6 +155,10 @@
/* Create the event manager */
almanah->event_manager = almanah_event_manager_new ();
+ /* Set up printing objects */
+ almanah->print_settings = gtk_print_settings_new ();
+ almanah->page_setup = gtk_page_setup_new ();
+
/* Create and show the interface */
almanah_create_interface ();
gtk_widget_show_all (almanah->main_window);
Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h (original)
+++ trunk/src/main.h Sat Dec 20 00:11:20 2008
@@ -38,6 +38,8 @@
AlmanahStorageManager *storage_manager;
AlmanahEventManager *event_manager;
GConfClient *gconf_client;
+ GtkPrintSettings *print_settings;
+ GtkPageSetup *page_setup;
GtkWidget *main_window;
GtkWidget *add_definition_dialog;
Modified: trunk/src/printing.c
==============================================================================
--- trunk/src/printing.c (original)
+++ trunk/src/printing.c Sat Dec 20 00:11:20 2008
@@ -440,11 +440,12 @@
/* Start date */
gtk_calendar_get_date (almanah_operation->start_calendar, &year, &month, &day);
- almanah_operation->start_date = g_date_new_dmy (day, month + 1, year);
+ g_date_set_dmy (almanah_operation->start_date, day, month + 1, year);
+ g_date_set_dmy (almanah_operation->current_date, day, month + 1, year);
/* End date */
gtk_calendar_get_date (almanah_operation->end_calendar, &year, &month, &day);
- almanah_operation->end_date = g_date_new_dmy (day, month + 1, year);
+ g_date_set_dmy (almanah_operation->end_date, day, month + 1, year);
/* Ensure they're in order */
if (g_date_compare (almanah_operation->start_date, almanah_operation->end_date) > 0) {
@@ -453,16 +454,13 @@
almanah_operation->start_date = almanah_operation->end_date;
almanah_operation->end_date = temp;
}
-
- almanah_operation->current_date = g_memdup (almanah_operation->start_date, sizeof (*(almanah_operation->start_date)));
}
void
-almanah_print_entries (void)
+almanah_print_entries (gboolean print_preview)
{
GtkPrintOperation *operation;
GtkPrintOperationResult res;
- static GtkPrintSettings *settings;
AlmanahPrintOperation almanah_operation;
operation = gtk_print_operation_new ();
@@ -474,8 +472,20 @@
almanah_operation.buffer = gtk_text_buffer_new (NULL);
almanah_interface_create_text_tags (almanah_operation.buffer, FALSE);
- if (settings != NULL)
- gtk_print_operation_set_print_settings (operation, settings);
+ /* Set up default dates here for print previews */
+ almanah_operation.start_date = g_date_new ();
+ g_date_set_time_t (almanah_operation.start_date, time (NULL));
+ g_date_subtract_months (almanah_operation.start_date, 1);
+
+ almanah_operation.end_date = g_date_new ();
+ g_date_set_time_t (almanah_operation.end_date, time (NULL));
+
+ almanah_operation.current_date = g_memdup (almanah_operation.start_date, sizeof (*(almanah_operation.start_date)));
+
+ if (almanah->print_settings != NULL)
+ gtk_print_operation_set_print_settings (operation, almanah->print_settings);
+ if (almanah->page_setup != NULL)
+ gtk_print_operation_set_default_page_setup (operation, almanah->page_setup);
gtk_print_operation_set_n_pages (operation, 1);
@@ -484,13 +494,18 @@
g_signal_connect (operation, "create-custom-widget", G_CALLBACK (create_custom_widget_cb), &almanah_operation);
g_signal_connect (operation, "custom-widget-apply", G_CALLBACK (custom_widget_apply_cb), &almanah_operation);
- res = gtk_print_operation_run (operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+ res = gtk_print_operation_run (operation,
+ (print_preview == TRUE) ? GTK_PRINT_OPERATION_ACTION_PREVIEW : GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
GTK_WINDOW (almanah->main_window), NULL);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
- if (settings != NULL)
- g_object_unref (settings);
- settings = g_object_ref (gtk_print_operation_get_print_settings (operation));
+ if (almanah->print_settings != NULL)
+ g_object_unref (almanah->print_settings);
+ almanah->print_settings = g_object_ref (gtk_print_operation_get_print_settings (operation));
+
+ if (almanah->page_setup != NULL)
+ g_object_unref (almanah->page_setup);
+ almanah->page_setup = g_object_ref (gtk_print_operation_get_default_page_setup (operation));
}
if (almanah_operation.current_date != NULL) {
@@ -502,3 +517,13 @@
g_object_unref (operation);
}
+void
+almanah_print_page_setup (void)
+{
+ GtkPageSetup *page_setup;
+
+ page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (almanah->main_window), almanah->page_setup, almanah->print_settings);
+ if (almanah->page_setup != NULL)
+ g_object_unref (almanah->page_setup);
+ almanah->page_setup = page_setup;
+}
Modified: trunk/src/printing.h
==============================================================================
--- trunk/src/printing.h (original)
+++ trunk/src/printing.h Sat Dec 20 00:11:20 2008
@@ -24,7 +24,8 @@
G_BEGIN_DECLS
-void almanah_print_entries (void);
+void almanah_print_entries (gboolean print_preview);
+void almanah_print_page_setup (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]