summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2011-01-28 15:53:34 +0200
committerMarius Gedminas <marius@gedmin.as>2011-01-28 15:53:34 +0200
commitadf2089f9dfa0470e929dd4ef7c6c0f68f27f0aa (patch)
tree9184dd4688d650cfb2efd5571ac64f9daed10e59
parent268a7fb49bce09df5561629a0a0a43e5a672628b (diff)
Application Indicator menu now has a CheckMenuItem "Show GTimelog".
Previously it used the old tray icon menu with separate Show/Hide items.
-rw-r--r--src/gtimelog/gtimelog.ui10
-rwxr-xr-xsrc/gtimelog/main.py22
2 files changed, 31 insertions, 1 deletions
diff --git a/src/gtimelog/gtimelog.ui b/src/gtimelog/gtimelog.ui
index 4ff6496..62165d4 100644
--- a/src/gtimelog/gtimelog.ui
+++ b/src/gtimelog/gtimelog.ui
@@ -644,4 +644,14 @@ GTimeLog is a time tracking application.
</object>
</child>
</object>
+ <object class="GtkMenu" id="app_indicator_menu">
+ <child>
+ <object class="GtkCheckMenuItem" id="appind_show">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Show GTimeLog</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_toggle_visible"/>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/gtimelog/main.py b/src/gtimelog/main.py
index 26ae1b2..6561ca9 100755
--- a/src/gtimelog/main.py
+++ b/src/gtimelog/main.py
@@ -1083,7 +1083,7 @@ class AppIndicator(IconChooser):
self.indicator = appindicator.Indicator("gtimelog", self.icon_name,
appindicator.CATEGORY_APPLICATION_STATUS)
self.indicator.set_status(appindicator.STATUS_ACTIVE)
- self.indicator.set_menu(gtimelog_window.tray_icon_popup_menu)
+ self.indicator.set_menu(gtimelog_window.app_indicator_menu)
self.gtimelog_window.tray_icon = self
self.gtimelog_window.main_window.connect("style-set", self.on_style_set)
@@ -1154,6 +1154,8 @@ class OldTrayIcon(IconChooser):
if event.button != 3:
return
main_window = self.gtimelog_window.main_window
+ # This should be unnecessary, as we now show/hide menu items
+ # immediatelly after showing/hiding the main window
if main_window.get_property("visible"):
self.gtimelog_window.tray_show.hide()
self.gtimelog_window.tray_hide.show()
@@ -1238,6 +1240,8 @@ class MainWindow(object):
# Now hook up signals
builder.connect_signals(self)
# Store references to UI elements we're going to need later
+ self.app_indicator_menu = builder.get_object("app_indicator_menu")
+ self.appind_show = builder.get_object("appind_show")
self.tray_icon_popup_menu = builder.get_object("tray_icon_popup_menu")
self.tray_show = builder.get_object("tray_show")
self.tray_hide = builder.get_object("tray_hide")
@@ -1292,6 +1296,7 @@ class MainWindow(object):
self.set_up_completion()
self.set_up_history()
self.populate_log()
+ self.update_show_checkbox()
self.tick(True)
gobject.timeout_add(1000, self.tick)
@@ -1509,12 +1514,27 @@ class MainWindow(object):
self.main_window.present()
self.tray_show.hide()
self.tray_hide.show()
+ self.update_show_checkbox()
def on_hide_activate(self, widget=None):
"""Tray icon menu -> Hide selected"""
self.main_window.hide()
self.tray_hide.hide()
self.tray_show.show()
+ self.update_show_checkbox()
+
+ def update_show_checkbox(self):
+ self.ignore_on_toggle_visible = True
+ # This next line triggers both 'activate' and 'toggled' signals
+ self.appind_show.set_active(self.main_window.get_property("visible"))
+ self.ignore_on_toggle_visible = False
+
+ ignore_on_toggle_visible = False
+
+ def on_toggle_visible(self, widget=None):
+ """Application indicator menu -> Show GTimeLog"""
+ if not self.ignore_on_toggle_visible:
+ self.toggle_visible()
def toggle_visible(self):
"""Toggle main window visibility."""