From 8cd4af873211a4c0974895ad30d2e2504686c940 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 13 Jan 2009 00:03:09 +0000 Subject: [PATCH] Added support to select which button displays by the changing of the buttonlist variable in the config file. Full list of valid buttons can be found at the top of cb-openbox-logout.py --- cb-openbox-logout.py | 37 ++++++++++++++++++++---- img/default/{reboot.png => restart.png} | Bin openbox-logout.conf | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) rename img/default/{reboot.png => restart.png} (100%) diff --git a/cb-openbox-logout.py b/cb-openbox-logout.py index 77480ef..a52e6a4 100755 --- a/cb-openbox-logout.py +++ b/cb-openbox-logout.py @@ -7,10 +7,13 @@ import StringIO import logging import cairo import gettext +import string class OpenboxLogout(): def __init__(self, config=None): + self.validbuttons = ['cancel', 'logout', 'restart', 'shutdown'] + self.load_config(config) gettext.install('cb-openbox-logout', 'po', unicode=1) @@ -41,7 +44,6 @@ class OpenboxLogout(): # Create the main panel box self.mainpanel = gtk.HBox() - self.mainpanel.size = 3 # Create the button box self.buttonpanel = gtk.HButtonBox() @@ -54,11 +56,19 @@ class OpenboxLogout(): # Add the main panel to the window self.window.add(self.mainpanel) + + if self.button_list: + list = map(lambda button: string.strip(button), self.button_list.split(",")) + for button in list: + self.add_button(button, self.buttonpanel) + else: + for button in self.validbuttons: + self.add_button(button, self.buttonpanel) - self.add_button("cancel", self.buttonpanel) - self.add_button("logout", self.buttonpanel) - self.add_button("reboot", self.buttonpanel) - self.add_button("shutdown", self.buttonpanel) + #self.add_button("cancel", self.buttonpanel) + #self.add_button("logout", self.buttonpanel) + #self.add_button("reboot", self.buttonpanel) + #self.add_button("shutdown", self.buttonpanel) if self.rendered_effects == True: @@ -117,6 +127,7 @@ class OpenboxLogout(): self.blur_background = self.parser.getboolean("looks", "blur") self.opacity = self.parser.getint("looks", "opacity") self.button_theme = self.parser.get("looks", "buttontheme") + self.button_list = self.parser.get("looks", "buttonlist") # Validate configuration if not os.path.exists('img/%s/' % self.button_theme): @@ -128,7 +139,21 @@ class OpenboxLogout(): except ValueError: logging.warning("Color %s is not a valid color, defaulting to black" % self.parser.get("looks", "bgcolor")) self.bgcolor = gtk.gdk.Color("black") + + if self.button_list: + + if self.button_list == "default": + self.button_list = string.join(self.validbuttons,",") + list = map(lambda button: string.strip(button), self.button_list.split(",")) + logging.debug("Button list: %s" % list) + for button in list: + if not button in self.validbuttons: + logging.warning("Button %s is not a valid button name, resetting to defaults" % button) + self.button_list = None + break + + def on_expose(self, widget, event): cr = widget.window.cairo_create() @@ -202,7 +227,7 @@ class OpenboxLogout(): self.quit() elif (data=='logout'): os.system('openbox --exit') - elif (data=='reboot'): + elif (data=='restart'): os.system('gdm-control --reboot && openbox --exit') elif (data=='shutdown'): os.system('gdm-control --shutdown && openbox --exit') diff --git a/img/default/reboot.png b/img/default/restart.png similarity index 100% rename from img/default/reboot.png rename to img/default/restart.png diff --git a/openbox-logout.conf b/openbox-logout.conf index 0807a1b..0b539c5 100644 --- a/openbox-logout.conf +++ b/openbox-logout.conf @@ -1,6 +1,7 @@ [looks] blur = False buttontheme = default +buttonlist = default opacity = 50 bgcolor = black