[gedit/wip/redesign2] external tools wip: use hidden-when to filter out items



commit dc02b3bc47b483ffa0933869efe7f370b5469bba
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Jan 6 16:31:25 2014 +0100

    external tools wip: use hidden-when to filter out items

 plugins/externaltools/tools/windowactivatable.py |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/plugins/externaltools/tools/windowactivatable.py 
b/plugins/externaltools/tools/windowactivatable.py
index e17326b..fdf5c46 100644
--- a/plugins/externaltools/tools/windowactivatable.py
+++ b/plugins/externaltools/tools/windowactivatable.py
@@ -18,7 +18,7 @@
 
 __all__ = ('ExternalToolsPlugin', 'Manager', 'OutputPanel', 'Capture', 'UniqueById')
 
-from gi.repository import Gio, GObject, Gtk, Gedit, PeasGtk
+from gi.repository import GLib, Gio, GObject, Gtk, Gedit, PeasGtk
 from .manager import Manager
 from .library import ToolLibrary
 from .outputpanel import OutputPanel
@@ -53,10 +53,11 @@ class ToolMenu(object):
     def _insert_directory(self, directory, menu):
         for d in sorted(directory.subdirs, key=lambda x: x.name.lower()):
             submenu = Gio.Menu()
-            item = Gio.MenuItem.new_submenu(d.name.replace('_', '__'), submenu)
-            menu.append_item(item)
+            menu.append_submenu(d.name.replace('_', '__'), submenu)
+            section = Gio.Menu()
+            submenu.append_section(None, section)
 
-            self._insert_directory(d, submenu)
+            self._insert_directory(d, section)
 
         for tool in sorted(directory.tools, key=lambda x: x.name.lower()):
             action_name = 'external-tool_%X_%X' % (id(tool), id(tool.name))
@@ -66,7 +67,9 @@ class ToolMenu(object):
             action.connect('activate', capture_menu_action, self._window, self._panel, tool)
             self._window.add_action(action)
 
-            menu.append(tool.name.replace('_', '__'), "win.%s" % action_name)
+            item = Gio.MenuItem.new(tool.name.replace('_', '__'), "win.%s" % action_name)
+            item.set_attribute_value("hidden-when", GLib.Variant.new_string("action-disabled"))
+            menu.append_item(item)
 
             if tool.shortcut:
                 app = Gio.Application.get_default()


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