From bb49ab41953659e7ca3b37b55dc419e61d6d2b17 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sat, 14 Feb 2009 09:45:00 +0000 Subject: [PATCH] Reorganise theme loading to work correctly, fixes LP #324130 --- oblogout-dev.sh | 2 +- oblogout/oblogout.py | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/oblogout-dev.sh b/oblogout-dev.sh index a698fc9..5ec6f54 100755 --- a/oblogout-dev.sh +++ b/oblogout-dev.sh @@ -1,3 +1,3 @@ #!/bin/sh OBLOGOUT_PATH=`dirname $0` -PYTHONPATH="$PYTHONPATH:$OBLOGOUT_PATH" python $OBLOGOUT_PATH/data/oblogout -l $* +PYTHONPATH="$PYTHONPATH:$OBLOGOUT_PATH" python $OBLOGOUT_PATH/data/oblogout -l -v $* diff --git a/oblogout/oblogout.py b/oblogout/oblogout.py index 1bf207f..b1d16f9 100644 --- a/oblogout/oblogout.py +++ b/oblogout/oblogout.py @@ -180,11 +180,6 @@ class OpenboxLogout(): def load_config(self, config): """ Load the configuration file and parse entries, when encountering a issue change safe defaults """ - - if self.local_mode: - self.img_path = "data/themes" - else: - self.img_path = "%s/share/themes" % sys.prefix self.parser = ConfigParser.SafeConfigParser() self.parser.read(config) @@ -217,13 +212,21 @@ class OpenboxLogout(): if self.parser.has_section("shortcuts"): self.shortcut_keys = self.parser.items("shortcuts") self.logger.debug("Shortcut Options: %s" % self.shortcut_keys) - + + + if self.local_mode: + self.theme_prefix = "./data/themes" + else: + self.theme_prefix = "%s/share/themes" % sys.prefix + + self.img_path = "%s/%s/oblogout" % (self.theme_prefix, self.button_theme) + if os.path.exists("%s/.themes/%s/oblogout" % (os.environ['HOME'], self.button_theme)): # Found a valid theme folder in the userdir, use that self.img_path = "%s/.themes/%s/oblogout" % (os.environ['HOME'], self.button_theme) self.logger.info("Using user theme at %s" % self.img_path) else: - if not os.path.exists('%s/%s/oblogout/' % (self.img_path, self.button_theme)): + if not os.path.exists("%s/%s/oblogout" % (self.theme_prefix, self.button_theme)): self.logger.warning("Button theme %s not found, reverting to default" % self.button_theme) self.button_theme = 'foom' @@ -315,10 +318,10 @@ class OpenboxLogout(): box = gtk.VBox() image = gtk.Image() - if os.path.exists("%s/%s/oblogout/%s.svg" % (self.img_path, self.button_theme, name)): - image.set_from_file("%s/%s/oblogout/%s.svg" % (self.img_path, self.button_theme, name)) + if os.path.exists("%s/%s.svg" % (self.img_path, name)): + image.set_from_file("%s/%s.svg" % (self.img_path, name)) else: - image.set_from_file("%s/%s/oblogout/%s.png" % (self.img_path, self.button_theme, name)) + image.set_from_file("%s/%s.png" % (self.img_path, name)) image.show() button = gtk.Button()