diff --git a/.bzrignore b/.bzrignore index bc9ceb7..a115f03 100644 --- a/.bzrignore +++ b/.bzrignore @@ -6,3 +6,4 @@ debian/oblogout debian/*.log debian/oblogout.* debian/files +python-build-stamp-2.5 diff --git a/oblogout b/data/oblogout similarity index 83% rename from oblogout rename to data/oblogout index 73068eb..8bcb580 100755 --- a/oblogout +++ b/data/oblogout @@ -28,7 +28,7 @@ import sys import getopt import logging import logging.handlers -from openboxlogout import openboxlogout +from oblogout import oblogout class Usage(Exception): def __init__(self, msg): @@ -37,19 +37,21 @@ class Usage(Exception): def main(argv = None): # Start logger instace used by the OpenboxLogout class - logger = logging.getLogger('OpenboxLogout') + logger = logging.getLogger('oblogout') logout = logging.StreamHandler(sys.stdout) logout.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")) logger.addHandler(logout) verbose = None config = None + local_mode = None + if argv is None: argv = sys.argv try: try: - opts, args = getopt.getopt(argv[1:], "hvc:", ["help", "verbose", "config="]) + opts, args = getopt.getopt(argv[1:], "hvc:l", ["help", "verbose", "config=", "local"]) except getopt.error, msg: raise Usage(msg) # more code, unchanged @@ -66,10 +68,15 @@ def main(argv = None): verbose = True elif o in ("-c", "--config"): config = a + elif o in ("-l", "--local"): + local_mode = True if not config: - config = '/etc/openbox-logout.conf' - + if not local_mode: + config = '/etc/oblogout.conf' + else: + config = 'data/oblogout.conf' + # Check config in local path, if it exists pass it on if not os.path.exists(config): logger.error("Invalid config file: %s" % config) @@ -82,7 +89,7 @@ def main(argv = None): logger.setLevel(logging.INFO) # Start the application - app = openboxlogout.OpenboxLogout(config) + app = oblogout.OpenboxLogout(config, local_mode) app.run_logout() return 0 diff --git a/openbox-logout.conf b/data/oblogout.conf similarity index 100% rename from openbox-logout.conf rename to data/oblogout.conf diff --git a/openboxlogout/themes/foom/oblog_icons.7z b/data/themes/foom/oblog_icons.7z similarity index 100% rename from openboxlogout/themes/foom/oblog_icons.7z rename to data/themes/foom/oblog_icons.7z diff --git a/openboxlogout/themes/foom/cancel.png b/data/themes/foom/oblogout/cancel.png similarity index 100% rename from openboxlogout/themes/foom/cancel.png rename to data/themes/foom/oblogout/cancel.png diff --git a/openboxlogout/themes/foom/hibernate.png b/data/themes/foom/oblogout/hibernate.png similarity index 100% rename from openboxlogout/themes/foom/hibernate.png rename to data/themes/foom/oblogout/hibernate.png diff --git a/openboxlogout/themes/foom/lock.png b/data/themes/foom/oblogout/lock.png similarity index 100% rename from openboxlogout/themes/foom/lock.png rename to data/themes/foom/oblogout/lock.png diff --git a/openboxlogout/themes/foom/logout.png b/data/themes/foom/oblogout/logout.png similarity index 100% rename from openboxlogout/themes/foom/logout.png rename to data/themes/foom/oblogout/logout.png diff --git a/openboxlogout/themes/foom/restart.png b/data/themes/foom/oblogout/restart.png similarity index 100% rename from openboxlogout/themes/foom/restart.png rename to data/themes/foom/oblogout/restart.png diff --git a/openboxlogout/themes/foom/shutdown.png b/data/themes/foom/oblogout/shutdown.png similarity index 100% rename from openboxlogout/themes/foom/shutdown.png rename to data/themes/foom/oblogout/shutdown.png diff --git a/openboxlogout/themes/foom/suspend.png b/data/themes/foom/oblogout/suspend.png similarity index 100% rename from openboxlogout/themes/foom/suspend.png rename to data/themes/foom/oblogout/suspend.png diff --git a/openboxlogout/themes/foom/switch.png b/data/themes/foom/oblogout/switch.png similarity index 100% rename from openboxlogout/themes/foom/switch.png rename to data/themes/foom/oblogout/switch.png diff --git a/openboxlogout/themes/oxygen/cancel.png b/data/themes/oxygen/oblogout/cancel.png similarity index 100% rename from openboxlogout/themes/oxygen/cancel.png rename to data/themes/oxygen/oblogout/cancel.png diff --git a/openboxlogout/themes/oxygen/hibernate.png b/data/themes/oxygen/oblogout/hibernate.png similarity index 100% rename from openboxlogout/themes/oxygen/hibernate.png rename to data/themes/oxygen/oblogout/hibernate.png diff --git a/openboxlogout/themes/oxygen/lock.png b/data/themes/oxygen/oblogout/lock.png similarity index 100% rename from openboxlogout/themes/oxygen/lock.png rename to data/themes/oxygen/oblogout/lock.png diff --git a/openboxlogout/themes/oxygen/logout.png b/data/themes/oxygen/oblogout/logout.png similarity index 100% rename from openboxlogout/themes/oxygen/logout.png rename to data/themes/oxygen/oblogout/logout.png diff --git a/openboxlogout/themes/default/restart.png b/data/themes/oxygen/oblogout/restart.png old mode 100755 new mode 100644 similarity index 100% rename from openboxlogout/themes/default/restart.png rename to data/themes/oxygen/oblogout/restart.png diff --git a/openboxlogout/themes/oxygen/safesuspend.png b/data/themes/oxygen/oblogout/safesuspend.png similarity index 100% rename from openboxlogout/themes/oxygen/safesuspend.png rename to data/themes/oxygen/oblogout/safesuspend.png diff --git a/openboxlogout/themes/default/shutdown.png b/data/themes/oxygen/oblogout/shutdown.png old mode 100755 new mode 100644 similarity index 100% rename from openboxlogout/themes/default/shutdown.png rename to data/themes/oxygen/oblogout/shutdown.png diff --git a/openboxlogout/themes/oxygen/suspend.png b/data/themes/oxygen/oblogout/suspend.png similarity index 100% rename from openboxlogout/themes/oxygen/suspend.png rename to data/themes/oxygen/oblogout/suspend.png diff --git a/openboxlogout/themes/oxygen/switch.png b/data/themes/oxygen/oblogout/switch.png similarity index 100% rename from openboxlogout/themes/oxygen/switch.png rename to data/themes/oxygen/oblogout/switch.png diff --git a/debian/control b/debian/control index 57966f2..ff124a4 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: oblogout Section: misc Priority: extra Maintainer: Andrew Williams -Build-Depends: cdbs, debhelper (>= 7), python-central (>= 0.5.6) +Build-Depends: cdbs, debhelper (>= 7), python-central (>= 0.5.6), python-distutils-extra XS-Python-Version: >= 2.5 Standards-Version: 3.7.3 Homepage: http://launchpad.net/oblogout/ diff --git a/oblogout-dev.sh b/oblogout-dev.sh new file mode 100755 index 0000000..a698fc9 --- /dev/null +++ b/oblogout-dev.sh @@ -0,0 +1,3 @@ +#!/bin/sh +OBLOGOUT_PATH=`dirname $0` +PYTHONPATH="$PYTHONPATH:$OBLOGOUT_PATH" python $OBLOGOUT_PATH/data/oblogout -l $* diff --git a/openboxlogout/__init__.py b/oblogout/__init__.py similarity index 100% rename from openboxlogout/__init__.py rename to oblogout/__init__.py diff --git a/openboxlogout/openboxlogout.py b/oblogout/oblogout.py similarity index 94% rename from openboxlogout/openboxlogout.py rename to oblogout/oblogout.py index 4e77978..773ab5a 100644 --- a/openboxlogout/openboxlogout.py +++ b/oblogout/oblogout.py @@ -56,11 +56,20 @@ except: sys.exit() class OpenboxLogout(): - def __init__(self, config=None): + def __init__(self, config=None, local=None): + + if local: + self.local_mode = True + else: + self.local_mode = False # Start logger and gettext/i18n - self.logger = logging.getLogger('OpenboxLogout') - gettext.install('oblogout', '%s/locale' % self.determine_path(), unicode=1) + self.logger = logging.getLogger('oblogout') + + if self.local_mode: + gettext.install('oblogout', 'mo', unicode=1) + else: + gettext.install('oblogout', '%s/share/locale' % sys.prefix, unicode=1) # Start dbus interface bus = dbus.SystemBus() @@ -151,9 +160,7 @@ class OpenboxLogout(): self.window.set_app_paintable(True) self.window.resize(gtk.gdk.screen_width(), gtk.gdk.screen_height()) self.window.realize() - - print self.buttonpanel.get_allocation().width - + if pixmap: self.window.window.set_back_pixmap(pixmap, False) self.window.move(0,0) @@ -174,7 +181,10 @@ class OpenboxLogout(): """ Load the configuration file and parse entries, when encountering a issue change safe defaults """ - self.img_path = "%s/themes" % self.determine_path() + 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) @@ -213,9 +223,9 @@ class OpenboxLogout(): 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/' % (self.img_path, self.button_theme)): + if not os.path.exists('%s/%s/oblogout/' % (self.img_path, self.button_theme)): self.logger.warning("Button theme %s not found, reverting to default" % self.button_theme) - self.button_theme = 'default' + self.button_theme = 'foom' # Load and parse button list @@ -305,7 +315,7 @@ class OpenboxLogout(): box = gtk.VBox() image = gtk.Image() - image.set_from_file("%s/%s/%s.png" % (self.img_path, self.button_theme, name)) + image.set_from_file("%s/%s/oblogout/%s.png" % (self.img_path, self.button_theme, name)) image.show() button = gtk.Button() diff --git a/openboxlogout/app.fil b/openboxlogout/app.fil deleted file mode 100644 index 6836aa5..0000000 --- a/openboxlogout/app.fil +++ /dev/null @@ -1 +0,0 @@ -openboxlogout.py diff --git a/openboxlogout/locale/de/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/de/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 64ad92b..0000000 Binary files a/openboxlogout/locale/de/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/en/LC_MESSAGES/openboxlogout.mo b/openboxlogout/locale/en/LC_MESSAGES/openboxlogout.mo deleted file mode 100644 index 635452c..0000000 Binary files a/openboxlogout/locale/en/LC_MESSAGES/openboxlogout.mo and /dev/null differ diff --git a/openboxlogout/locale/en_GB/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/en_GB/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 76f32a2..0000000 Binary files a/openboxlogout/locale/en_GB/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/fi/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/fi/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 33674ea..0000000 Binary files a/openboxlogout/locale/fi/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/fr/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/fr/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 428fe3b..0000000 Binary files a/openboxlogout/locale/fr/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/he/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/he/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 6f5281b..0000000 Binary files a/openboxlogout/locale/he/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/nb/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/nb/LC_MESSAGES/oblogout.mo deleted file mode 100644 index 0dfb87e..0000000 Binary files a/openboxlogout/locale/nb/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/locale/nn/LC_MESSAGES/oblogout.mo b/openboxlogout/locale/nn/LC_MESSAGES/oblogout.mo deleted file mode 100644 index b79926c..0000000 Binary files a/openboxlogout/locale/nn/LC_MESSAGES/oblogout.mo and /dev/null differ diff --git a/openboxlogout/themes/default/cancel.png b/openboxlogout/themes/default/cancel.png deleted file mode 100755 index a537b66..0000000 Binary files a/openboxlogout/themes/default/cancel.png and /dev/null differ diff --git a/openboxlogout/themes/default/logout.png b/openboxlogout/themes/default/logout.png deleted file mode 100755 index ccdd74a..0000000 Binary files a/openboxlogout/themes/default/logout.png and /dev/null differ diff --git a/openboxlogout/themes/oxygen/restart.png b/openboxlogout/themes/oxygen/restart.png deleted file mode 100644 index d84366b..0000000 Binary files a/openboxlogout/themes/oxygen/restart.png and /dev/null differ diff --git a/openboxlogout/themes/oxygen/shutdown.png b/openboxlogout/themes/oxygen/shutdown.png deleted file mode 100644 index 2196355..0000000 Binary files a/openboxlogout/themes/oxygen/shutdown.png and /dev/null differ diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..3902d4d --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,2 @@ +oblogout/oblogout.py +data/oblogout diff --git a/openboxlogout/pofiles/oblogout-de.po b/po/de.po similarity index 100% rename from openboxlogout/pofiles/oblogout-de.po rename to po/de.po diff --git a/openboxlogout/pofiles/oblogout-en_GB.po b/po/en_GB.po similarity index 100% rename from openboxlogout/pofiles/oblogout-en_GB.po rename to po/en_GB.po diff --git a/openboxlogout/pofiles/oblogout-fi.po b/po/fi.po similarity index 100% rename from openboxlogout/pofiles/oblogout-fi.po rename to po/fi.po diff --git a/openboxlogout/pofiles/oblogout-fr.po b/po/fr.po similarity index 100% rename from openboxlogout/pofiles/oblogout-fr.po rename to po/fr.po diff --git a/openboxlogout/pofiles/oblogout-he.po b/po/he.po similarity index 100% rename from openboxlogout/pofiles/oblogout-he.po rename to po/he.po diff --git a/openboxlogout/pofiles/oblogout-nb.po b/po/nb.po similarity index 100% rename from openboxlogout/pofiles/oblogout-nb.po rename to po/nb.po diff --git a/openboxlogout/pofiles/oblogout-nn.po b/po/nn.po similarity index 100% rename from openboxlogout/pofiles/oblogout-nn.po rename to po/nn.po diff --git a/openboxlogout/messages.pot b/po/oblogout.pot similarity index 68% rename from openboxlogout/messages.pot rename to po/oblogout.pot index 076fb48..847f614 100644 --- a/openboxlogout/messages.pot +++ b/po/oblogout.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-01-17 23:39+0000\n" +"POT-Creation-Date: 2009-01-28 18:30+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,77 +16,72 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: openboxlogout.py:209 -#, python-format -msgid "Button %s is not a valid button name, removing" +#: ../oblogout/oblogout.py:88 +msgid "Openbox Logout" msgstr "" -#: openboxlogout.py:218 -msgid "Can't Hibernate, disabling button" +#: ../oblogout/oblogout.py:178 +msgid "Unable to determin the module path, exiting..." msgstr "" -#: openboxlogout.py:222 -msgid "Can't Safe Suspend, disabling button" -msgstr "" - -#: openboxlogout.py:214 -msgid "Can't Suspend, disabling button" -msgstr "" - -#: openboxlogout.py:187 +#: ../oblogout/oblogout.py:213 #, python-format msgid "Color %s is not a valid color, defaulting to black" msgstr "" -#: openboxlogout.py:226 -msgid "No valid buttons found, resetting to defaults" -msgstr "" - -#: openboxlogout.py:54 -msgid "Openbox Logout" -msgstr "" - -#: openboxlogout.py:142 -msgid "Unable to determin the module path, exiting..." -msgstr "" - -#: openboxlogout.py:154 -#, python-format -msgid "Unable to find config file %s" -msgstr "" - -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 msgid "cancel" msgstr "" -#: openboxlogout.py:192 -msgid "hibernate" -msgstr "" - -#: openboxlogout.py:192 -msgid "lock" -msgstr "" - -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 msgid "logout" msgstr "" -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 msgid "restart" msgstr "" -#: openboxlogout.py:192 -msgid "safesuspend" -msgstr "" - -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 msgid "shutdown" msgstr "" -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 msgid "suspend" msgstr "" -#: openboxlogout.py:192 +#: ../oblogout/oblogout.py:235 +msgid "hibernate" +msgstr "" + +#: ../oblogout/oblogout.py:235 +msgid "safesuspend" +msgstr "" + +#: ../oblogout/oblogout.py:235 +msgid "lock" +msgstr "" + +#: ../oblogout/oblogout.py:235 msgid "switch" msgstr "" + +#: ../oblogout/oblogout.py:247 +#, python-format +msgid "Button %s is not a valid button name, removing" +msgstr "" + +#: ../oblogout/oblogout.py:252 +msgid "Can't Suspend, disabling button" +msgstr "" + +#: ../oblogout/oblogout.py:256 +msgid "Can't Hibernate, disabling button" +msgstr "" + +#: ../oblogout/oblogout.py:260 +msgid "Can't Safe Suspend, disabling button" +msgstr "" + +#: ../oblogout/oblogout.py:264 +msgid "No valid buttons found, resetting to defaults" +msgstr "" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..932d2ac --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[build] +icons=False +help=False + +[build_i18n] +po-dir=po + diff --git a/setup.py b/setup.py index d1c5fbc..73aebec 100755 --- a/setup.py +++ b/setup.py @@ -5,87 +5,25 @@ import os, sys, glob, fnmatch ## Added 10 Jan 2008 from distutils.core import setup, Extension import distutils.command.install_data - -## Code borrowed from wxPython's setup and config files -## Thanks to Robin Dunn for the suggestion. -## I am not 100% sure what's going on, but it works! -def opj(*args): - path = os.path.join(*args) - return os.path.normpath(path) - -## Added 10 Jan 2008 -# Specializations of some distutils command classes -class wx_smart_install_data(distutils.command.install_data.install_data): - """need to change self.install_dir to the actual library dir""" - def run(self): - install_cmd = self.get_finalized_command('install') - self.install_dir = getattr(install_cmd, 'install_lib') - return distutils.command.install_data.install_data.run(self) - -def find_data_files(srcdir, *wildcards, **kw): - # get a list of all files under the srcdir matching wildcards, - # returned in a format to be used for install_data - def walk_helper(arg, dirname, files): - if '.svn' in dirname: - return - names = [] - lst, wildcards = arg - for wc in wildcards: - wc_name = opj(dirname, wc) - for f in files: - filename = opj(dirname, f) - - if fnmatch.fnmatch(filename, wc_name) and not os.path.isdir(filename): - names.append(filename) - if names: - lst.append( (dirname, names ) ) - - file_list = [] - recursive = kw.get('recursive', True) - if recursive: - os.path.walk(srcdir, walk_helper, (file_list, wildcards)) - else: - walk_helper((file_list, wildcards), - srcdir, - [os.path.basename(f) for f in glob.glob(opj(srcdir, '*'))]) - return file_list - -## This is a list of files to install, and where: -## Make sure the MANIFEST.in file points to all the right -## directories too. -files = find_data_files('openboxlogout/', '*.*') - -# Extra entry for config file copied to /etc/ -files.append(('/etc/', ['openbox-logout.conf'])) - -print files - from distutils.core import setup +from DistUtilsExtra.command import * -setup(name = "openboxlogout", +setup(name = "oblogout", version = "0.2", description = "Openbox Logout", author = "Andrew Williams", author_email = "andy@tensixtyone.com", - url = "http://bzr.tensixtyone.com/", - #Name the folder where your packages live: - #(If you have other packages (dirs) or modules (py files) then - #put them into the package directory - they will be found - #recursively.) - packages = ['openboxlogout'], - - data_files = files, + url = "http://launchpad.net/oblogout/", - ## Borrowed from wxPython too: - ## Causes the data_files to be installed into the modules directory. - ## Override some of the default distutils command classes with my own. - cmdclass = { 'install_data': wx_smart_install_data }, + packages = ['oblogout'], + scripts = ["data/oblogout"], + data_files = [('share/themes/foom/oblogout', glob.glob('data/themes/foom/oblogout/*')), + ('share/themes/oxygen/oblogout', glob.glob('data/themes/oxygen/oblogout/*')), + ('/etc/', glob.glob('data/openbox-logout.conf'))], + + cmdclass = { 'build' : build_extra.build_extra, + 'build_i18n' : build_i18n.build_i18n }, - #'runner' is in the root. - scripts = ["oblogout"], - long_description = """Really long text here.""" - # - #This next part it for the Cheese Shop, look a little down the page. - #classifiers = [] + long_description = """Really long text here.""" ) diff --git a/tools/gen-mo.sh b/tools/gen-mo.sh deleted file mode 100755 index e8a2820..0000000 --- a/tools/gen-mo.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cd openboxlogout/ - -for file in ./pofiles/*.po; do - lang=`echo $file | cut -d "-" -f 2 - | cut -d "." -f 1` - - mkdir -p locale/$lang/LC_MESSAGES - msgfmt --output-file="locale/$lang/LC_MESSAGES/oblogout.mo" "$file" -done