From b7cf1b9c79f6c547ac8daec82d3fa851ceec839d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 25 Sep 2015 10:27:24 +0200 Subject: [PATCH 1/2] Add a traditional menu bar Bug: https://bugzilla.gnome.org/749976 Bug-Debian: https://bugs.debian.org/793445 --- data/Makefile.am | 1 data/eog-menubar.ui | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 src/eog-application.c | 35 ++++++++ src/eog-window.c | 59 +++++++------- src/eog.gresource.xml | 1 6 files changed, 280 insertions(+), 26 deletions(-) create mode 100644 data/eog-menubar.xml --- a/data/Makefile.am +++ b/data/Makefile.am @@ -39,6 +39,7 @@ EXTRA_DIST = \ eog-app-menu.ui \ eog-gear-menu.ui \ eog-image-properties-dialog.ui \ + eog-menubar.ui \ eog-multiple-save-as-dialog.ui \ eog-preferences-dialog.ui \ eog-zoom-entry.ui \ --- /dev/null +++ b/data/eog-menubar.ui @@ -0,0 +1,209 @@ + + + + + _Image +
+ + _Open… + win.open + <Ctrl>o + +
+
+ + _Save + win.save + <Ctrl>s + + + _Save As… + win.save-as + <Ctrl><Shift>s + +
+
+ + Print… + win.print + <Ctrl>p + +
+
+ + Set as _Wallpaper + win.set-wallpaper + <Ctrl>F8 + + + Show Containing _Folder + win.open-folder + +
+
+ + Image Properties + win.properties + <Alt>Return + +
+
+ + _Close + win.close + <Ctrl>w + +
+
+ + _Edit +
+ + _Undo + win.undo + <Ctrl>z + +
+
+ + _Copy Image + win.copy + <Ctrl>c + +
+
+ + Flip _Horizontal + win.flip-horizontal + + + Flip _Vertical + win.flip-vertical + +
+
+ + _Rotate Clockwise + win.rotate-90 + <Ctrl>r + + + Rotate Counter_clockwise + win.rotate-270 + <Ctrl><Shift>r + +
+
+ + Move to _Trash + win.move-trash + Delete + + + _Delete + win.delete + <Shift>Delete + +
+
+ + _Preferences + app.preferences + +
+
+ + _View +
+ + _Statusbar + win.view-statusbar + + + _Image Gallery + win.view-gallery + F9 + + + Side _Pane + win.view-sidebar + <Ctrl>F9 + +
+
+ + Zoom _In + win.zoom-in + plus + + + Zoom _Out + win.zoom-out + minus + + + _Best Fit + win.toggle-zoom-fit + F + +
+
+ + _Fullscreen + win.view-fullscreen + F11 + + + Slide Show + win.view-slideshow + F5 + +
+
+ + _Go +
+ + _Previous Image + win.go-previous + Left + + + _Next Image + win.go-next + Right + +
+
+ + _First Image + win.go-first + <Alt>Home + + + _Last Image + win.go-last + <Alt>End + +
+
+ + _Help +
+ + _Contents + win.manual + F1 + + + win.show-help-overlay + _Keyboard Shortcuts + + + _About + app.about + +
+
+
+
--- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -5,6 +5,7 @@ data/eog.appdata.xml.in data/eog.desktop.in.in data/eog-gear-menu.ui data/eog-image-properties-dialog.ui +data/eog-menubar.ui data/eog-multiple-save-as-dialog.ui data/eog-preferences-dialog.ui data/eog-zoom-entry.ui --- a/src/eog-application.c +++ b/src/eog-application.c @@ -267,6 +267,29 @@ on_extension_removed (PeasExtensionSet * eog_application_activatable_deactivate (EOG_APPLICATION_ACTIVATABLE (exten)); } +static gboolean +in_desktop (const gchar *name) +{ + const gchar *desktop_name_list; + gchar **names; + gboolean in_list = FALSE; + gint i; + + desktop_name_list = g_getenv ("XDG_CURRENT_DESKTOP"); + if (!desktop_name_list) + return FALSE; + + names = g_strsplit (desktop_name_list, ":", -1); + for (i = 0; names[i] && !in_list; i++) + if (strcmp (names[i], name) == 0) { + in_list = TRUE; + break; + } + g_strfreev (names); + + return in_list; +} + static void eog_application_startup (GApplication *application) { @@ -329,6 +352,18 @@ eog_application_startup (GApplication *a G_CALLBACK (on_extension_removed), app); peas_extension_set_call (app->priv->extensions, "activate"); + + if (in_desktop("Unity")) + { + GtkBuilder *builder; + builder = gtk_builder_new_from_resource ("/org/gnome/eog/gtk/menu/menus-traditional.ui"); + + gtk_application_set_app_menu (GTK_APPLICATION (application), NULL); + gtk_application_set_menubar (GTK_APPLICATION (application), + G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"))); + + g_object_unref (builder); + } } static void --- a/src/eog-window.c +++ b/src/eog-window.c @@ -4243,23 +4243,36 @@ eog_window_construct_ui (EogWindow *wind gtk_widget_show (priv->zoom_scale); #endif - menu_button = gtk_menu_button_new (); - menu_image = gtk_image_new_from_icon_name ("open-menu-symbolic", - GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (menu_button), menu_image); - - builder = gtk_builder_new_from_resource ("/org/gnome/eog/ui/eog-gear-menu.ui"); - builder_object = gtk_builder_get_object (builder, "gear-menu"); - gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), - G_MENU_MODEL (builder_object)); - - gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), menu_button); - gtk_widget_show (menu_button); - - action = G_ACTION (g_property_action_new ("toggle-gear-menu", - menu_button, "active")); - g_action_map_add_action (G_ACTION_MAP (window), action); - g_object_unref (action); + priv->open_with_menu = g_menu_new (); + priv->appinfo = g_ptr_array_new_with_free_func (g_object_unref); + + if (!in_desktop ("Unity")) { + menu_button = gtk_menu_button_new (); + menu_image = gtk_image_new_from_icon_name ("open-menu-symbolic", + GTK_ICON_SIZE_BUTTON); + gtk_button_set_image (GTK_BUTTON (menu_button), menu_image); + + builder = gtk_builder_new_from_resource ("/org/gnome/eog/ui/eog-gear-menu.ui"); + builder_object = gtk_builder_get_object (builder, "gear-menu"); + gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), + G_MENU_MODEL (builder_object)); + + gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), menu_button); + gtk_widget_show (menu_button); + + builder_object = gtk_builder_get_object (builder, "open-with-menu"); + g_menu_append_section (G_MENU (builder_object), + NULL, + G_MENU_MODEL (priv->open_with_menu)); + priv->gear_menu_builder = builder; + builder = NULL; + + action = G_ACTION (g_property_action_new ("toggle-gear-menu", + menu_button, "active")); + g_action_map_add_action (G_ACTION_MAP (window), action); + g_object_unref (action); + + } fullscreen_button = gtk_button_new_from_icon_name ("view-fullscreen-symbolic", GTK_ICON_SIZE_BUTTON); @@ -4270,15 +4283,6 @@ eog_window_construct_ui (EogWindow *wind gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), fullscreen_button); gtk_widget_show (fullscreen_button); - priv->open_with_menu = g_menu_new (); - priv->appinfo = g_ptr_array_new_with_free_func (g_object_unref); - builder_object = gtk_builder_get_object (builder, "open-with-menu"); - g_menu_append_section (G_MENU (builder_object), - NULL, - G_MENU_MODEL (priv->open_with_menu)); - priv->gear_menu_builder = builder; - builder = NULL; - priv->cbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (priv->box), priv->cbox, TRUE, TRUE, 0); gtk_widget_show (priv->cbox); @@ -5250,6 +5254,9 @@ eog_window_get_gear_menu_section (EogWin GObject *object; g_return_val_if_fail (EOG_IS_WINDOW (window), NULL); + if (window->priv->gear_menu_builder == NULL) + return NULL; + object = gtk_builder_get_object (window->priv->gear_menu_builder, id); if (object == NULL || !G_IS_MENU (object)) return NULL; --- a/src/eog.gresource.xml +++ b/src/eog.gresource.xml @@ -14,6 +14,7 @@ eog-app-menu.ui + eog-menubar.ui help-overlay.ui