summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-07-28 22:00:22 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-07-28 22:00:22 +0200
commitea1b27e48a607324270b90f9c54e032fe349100d (patch)
treeec86210fd7e2f166264381ec245b96d9c54e9f9b /portato
parentcb6fc48a43c3e9d0e86292f233a3600aebd93f68 (diff)
downloadportato-ea1b27e48a607324270b90f9c54e032fe349100d.tar.gz
portato-ea1b27e48a607324270b90f9c54e032fe349100d.tar.bz2
portato-ea1b27e48a607324270b90f9c54e032fe349100d.zip
Added one level of indirection to find wrong calls of 'get_widget'
Diffstat (limited to 'portato')
-rw-r--r--portato/gui/windows/basic.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py
index 101b7ae..09d0d7e 100644
--- a/portato/gui/windows/basic.py
+++ b/portato/gui/windows/basic.py
@@ -21,10 +21,29 @@ from functools import wraps
import os.path
from ...constants import TEMPLATE_DIR, APP_ICON, APP, LOCALE_DIR
+from ...helper import error
gtk.glade.bindtextdomain (APP, LOCALE_DIR)
gtk.glade.textdomain (APP)
+class WrappedTree (object):
+ __slots__ = ("klass", "tree", "get_widget")
+ def __init__ (self, klass, tree):
+ self.tree = tree
+ self.klass = klass
+
+ def __getattribute__ (self, name):
+ if name in WrappedTree.__slots__:
+ return object.__getattribute__(self, name)
+ else:
+ return getattr(self.tree, name)
+
+ def get_widget(self, name):
+ w = self.tree.get_widget(name)
+ if w is None:
+ error("Widget '%s' could not be found in class '%s'.", name, self.klass)
+ return w
+
class Window (object):
def __init__ (self):
@@ -65,7 +84,7 @@ class Window (object):
return wrapper
def get_tree (self, name):
- return gtk.glade.XML(os.path.join(TEMPLATE_DIR, self.__file__+".glade"), name)
+ return WrappedTree(self.__class__.__name__, gtk.glade.XML(os.path.join(TEMPLATE_DIR, self.__file__+".glade"), name))
class AbstractDialog (Window):
"""A class all our dialogs get derived from. It sets useful default vars and automatically handles the ESC-Button."""