[shotwell/wip/dedeprecate: 11/26] wip: Remove UIManager



commit 3eccee28f88a73a03fb5c0ec13fa719a79684ca0
Author: Jens Georg <mail jensge org>
Date:   Wed Oct 19 23:06:05 2016 +0200

    wip: Remove UIManager
    
    Signed-off-by: Jens Georg <mail jensge org>

 shotwell.am                          |    7 +++++-
 src/org.gnome.Shotwell.gresource.xml |    1 +
 src/sidebar/Tree.vala                |   42 ++++++++++++++-------------------
 ui/sidebar_default_context.ui        |   22 +++++++++++++-----
 4 files changed, 41 insertions(+), 31 deletions(-)
---
diff --git a/shotwell.am b/shotwell.am
index d1b64ef..6f8250d 100644
--- a/shotwell.am
+++ b/shotwell.am
@@ -24,7 +24,12 @@ nodist_shotwell_SOURCES = \
        src/resource.c
 MOSTLYCLEANFILES += src/resource.c
 
-src/resource.c: src/org.gnome.Shotwell.gresource.xml
+shotwell_resource_deps = $(shell $(GLIB_COMPILE_RESOURCES) \
+               --sourcedir=$(abs_top_srcdir)/icons \
+               --sourcedir=$(abs_top_srcdir)/ui \
+               --generate-dependencies src/org.gnome.Shotwell.gresource.xml)
+
+src/resource.c: src/org.gnome.Shotwell.gresource.xml $(shotwell_resource_deps)
        $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ \
                --sourcedir=$(abs_top_srcdir)/icons \
                --sourcedir=$(abs_top_srcdir)/ui \
diff --git a/src/org.gnome.Shotwell.gresource.xml b/src/org.gnome.Shotwell.gresource.xml
index 816e961..817e93f 100644
--- a/src/org.gnome.Shotwell.gresource.xml
+++ b/src/org.gnome.Shotwell.gresource.xml
@@ -4,5 +4,6 @@
       <file>crop-pivot-reticle.png</file>
       <file>search_sidebar_context.ui</file>
       <file>tag_sidebar_context.ui</file>
+      <file>sidebar_default_context.ui</file>
   </gresource>
 </gresources>
diff --git a/src/sidebar/Tree.vala b/src/sidebar/Tree.vala
index 0fd9144..f02eac0 100644
--- a/src/sidebar/Tree.vala
+++ b/src/sidebar/Tree.vala
@@ -59,7 +59,7 @@ public class Sidebar.Tree : Gtk.TreeView {
         typeof (string?)            // ICON
     );
     
-    private Gtk.UIManager ui = new Gtk.UIManager();
+    private Gtk.Builder builder = new Gtk.Builder ();
     private Gtk.CellRendererText text_renderer;
     private unowned ExternalDropHandler drop_handler;
     private Gtk.Entry? text_entry = null;
@@ -190,33 +190,27 @@ public class Sidebar.Tree : Gtk.TreeView {
         
         return false;
     }
-    
-    private void setup_default_context_menu() {
-        Gtk.ActionGroup group = new Gtk.ActionGroup("SidebarDefault");
-        Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
-        
-        Gtk.ActionEntry new_search = { "CommonNewSearch", null, TRANSLATABLE, null, null, on_new_search };
-        new_search.label = _("Ne_w Saved Search…");
-        actions += new_search;
 
-        Gtk.ActionEntry new_tag = { "CommonNewTag", null, TRANSLATABLE, null, null, on_new_tag };
-        new_tag.label = _("New _Tag…");
-        actions += new_tag;
-        
-        group.add_actions(actions, this);
-        ui.insert_action_group(group, 0);
-        
-        File ui_file = Resources.get_ui("sidebar_default_context.ui");
+    private const GLib.ActionEntry[] entries = {
+        { "tag.new", on_new_tag },
+        { "search.new", on_new_search }
+    };
+
+    private void setup_default_context_menu() {
         try {
-            ui.add_ui_from_file(ui_file.get_path());
-        } catch (Error err) {
-            AppWindow.error_message("Error loading UI file %s: %s".printf(
-                ui_file.get_path(), err.message));
+            this.builder.add_from_resource
+                            ("/org/gnome/Shotwell/sidebar_default_context.ui");
+            var model = builder.get_object ("popup-menu") as GLib.MenuModel;
+            this.default_context_menu = new Gtk.Menu.from_model (model);
+            var group = new GLib.SimpleActionGroup ();
+            group.add_action_entries (entries, this);
+            this.insert_action_group ("sidebar", group);
+            this.default_context_menu.attach_to_widget (this, null);
+        } catch (Error error) {
+            AppWindow.error_message("Error loading UI resource: %s".printf(
+                error.message));
             Application.get_instance().panic();
         }
-        default_context_menu = (Gtk.Menu) ui.get_widget("/SidebarDefaultContextMenu");
-        
-        ui.ensure_update();
     }
     
     private bool has_wrapper(Sidebar.Entry entry) {
diff --git a/ui/sidebar_default_context.ui b/ui/sidebar_default_context.ui
index 2e5ed87..bd3d63a 100644
--- a/ui/sidebar_default_context.ui
+++ b/ui/sidebar_default_context.ui
@@ -1,7 +1,17 @@
-<ui>
-    <popup name="SidebarDefaultContextMenu">
-        <menuitem name="NewSearch" action="CommonNewSearch" />
-        <menuitem name="NewTag" action="CommonNewTag" />
-    </popup>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="shotwell">
+  <menu id='popup-menu'>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Ne_w Saved Search…</attribute>
+        <attribute name="action">sidebar.search.new</attribute>
+        <attribute name="accel">&lt;Primary&gt;s</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">New _Tag…</attribute>
+        <attribute name="action">sidebar.tag.new</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
 


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