[gedit/wip/redesign2: 2/4] wip: port external tools to new menu api
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/redesign2: 2/4] wip: port external tools to new menu api
- Date: Thu, 2 Jan 2014 22:45:18 +0000 (UTC)
commit 506608047d99cc3ce4f464cca712ca962b634a45
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Jan 2 19:50:53 2014 +0100
wip: port external tools to new menu api
plugins/externaltools/tools/windowactivatable.py | 57 +++++----------------
1 files changed, 14 insertions(+), 43 deletions(-)
---
diff --git a/plugins/externaltools/tools/windowactivatable.py
b/plugins/externaltools/tools/windowactivatable.py
index 431dc76..da8089f 100644
--- a/plugins/externaltools/tools/windowactivatable.py
+++ b/plugins/externaltools/tools/windowactivatable.py
@@ -26,15 +26,12 @@ from .capture import Capture
from .functions import *
class ToolMenu(object):
- def __init__(self, library, window, panel, menupath):
+ def __init__(self, library, window, panel, menu):
super(ToolMenu, self).__init__()
self._library = library
self._window = window
self._panel = panel
- self._menupath = menupath
- self._merge_id = 0
- self._action_group = Gtk.ActionGroup("ExternalToolsPluginToolActions")
self._signals = []
self.update()
@@ -167,45 +164,22 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
self.window._external_tools_window_activatable = self
self._library = ToolLibrary()
- ui_manager = self.window.get_ui_manager()
-
- self._action_group = Gtk.ActionGroup(name='ExternalToolsPluginActions')
- self._action_group.set_translation_domain('gedit')
- self._action_group.add_actions([('ExternalToolManager', None,
- _('Manage _External Tools...'), None,
- _("Opens the External Tools Manager"),
- lambda action: self.open_dialog()),
- ('ExternalTools', None,
- _('External _Tools'), None,
- _("External tools"), None)])
- ui_manager.insert_action_group(self._action_group, -1)
-
- ui_string = """
- <ui>
- <menubar name="MenuBar">
- <menu name="ToolsMenu" action="Tools">
- <placeholder name="ToolsOps_4">
- <separator/>
- <menu name="ExternalToolsMenu" action="ExternalTools">
- <placeholder name="ExternalToolPlaceholder"/>
- </menu>
- <separator/>
- </placeholder>
- <placeholder name="ToolsOps_5">
- <menuitem name="ExternalToolManager" action="ExternalToolManager"/>
- </placeholder>
- </menu>
- </menubar>
- </ui>"""
-
- self._merge_id = ui_manager.add_ui_from_string(ui_string)
+ action = Gio.SimpleAction(name="manage_tools")
+ action.connect("activate", lambda action, parameter: self.open_dialog())
+ self.window.add_action(action)
+
+ self.gear_menu = self.extend_gear_menu("ext9")
+ item = Gio.MenuItem.new(_("Manage _External Tools..."), "win.manage_tools")
+ self.gear_menu.add_menu_item(item)
+ external_tools_submenu = Gio.Menu()
+ item = Gio.MenuItem.new_submenu(_("External _Tools"), external_tools_submenu)
+ self.gear_menu.add_menu_item(item)
# Create output console
self._output_buffer = OutputPanel(self.plugin_info.get_data_dir(), self.window)
- self.menu = ToolMenu(self._library, self.window, self._output_buffer,
- "/MenuBar/ToolsMenu/ToolsOps_4/ExternalToolsMenu/ExternalToolPlaceholder")
- ui_manager.ensure_update()
+ #self.menu = ToolMenu(self._library, self.window, self._output_buffer,
+ # "/MenuBar/ToolsMenu/ToolsOps_4/ExternalToolsMenu/ExternalToolPlaceholder")
bottom = self.window.get_bottom_panel()
image = Gtk.Image.new_from_icon_name("system-run-symbolic", Gtk.IconSize.MENU)
@@ -221,11 +195,8 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
def do_deactivate(self):
self.window._external_tools_window_activatable = None
- ui_manager = self.window.get_ui_manager()
self.menu.deactivate()
- ui_manager.remove_ui(self._merge_id)
- ui_manager.remove_action_group(self._action_group)
- ui_manager.ensure_update()
+ self.window.remove_action("manage_tools")
bottom = self.window.get_bottom_panel()
bottom.remove_item(self._output_buffer.panel)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]