From afa1de13f0576ace6dcbb0176490fd20922950cd Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Tue, 2 Sep 2008 13:01:17 +0200 Subject: Switch from tabs to 4 spaces --- portato/gui/windows/basic.py | 180 +++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 90 deletions(-) (limited to 'portato/gui/windows/basic.py') diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py index 09d0d7e..6d74858 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -27,101 +27,101 @@ 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 + __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): - - if not hasattr(self, "__tree__"): - self.__tree__ = self.__class__.__name__ - - if not hasattr(self, "__window__"): - self.__window__ = self.__class__.__name__ - - if not hasattr(self, "__file__"): - self.__file__ = self.__class__.__name__ - - self.tree = self.get_tree(self.__tree__) - self.tree.signal_autoconnect(self) - self.window = self.tree.get_widget(self.__window__) - self.window.set_icon_from_file(APP_ICON) - - @staticmethod - def watch_cursor (func): - """This is a decorator for functions being so time consuming, that it is appropriate to show the watch-cursor. - @attention: this function relies on the gtk.Window-Object being stored as self.window""" - - @wraps(func) - def wrapper (self, *args, **kwargs): - ret = None - def cb_idle(): - try: - ret = func(self, *args, **kwargs) - finally: - self.window.window.set_cursor(None) - return False - - watch = gtk.gdk.Cursor(gtk.gdk.WATCH) - self.window.window.set_cursor(watch) - gobject.idle_add(cb_idle) - return ret - - return wrapper - - def get_tree (self, name): - return WrappedTree(self.__class__.__name__, gtk.glade.XML(os.path.join(TEMPLATE_DIR, self.__file__+".glade"), name)) + def __init__ (self): + + if not hasattr(self, "__tree__"): + self.__tree__ = self.__class__.__name__ + + if not hasattr(self, "__window__"): + self.__window__ = self.__class__.__name__ + + if not hasattr(self, "__file__"): + self.__file__ = self.__class__.__name__ + + self.tree = self.get_tree(self.__tree__) + self.tree.signal_autoconnect(self) + self.window = self.tree.get_widget(self.__window__) + self.window.set_icon_from_file(APP_ICON) + + @staticmethod + def watch_cursor (func): + """This is a decorator for functions being so time consuming, that it is appropriate to show the watch-cursor. + @attention: this function relies on the gtk.Window-Object being stored as self.window""" + + @wraps(func) + def wrapper (self, *args, **kwargs): + ret = None + def cb_idle(): + try: + ret = func(self, *args, **kwargs) + finally: + self.window.window.set_cursor(None) + return False + + watch = gtk.gdk.Cursor(gtk.gdk.WATCH) + self.window.window.set_cursor(watch) + gobject.idle_add(cb_idle) + return ret + + return wrapper + + def get_tree (self, 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.""" - - def __init__ (self, parent): - """Constructor. - - @param parent: the parent window - @type parent: gtk.Window""" - - Window.__init__(self) - - # set parent - self.window.set_transient_for(parent) - self.parent = parent - - # catch the ESC-key - self.window.connect("key-press-event", self.cb_key_pressed) - - def cb_key_pressed (self, widget, event): - """Closes the window if ESC is pressed.""" - keyname = gtk.gdk.keyval_name(event.keyval) - if keyname == "Escape": - self.close() - return True - else: - return False - - def close (self, *args): - self.window.destroy() + """A class all our dialogs get derived from. It sets useful default vars and automatically handles the ESC-Button.""" + + def __init__ (self, parent): + """Constructor. + + @param parent: the parent window + @type parent: gtk.Window""" + + Window.__init__(self) + + # set parent + self.window.set_transient_for(parent) + self.parent = parent + + # catch the ESC-key + self.window.connect("key-press-event", self.cb_key_pressed) + + def cb_key_pressed (self, widget, event): + """Closes the window if ESC is pressed.""" + keyname = gtk.gdk.keyval_name(event.keyval) + if keyname == "Escape": + self.close() + return True + else: + return False + + def close (self, *args): + self.window.destroy() class Popup (object): - def __init__ (self, name, parent, file = "popups"): - self.tree = gtk.glade.XML(os.path.join(TEMPLATE_DIR, file+".glade"), root = name) - self.tree.signal_autoconnect(parent) - self._popup = self.tree.get_widget(name) + def __init__ (self, name, parent, file = "popups"): + self.tree = gtk.glade.XML(os.path.join(TEMPLATE_DIR, file+".glade"), root = name) + self.tree.signal_autoconnect(parent) + self._popup = self.tree.get_widget(name) - def popup (self, *args): - self._popup.popup(*args) + def popup (self, *args): + self._popup.popup(*args) -- cgit v1.2.3-70-g09d2 td>2012-09-19Since we're using batch mode, we can read directly.Jason A. Donenfeld1-1/+1 2012-09-19Clean up git handling.Jason A. Donenfeld2-42/+28 Get rid of push/pull shortcuts, as they weren't widely used. Add contents to repo on git init. Centralize git add logic, and make it less error prone. 2012-09-19Fix git regression.Jason A. Donenfeld1-1/+1 2012-09-18Add additional information from KeepassX xmlJuhamatti Niemelä1-3/+15 Import passwords as multiline entries with password in the first line. Rest contains following data if they exist in the entry element of the xml file: - username - url - comment 2012-09-18Copyright and licensing info to keepassx2pass scriptJuhamatti Niemelä1-0/+4 2012-09-18Quote the template.Jason A. Donenfeld1-1/+1 2012-09-18Better dependency list.Jason A. Donenfeld1-1/+10 2012-09-18Make recursive make silent.Jason A. Donenfeld1-1/+1 2012-09-18Quote the program name.Jason A. Donenfeld1-4/+4 2012-09-17Abstract potentially platform specific commands into their own commands.Jason A. Donenfeld4-72/+97 2012-09-16Support recursive and forced removal.Jason A. Donenfeld2-12/+28 Laurent asked for this. Reported-by: Laurent Ghigonis <laurent@p1sec.com> 2012-09-16Small stylistic things.Jason A. Donenfeld1-9/+9 Reported-by: Laurent Ghigonis <laurent@p1sec.com> 2012-09-15Use --force flag in keepassx import.Jason A. Donenfeld1-1/+1