From 6f740cbb6b651dfa73ed6c0e0e2cf4176310e3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 18 Feb 2009 22:51:55 +0100 Subject: Add 'get_ui()' method for convenience --- portato/gui/windows/basic.py | 15 ++++++++++++++- portato/gui/windows/main.py | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index d7c7940..a4f8236 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -23,7 +23,7 @@ from ...constants import TEMPLATE_DIR, APP, LOCALE_DIR from ...helper import error class WrappedTree (object): - __slots__ = ("klass", "tree", "get_widget") + __slots__ = ("klass", "tree", "get_widget", "get_ui") def __init__ (self, klass, tree): self.tree = tree self.klass = klass @@ -40,6 +40,19 @@ class WrappedTree (object): error("Widget '%s' could not be found in class '%s'.", name, self.klass) return w + def get_ui (self, name, ui = "uimanager"): + uiw = self.get_widget(ui) + if uiw is None: + return None + + if not name.startswith("ui/"): + name = "ui/%s" % name + + w = uiw.get_widget(name) + if w is None: + error("UIItem '%s' of UIManager '%s' could not be found in class '%s'.", name, ui, self.klass) + return w + class UIBuilder (object): def __init__ (self, connector = None): diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index eb4f7b3..437d305 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -479,8 +479,8 @@ class MainWindow (Window): plugin.load_plugins() menus = [p.menus for p in plugin.get_plugin_queue().get_plugins()] - #if menus: - # pluginMenu = self.tree.get_widget("pluginMenu") + # if menus: + # pluginMenu = self.tree.get_ui("pluginMenu") # for m in itt.chain(*menus): # item = gtk.MenuItem(m.label) @@ -552,8 +552,8 @@ class MainWindow (Window): self.packageTable = PackageTable(self) # popups - self.consolePopup = self.tree.get_widget("uimanager").get_widget("ui/consolePopup") - self.trayPopup = self.tree.get_widget("uimanager").get_widget("ui/systrayPopup") + self.consolePopup = self.tree.get_ui("consolePopup") + self.trayPopup = self.tree.get_ui("systrayPopup") # pause menu items self.emergePaused = False -- cgit v1.2.3