[eog/wip/gaction-migration] Use separate object for thumbnail popup menu



commit d6fa7a086c97408b4f281320293b98f2f7e43f15
Author: Felix Riemann <friemann gnome org>
Date:   Thu Dec 18 20:30:42 2014 +0100

    Use separate object for thumbnail popup menu
    
    Assigning a GtkMenu twice is not guaranteed to be glitchfree.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741050

 data/Makefile.am       |    2 +-
 data/eog-view-popup.ui |   53 ------------------------
 data/popup-menus.ui    |  103 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/eog-window.c       |   22 +++++------
 src/eog.gresource.xml  |    2 +-
 5 files changed, 115 insertions(+), 67 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 7995047..f5e039b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -33,7 +33,7 @@ EXTRA_DIST =                  \
        eog-image-properties-dialog.ui  \
        eog-multiple-save-as-dialog.ui  \
        eog-preferences-dialog.ui \
-       eog-view-popup.ui       \
+       popup-menus.ui  \
        $(DESKTOP_IN_FILES)     \
        $(appdata_in_files)     \
        eog.convert
diff --git a/data/popup-menus.ui b/data/popup-menus.ui
new file mode 100644
index 0000000..813b6ec
--- /dev/null
+++ b/data/popup-menus.ui
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<interface>
+  <menu id="view-popup-menu">
+    <section>
+      <submenu>
+        <attribute name="label" translatable="yes">Open _with</attribute>
+        <section id="open-with-placeholder"/>
+      </submenu>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Save</attribute>
+        <attribute name="action">win.ImageSave</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Save _As…</attribute>
+        <attribute name="action">win.ImageSaveAs</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Print…</attribute>
+        <attribute name="action">win.ImagePrint</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Copy</attribute>
+        <attribute name="action">win.EditCopyImage</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move to _Trash</attribute>
+        <attribute name="action">win.EditMoveToTrash</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Prope_rties</attribute>
+        <attribute name="action">win.ImageProperties</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Set as Wa_llpaper</attribute>
+        <attribute name="action">win.ImageSetAsWallpaper</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Show Containing _Folder</attribute>
+        <attribute name="action">win.ImageOpenContainingFolder</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="thumbnail-popup">
+    <section>
+      <submenu>
+        <attribute name="label" translatable="yes">Open _with</attribute>
+        <section id="open-with-placeholder"/>
+      </submenu>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Save</attribute>
+        <attribute name="action">win.ImageSave</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Save _As…</attribute>
+        <attribute name="action">win.ImageSaveAs</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Print…</attribute>
+        <attribute name="action">win.ImagePrint</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Copy</attribute>
+        <attribute name="action">win.EditCopyImage</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Move to _Trash</attribute>
+        <attribute name="action">win.EditMoveToTrash</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Prope_rties</attribute>
+        <attribute name="action">win.ImageProperties</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Set as Wa_llpaper</attribute>
+        <attribute name="action">win.ImageSetAsWallpaper</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Show Containing _Folder</attribute>
+        <attribute name="action">win.ImageOpenContainingFolder</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/src/eog-window.c b/src/eog-window.c
index bf4f76b..67f8b89 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -4396,16 +4396,12 @@ static void
 eog_window_construct_ui (EogWindow *window)
 {
        EogWindowPrivate *priv;
-
-       GError *error = NULL;
-
-       GtkWidget *view_popup;
+       GtkWidget *popup;
        GtkWidget *hpaned;
        GAction *action = NULL;
        GtkBuilder *builder;
        GObject *builder_object;
 
-
        g_return_if_fail (EOG_IS_WINDOW (window));
 
        priv = window->priv;
@@ -4519,14 +4515,14 @@ eog_window_construct_ui (EogWindow *window)
        g_settings_bind (priv->view_settings, EOG_CONF_VIEW_ZOOM_MULTIPLIER,
                         priv->view, "zoom-multiplier", G_SETTINGS_BIND_GET);
 
-       builder = gtk_builder_new_from_resource ("/org/gnome/eog/ui/eog-view-popup.ui");
+       builder = gtk_builder_new_from_resource ("/org/gnome/eog/ui/popup-menus.ui");
        builder_object = gtk_builder_get_object (builder, "view-popup-menu");
-       view_popup = gtk_menu_new_from_model (G_MENU_MODEL(builder_object));
+       popup = gtk_menu_new_from_model (G_MENU_MODEL(builder_object));
 
        eog_scroll_view_set_popup (EOG_SCROLL_VIEW (priv->view),
-                                  GTK_MENU (view_popup));
+                                  GTK_MENU (popup));
 
-       g_clear_object (&builder);
+       g_object_unref (popup);
 
        gtk_paned_pack1 (GTK_PANED (hpaned),
                         priv->sidebar,
@@ -4560,11 +4556,13 @@ eog_window_construct_ui (EogWindow *window)
        g_settings_bind (priv->ui_settings, EOG_CONF_UI_SCROLL_BUTTONS,
                         priv->nav, "show-buttons", G_SETTINGS_BIND_GET);
 
-       // Reuse ScrollView's menu model for the thumbnail menu
+       builder_object = gtk_builder_get_object (builder, "thumbnail-popup");
+       popup = gtk_menu_new_from_model (G_MENU_MODEL(builder_object));
        eog_thumb_view_set_thumbnail_popup (EOG_THUMB_VIEW (priv->thumbview),
-                                           GTK_MENU (view_popup));
+                                           GTK_MENU (popup));
 
-       g_object_unref (view_popup);
+       g_object_unref (popup);
+       g_clear_object (&builder);
 
        gtk_box_pack_start (GTK_BOX (priv->layout), priv->nav, FALSE, FALSE, 0);
 
diff --git a/src/eog.gresource.xml b/src/eog.gresource.xml
index bfe4fa8..a1048c0 100644
--- a/src/eog.gresource.xml
+++ b/src/eog.gresource.xml
@@ -6,8 +6,8 @@
     <file compressed="true" preprocess="xml-stripblanks">eog-image-properties-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-multiple-save-as-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">eog-preferences-dialog.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks">eog-view-popup.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">fullscreen-toolbar.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">popup-menus.ui</file>
   </gresource>
 </gresources>
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]