[gedit/wip/redesign2: 2/2] Port quickopen to new menu api



commit 59fdd7fbcdab92482dda5b68ecdb364a0ca97310
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Jan 1 22:37:06 2014 +0100

    Port quickopen to new menu api

 plugins/quickopen/quickopen/__init__.py |   26 ++++++--------------------
 1 files changed, 6 insertions(+), 20 deletions(-)
---
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
index d2d37b6..f5ba158 100644
--- a/plugins/quickopen/quickopen/__init__.py
+++ b/plugins/quickopen/quickopen/__init__.py
@@ -59,16 +59,7 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
 
     def _uninstall_menu(self):
         gear_menu = self.window.get_gear_menu()
-        for i in range(gear_menu.get_n_items()):
-            id_attr = gear_menu.get_item_attribute_value(i, "id", GLib.VariantType.new("s"))
-            if id_attr and id_attr.get_string() == "ext2":
-                model = gear_menu.get_item_link(i, "section")
-                for j in range(model.get_n_items()):
-                    attr = model.get_item_attribute_value(j, "id", GLib.VariantType.new("s"))
-                    if attr and attr.get_string() == "quickopen":
-                        model.remove(j)
-                        break
-                break
+        gear_menu.remove_items(self.merge_id)
 
         self.window.remove_action("quickopen")
 
@@ -77,17 +68,12 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
         action.connect('activate', self.on_quick_open_activate)
         self.window.add_action(action)
 
+        item = Gio.MenuItem.new(_("Quick Open..."), "win.quickopen")
+        item.set_attribute_value("accel", GLib.Variant.new_string("<Primary><Alt>O"))
+
         gear_menu = self.window.get_gear_menu()
-        for i in  range(gear_menu.get_n_items()):
-            id_attr = gear_menu.get_item_attribute_value(i, "id", GLib.VariantType.new("s"))
-            if id_attr and id_attr.get_string() == "ext2":
-                model = gear_menu.get_item_link(i, "section")
-
-                item = Gio.MenuItem.new(_("Quick Open..."), "win.quickopen")
-                item.set_attribute_value("id", GLib.Variant.new_string("quickopen"))
-                item.set_attribute_value("accel", GLib.Variant.new_string("<Primary><Alt>O"))
-                model.append_item(item)
-                break
+        self.merge_id = gear_menu.new_merge_id()
+        gear_menu.add_menu_item (item, self.merge_id, "ext2")
 
     def _create_popup(self):
         paths = []


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