From 5214c805634169499365c9a096e1bf0519deaa28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 6 Sep 2009 01:34:45 +0200 Subject: Automatic loading of the external menu --- portato/gui/templates/MainWindow.ui | 12 +++++++++++- portato/gui/windows/basic.py | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'portato') diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui index f971d47..0455cfe 100644 --- a/portato/gui/templates/MainWindow.ui +++ b/portato/gui/templates/MainWindow.ui @@ -13,7 +13,17 @@ True vertical - + + True + vertical + + + + + + False + 0 + diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index e7f48a6..cab2fb9 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -77,10 +77,24 @@ class UIBuilder (object): if not hasattr(self, "__file__"): self.__file__ = self.__class__.__name__ + # general setup self._builder = gtk.Builder() self._builder.add_from_file(os.path.join(TEMPLATE_DIR, self.__file__+".ui")) self._builder.set_translation_domain(APP) + + self.tree = WrappedTree(self.__class__.__name__, self._builder) + # load menu if existing + menufile = os.path.join(TEMPLATE_DIR, self.__file__+".menu") + if os.path.exists(menufile): + debug("Menufile for '%s' exists.", self.__file__) + barbox = self.tree.get_widget("menubar_box") + if barbox is not None: + self._builder.add_from_file(menufile) + bar = self.tree.get_ui("menubar") + barbox.pack_start(bar, expand = False, fill = False) + + # signal connections if connector is None: connector = self unconnected = self._builder.connect_signals(connector) @@ -89,8 +103,6 @@ class UIBuilder (object): for uc in set(unconnected): error("Signal '%s' not connected in class '%s'.", uc, self.__class__.__name__) - self.tree = WrappedTree(self.__class__.__name__, self._builder) - class Window (UIBuilder): def __init__ (self): -- cgit v1.2.3