[Inteproxy-commits] r76 - in trunk: . inteproxy
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed May 2 15:27:24 CEST 2007
Author: bh
Date: 2007-05-02 15:27:23 +0200 (Wed, 02 May 2007)
New Revision: 76
Modified:
trunk/ChangeLog
trunk/inteproxy/gtkapp.py
Log:
* inteproxy/gtkapp.py (StatusIcon.__init__)
(InteProxyApplication.__init__): Move the logic that makes the
status icon optional from InteProxyApplication to the StatusIcon,
making InteProxyApplication a little simpler.
(InteProxyApplication.__init__): Wait until the StatusIcon is
actually shown before deciding whether to remove menu items and
show the main window immediately.
(StatusIcon.is_embedded, InteProxyApplication.hide_main_window):
Adapt to the changed logic.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-05-02 13:06:01 UTC (rev 75)
+++ trunk/ChangeLog 2007-05-02 13:27:23 UTC (rev 76)
@@ -1,5 +1,17 @@
2007-05-02 Bernhard Herzog <bh at intevation.de>
+ * inteproxy/gtkapp.py (StatusIcon.__init__)
+ (InteProxyApplication.__init__): Move the logic that makes the
+ status icon optional from InteProxyApplication to the StatusIcon,
+ making InteProxyApplication a little simpler.
+ (InteProxyApplication.__init__): Wait until the StatusIcon is
+ actually shown before deciding whether to remove menu items and
+ show the main window immediately.
+ (StatusIcon.is_embedded, InteProxyApplication.hide_main_window):
+ Adapt to the changed logic.
+
+2007-05-02 Bernhard Herzog <bh at intevation.de>
+
* inteproxy/gtkapp.py (InteProxyApplication.__init__): If no
status icon is shown hide the File/Close menu item because it
would hide the window, leaving the user without a way to quit
Modified: trunk/inteproxy/gtkapp.py
===================================================================
--- trunk/inteproxy/gtkapp.py 2007-05-02 13:06:01 UTC (rev 75)
+++ trunk/inteproxy/gtkapp.py 2007-05-02 13:27:23 UTC (rev 76)
@@ -164,6 +164,12 @@
The StatusIcon is a small icon in the system tray. The user can
interact with that icon by clicking on it to show the main window or
to popup a menu with the most important commands.
+
+ There is no guarantee that the icon will actually show up on the
+ user's desktop because there either isn't a system tray at all or
+ because the GTK+ version used doesn't support status icons yet.
+ Whether the icon is visible can be determined with the is_embedded
+ method.
"""
def __init__(self, application):
@@ -171,14 +177,17 @@
"""
self.application = application
- iconfile = image_filename("InteProxy-icon.png")
- self.status_icon = gtk.status_icon_new_from_file(iconfile)
- self.status_icon.set_tooltip("InteProxy")
- self.status_icon.connect("activate", self.show_window)
- self.status_icon.connect("popup-menu", self.popup_menu)
+ constructor = getattr(gtk, "status_icon_new_from_file", None)
+ if constructor is not None:
+ self.status_icon = constructor(image_filename("InteProxy-icon.png"))
+ self.status_icon.set_tooltip("InteProxy")
+ self.status_icon.connect("activate", self.show_window)
+ self.status_icon.connect("popup-menu", self.popup_menu)
+ else:
+ self.status_icon = None
def is_embedded(self):
- return self.status_icon.is_embedded()
+ return self.status_icon is not None and self.status_icon.is_embedded()
def popup_menu(self, status_icon, button, activate_time):
"""Pops up the StatusIconMenu.
@@ -291,13 +300,17 @@
super(InteProxyApplication, self).__init__(server)
self.create_ui()
- if hasattr(gtk, "StatusIcon"):
- self.status_icon = StatusIcon(self)
- else:
- self.status_icon = None
+ self.status_icon = StatusIcon(self)
self.main_window = InteProxyMainWindow(self)
- if not self.status_icon or not self.status_icon.is_embedded():
+ # process some events to give the status icon a chance to appear
+ # in the status bar. Without this, the StatusIcon.is_embedded()
+ # method will return False now even if the Status icon will
+ # actually appear.
+ while gtk.events_pending():
+ gtk.main_iteration_do()
+
+ if not self.status_icon.is_embedded():
# No status icon is shown, so:
# - hide the File/Close menu item because it would hide the
# window, leaving the user without a way to quit InteProxy.
@@ -346,7 +359,7 @@
def hide_main_window(self, *args):
"""Hides the main window if a status icon is shown other wise quits"""
- if self.status_icon:
+ if self.status_icon.is_embedded():
self.main_window.hide()
else:
self.quit()
More information about the Inteproxy-commits
mailing list