Browse files

gnomeapplet is no longer necessary to run in dzen mode or change pref…

…erences
  • Loading branch information...
1 parent b87b9a9 commit 7af4a368089a3afe2d59f276e987c2b39ad844ca @teleshoes committed Jan 9, 2012
Showing with 17 additions and 8 deletions.
  1. +6 −2 src/gui.py
  2. +11 −6 src/tpbattstat.py
View
8 src/gui.py
@@ -53,13 +53,13 @@ def __init__(self, applet, prefs, battStatus):
self.create_menu()
self.gconfGui = None
- self.applet.connect("change-orient", self.resetLayout)
+ if gnomeappletOk:
+ self.applet.connect("change-orient", self.resetLayout)
def getGtkWidget(self):
return self.container
def resetLayout(self):
if self.box != None:
self.container.remove(self.box)
- orient = self.applet.get_orient()
if self.isVertical():
self.box = gtk.VBox()
@@ -73,6 +73,8 @@ def resetLayout(self):
self.container.add(self.box)
self.container.show_all()
def create_menu(self):
+ if not gnomeappletOk:
+ return
xml="""<popup name="button3">
<menuitem name="Preferences" verb="Preferences" label="_Preferences"
pixtype="stock" pixname="gtk-preferences"/>
@@ -175,6 +177,8 @@ def getSeparatorMarkup(self):
else:
return sep
def isVertical(self):
+ if not gnomeappletOk:
+ return False
orient = self.applet.get_orient()
return not (orient == gnomeapplet.ORIENT_UP or
orient == gnomeapplet.ORIENT_DOWN)
View
17 src/tpbattstat.py
@@ -53,10 +53,11 @@ def __init__(self, applet, mode="gtk", forceDelay=None):
self.actions = Actions(self.prefs, self.battStatus)
if self.mode == "gtk":
self.gui = Gui(self.applet, self.prefs, self.battStatus)
- self.applet.add_preferences(SCHEMA_DIR)
- self.applet.add(self.gui.getGtkWidget())
- self.applet.set_background_widget(self.applet)
- self.applet.show_all()
+ if gnomeappletOk:
+ self.applet.add_preferences(SCHEMA_DIR)
+ self.applet.add(self.gui.getGtkWidget())
+ self.applet.set_background_widget(self.applet)
+ self.applet.show_all()
elif self.mode == "dzen":
self.dzenprinter = DzenPrinter(self.prefs, self.battStatus)
@@ -115,11 +116,15 @@ def main():
print " " + sys.argv[0] + " [-p | --prefs | prefs]"
elif arg == "-w" or arg == "--window" or arg == "window":
- applet = gnomeapplet.Applet()
+ if gnomeappletOk:
+ applet = gnomeapplet.Applet()
+ else:
+ applet = None
TPBattStatAppletFactory(applet, None)
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("TPBattStatApplet")
- applet.reparent(window)
+ if gnomeappletOk:
+ applet.reparent(window)
showAndExit(window)
elif arg == "-p" or arg == "--prefs" or arg == "prefs":

0 comments on commit 7af4a36

Please sign in to comment.