[gedit] With gtk > 2.17.4 use page setup embedded in print dialog
- From: Paolo Borelli <pborelli src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit] With gtk > 2.17.4 use page setup embedded in print dialog
- Date: Mon, 10 Aug 2009 19:00:27 +0000 (UTC)
commit b31143c7985a794f56739f2b6b83721eeccbe004
Author: Paolo Borelli <porelli gnome org>
Date: Mon Aug 10 20:58:45 2009 +0200
With gtk > 2.17.4 use page setup embedded in print dialog
Based on a patch by Marek KaÅ¡Ãk, bug #591338
gedit/gedit-commands-file-print.c | 2 ++
gedit/gedit-commands.h | 9 +++++++--
gedit/gedit-print-job.c | 4 ++++
gedit/gedit-tab.c | 4 ++++
gedit/gedit-tab.h | 5 ++++-
gedit/gedit-ui.h | 2 ++
gedit/gedit-ui.xml | 2 +-
gedit/gedit-window.c | 34 ++++++++++++++++++++++++++--------
8 files changed, 50 insertions(+), 12 deletions(-)
---
diff --git a/gedit/gedit-commands-file-print.c b/gedit/gedit-commands-file-print.c
index 277cae5..455e2e2 100644
--- a/gedit/gedit-commands-file-print.c
+++ b/gedit/gedit-commands-file-print.c
@@ -42,6 +42,7 @@
#include "gedit-tab.h"
#include "gedit-debug.h"
+#if !GTK_CHECK_VERSION (2, 17, 4)
void
_gedit_cmd_file_page_setup (GtkAction *action,
GeditWindow *window)
@@ -56,6 +57,7 @@ _gedit_cmd_file_page_setup (GtkAction *action,
_gedit_tab_page_setup (tab);
}
+#endif
void
_gedit_cmd_file_print_preview (GtkAction *action,
diff --git a/gedit/gedit-commands.h b/gedit/gedit-commands.h
index 8ef5aec..08e7088 100644
--- a/gedit/gedit-commands.h
+++ b/gedit/gedit-commands.h
@@ -80,8 +80,6 @@ void _gedit_cmd_file_revert (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_file_open_uri (GtkAction *action,
GeditWindow *window);
-void _gedit_cmd_file_page_setup (GtkAction *action,
- GeditWindow *window);
void _gedit_cmd_file_print_preview (GtkAction *action,
GeditWindow *window);
void _gedit_cmd_file_print (GtkAction *action,
@@ -156,6 +154,13 @@ void _gedit_cmd_file_close_tab (GeditTab *tab,
void _gedit_cmd_file_save_documents_list (GeditWindow *window,
GList *docs);
+
+#if !GTK_CHECK_VERSION (2, 17, 4)
+void _gedit_cmd_file_page_setup (GtkAction *action,
+ GeditWindow *window);
+#endif
+
+
G_END_DECLS
#endif /* __GEDIT_COMMANDS_H__ */
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
index d5ac8ca..436f246 100644
--- a/gedit/gedit-print-job.c
+++ b/gedit/gedit-print-job.c
@@ -751,6 +751,10 @@ gedit_print_job_print (GeditPrintJob *job,
gtk_print_operation_set_job_name (priv->operation, job_name);
g_free (job_name);
+#if GTK_CHECK_VERSION (2, 17, 4)
+ gtk_print_operation_set_embed_page_setup (priv->operation, TRUE);
+#endif
+
gtk_print_operation_set_custom_tab_label (priv->operation,
_("Text Editor"));
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 7b81732..476f3fd 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -2504,6 +2504,8 @@ show_printing_message_area (GeditTab *tab, gboolean preview)
set_message_area (tab, area);
}
+#if !GTK_CHECK_VERSION (2, 17, 4)
+
static void
page_setup_done_cb (GtkPageSetup *setup,
GeditTab *tab)
@@ -2546,6 +2548,8 @@ _gedit_tab_page_setup (GeditTab *tab)
/* CHECK: should we unref setup and settings? */
}
+#endif
+
static void
gedit_tab_print_or_print_preview (GeditTab *tab,
GtkPrintOperationAction print_action)
diff --git a/gedit/gedit-tab.h b/gedit/gedit-tab.h
index 81c0e3d..43d90d2 100644
--- a/gedit/gedit-tab.h
+++ b/gedit/gedit-tab.h
@@ -146,7 +146,6 @@ void _gedit_tab_save_as (GeditTab *tab,
const gchar *uri,
const GeditEncoding *encoding);
-void _gedit_tab_page_setup (GeditTab *tab);
void _gedit_tab_print (GeditTab *tab);
void _gedit_tab_print_preview (GeditTab *tab);
@@ -154,6 +153,10 @@ void _gedit_tab_mark_for_closing (GeditTab *tab);
gboolean _gedit_tab_can_close (GeditTab *tab);
+#if !GTK_CHECK_VERSION (2, 17, 4)
+void _gedit_tab_page_setup (GeditTab *tab);
+#endif
+
G_END_DECLS
#endif /* __GEDIT_TAB_H__ */
diff --git a/gedit/gedit-ui.h b/gedit/gedit-ui.h
index ef50668..121688e 100644
--- a/gedit/gedit-ui.h
+++ b/gedit/gedit-ui.h
@@ -83,8 +83,10 @@ static const GtkActionEntry gedit_menu_entries[] =
N_("Save the current file with a different name"), G_CALLBACK (_gedit_cmd_file_save_as) },
{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL,
N_("Revert to a saved version of the file"), G_CALLBACK (_gedit_cmd_file_revert) },
+#if !GTK_CHECK_VERSION (2, 17, 4)
{ "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Set_up..."), NULL,
N_("Setup the page settings"), G_CALLBACK (_gedit_cmd_file_page_setup) },
+#endif
{ "FilePrintPreview", GTK_STOCK_PRINT_PREVIEW, N_("Print Previe_w"),"<control><shift>P",
N_("Print preview"), G_CALLBACK (_gedit_cmd_file_print_preview) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
diff --git a/gedit/gedit-ui.xml b/gedit/gedit-ui.xml
index 9d28db9..21c31a7 100644
--- a/gedit/gedit-ui.xml
+++ b/gedit/gedit-ui.xml
@@ -41,7 +41,7 @@
<menuitem name="FileRevertMenu" action="FileRevert"/>
<placeholder name="FileOps_4"/>
<separator/>
- <menuitem name="FilePageSetupMenu" action="FilePageSetup"/>
+ <placeholder name="FileOps_5"/>
<menuitem name="FilePrintPreviewMenu" action="FilePrintPreview"/>
<menuitem name="FilePrintMenu" action="FilePrint"/>
<placeholder name="FileRecentsPlaceholder">
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index ce490e9..f21ca14 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -1411,7 +1411,6 @@ create_menu_bar_and_toolbar (GeditWindow *window,
GtkWidget *menubar;
GtkRecentManager *recent_manager;
GError *error = NULL;
- GeditLockdownMask lockdown;
gchar *ui_file;
gedit_debug (DEBUG_WINDOW);
@@ -1495,6 +1494,30 @@ create_menu_bar_and_toolbar (GeditWindow *window,
}
g_free (ui_file);
+#if !GTK_CHECK_VERSION (2, 17, 4)
+ /* merge page setup menu manually since we cannot have conditional
+ * sections in gedit-ui.xml */
+ {
+ guint merge_id;
+ GeditLockdownMask lockdown;
+
+ merge_id = gtk_ui_manager_new_merge_id (manager);
+ gtk_ui_manager_add_ui (manager,
+ merge_id,
+ "/MenuBar/FileMenu/FileOps_5",
+ "FilePageSetupMenu",
+ "FilePageSetup",
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FilePageSetup");
+ gtk_action_set_sensitive (action,
+ !(lockdown & GEDIT_LOCKDOWN_PRINT_SETUP));
+ }
+#endif
+
/* show tooltips in the statusbar */
g_signal_connect (manager,
"connect_proxy",
@@ -1505,13 +1528,6 @@ create_menu_bar_and_toolbar (GeditWindow *window,
G_CALLBACK (disconnect_proxy_cb),
window);
- /* page setup menu lockdown state */
- lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
- action = gtk_action_group_get_action (window->priv->action_group,
- "FilePageSetup");
- gtk_action_set_sensitive (action,
- !(lockdown & GEDIT_LOCKDOWN_PRINT_SETUP));
-
/* recent files menu */
action_group = gtk_action_group_new ("RecentFilesActions");
gtk_action_group_set_translation_domain (action_group, NULL);
@@ -2535,10 +2551,12 @@ _gedit_window_set_lockdown (GeditWindow *window,
!(window->priv->state & GEDIT_WINDOW_STATE_PRINTING) &&
!(lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK));
+#if !GTK_CHECK_VERSION (2, 17, 4)
action = gtk_action_group_get_action (window->priv->action_group,
"FilePageSetup");
gtk_action_set_sensitive (action,
!(lockdown & GEDIT_LOCKDOWN_PRINT_SETUP));
+#endif
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]