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



commit 724da0d1b72d0307f3e04e749ed4f1e2a9a32196
Author: Jens Georg <mail jensge org>
Date:   Wed Oct 19 22:36:26 2016 +0200

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

 src/org.gnome.Shotwell.gresource.xml |    1 +
 src/tags/Branch.vala                 |   40 +++++++++++++++------------------
 ui/tag_sidebar_context.ui            |   17 +++++++++-----
 3 files changed, 30 insertions(+), 28 deletions(-)
---
diff --git a/src/org.gnome.Shotwell.gresource.xml b/src/org.gnome.Shotwell.gresource.xml
index bf973f1..816e961 100644
--- a/src/org.gnome.Shotwell.gresource.xml
+++ b/src/org.gnome.Shotwell.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/org/gnome/Shotwell">
       <file>crop-pivot-reticle.png</file>
       <file>search_sidebar_context.ui</file>
+      <file>tag_sidebar_context.ui</file>
   </gresource>
 </gresources>
diff --git a/src/tags/Branch.vala b/src/tags/Branch.vala
index 0663fe4..c8cfe95 100644
--- a/src/tags/Branch.vala
+++ b/src/tags/Branch.vala
@@ -124,38 +124,33 @@ public class Tags.Branch : Sidebar.Branch {
 
 public class Tags.Header : Sidebar.Header, Sidebar.InternalDropTargetEntry, 
     Sidebar.InternalDragSourceEntry, Sidebar.Contextable {
-    private Gtk.UIManager ui = new Gtk.UIManager();
+    private Gtk.Builder builder;
     private Gtk.Menu? context_menu = null;
     
     public Header() {
         base (_("Tags"));
         setup_context_menu();
     }
-    
+
+    private const GLib.ActionEntry[] entries = { { "new", on_new_tag } };
+
     private void setup_context_menu() {
-        Gtk.ActionGroup group = new Gtk.ActionGroup("SidebarDefault");
-        Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
-        
-        Gtk.ActionEntry new_tag = { "CommonNewTag", null, TRANSLATABLE, null, null, on_new_tag };
-        new_tag.label = Resources.NEW_CHILD_TAG_SIDEBAR_MENU;
-        actions += new_tag;
-        
-        group.add_actions(actions, this);
-        ui.insert_action_group(group, 0);
-        
-        File ui_file = Resources.get_ui("tag_sidebar_context.ui");
+        this.builder = new Gtk.Builder ();
         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/tag_sidebar_context.ui");
+            var model = builder.get_object ("popup-menu") as GLib.MenuModel;
+            this.context_menu = new Gtk.Menu.from_model (model);
+            var group = new GLib.SimpleActionGroup ();
+            group.add_action_entries (entries, this);
+            this.context_menu.insert_action_group ("tag", group);
+        } catch (Error error) {
+            AppWindow.error_message("Error loading UI resource: %s".printf(
+                error.message));
             Application.get_instance().panic();
         }
-        context_menu = (Gtk.Menu) ui.get_widget("/SidebarTagContextMenu");
-        
-        ui.ensure_update();
     }
-    
+
     public bool internal_drop_received(Gee.List<MediaSource> media) {
         AddTagsDialog dialog = new AddTagsDialog();
         string[]? names = dialog.execute();
@@ -193,7 +188,8 @@ public class Tags.Header : Sidebar.Header, Sidebar.InternalDropTargetEntry,
         return context_menu;
     }
     
-    private void on_new_tag() {
+    private void on_new_tag (GLib.SimpleAction action,
+                             GLib.Variant? parameter) {
         NewRootTagCommand creation_command = new NewRootTagCommand();
         AppWindow.get_command_manager().execute(creation_command);
         LibraryWindow.get_app().rename_tag_in_sidebar(creation_command.get_created_tag());
diff --git a/ui/tag_sidebar_context.ui b/ui/tag_sidebar_context.ui
index 4a3d049..a473f6a 100644
--- a/ui/tag_sidebar_context.ui
+++ b/ui/tag_sidebar_context.ui
@@ -1,6 +1,11 @@
-<ui>
-    <popup name="SidebarTagContextMenu">
-        <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">_New</attribute>
+        <attribute name="action">tag.new</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>


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