[hamster-applet] allow to launch prefs and overview from the popup-menu. due to spawning a new process, it takes a bi
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] allow to launch prefs and overview from the popup-menu. due to spawning a new process, it takes a bi
- Date: Fri, 16 Jul 2010 14:46:04 +0000 (UTC)
commit 5cd897023a2bf5dcc2f9cefceb331544157ef4f9
Author: Toms Bauģis <toms baugis gmail com>
Date: Fri Jul 16 15:45:30 2010 +0100
allow to launch prefs and overview from the popup-menu.
due to spawning a new process, it takes a bit of time and does not guarantee unique instances.
data/hamster-client.desktop.in.in | 10 ++++++++++
data/wscript_build | 10 +++++++++-
src/docky_control/hamster_control.py | 28 ++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/data/hamster-client.desktop.in.in b/data/hamster-client.desktop.in.in
new file mode 100644
index 0000000..0c94f43
--- /dev/null
+++ b/data/hamster-client.desktop.in.in
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Terminal=false
+_Name=Time Tracker
+_Comment=Project Hamster - track your time
+Icon=hamster-applet
+Exec= BINDIR@/hamster-client overview
+Categories=GNOME;GTK;Utility;
+NoDisplay=true
diff --git a/data/wscript_build b/data/wscript_build
index 4142513..dc46542 100644
--- a/data/wscript_build
+++ b/data/wscript_build
@@ -27,6 +27,12 @@ bld(features = "subst",
)
bld(features = "subst",
+ source= "hamster-client.desktop.in.in",
+ target= "hamster-client.desktop.in",
+ dict = bld.env
+ )
+
+bld(features = "subst",
source= "Hamster_Applet.server.in.in",
target= "Hamster_Applet.server.in",
dict = bld.env
@@ -42,7 +48,9 @@ bld(features = 'intltool_in',
flags = ['-s', '-u', '-c'])
bld(features = 'intltool_in',
- source = 'hamster-standalone.desktop.in hamster-applet.desktop.in',
+ source = """hamster-standalone.desktop.in
+ hamster-applet.desktop.in
+ hamster-client.desktop.in""",
install_path = '${DATADIR}/applications',
podir = '../po',
flags = ['-d', '-q', '-u', '-c'])
diff --git a/src/docky_control/hamster_control.py b/src/docky_control/hamster_control.py
index 6f07111..0690601 100755
--- a/src/docky_control/hamster_control.py
+++ b/src/docky_control/hamster_control.py
@@ -23,6 +23,8 @@
import atexit
import gobject
import sys, os
+from subprocess import Popen
+
import gtk
from docky.docky import DockyItem, DockySink
@@ -43,7 +45,10 @@ class DockyHamsterItem(DockyItem):
self.storage.connect("facts-changed", lambda storage: self.refresh_hamster())
self.storage.connect("activities-changed", lambda storage: self.refresh_hamster())
+ self.id_map = {} #menu items
+
self.update_text()
+ self.add_actions()
gobject.timeout_add_seconds(60, self.refresh_hamster)
@@ -66,6 +71,29 @@ class DockyHamsterItem(DockyItem):
self.iface.SetText(_("No activity"))
self.iface.ResetBadgeText()
+ def add_menu_item(self, name, icon):
+ menu_id = self.iface.AddMenuItem(name, icon, "")
+ self.id_map[menu_id] = name
+
+ def menu_pressed(self, menu_id):
+ if self.id_map[menu_id] == _("Overview"):
+ Popen(["hamster-client", "overview", "&"])
+ elif self.id_map[menu_id] == _("Preferences"):
+ Popen(["hamster-client", "preferences", "&"])
+
+ self.add_actions() # TODO - figure out why is it that we have to regen all menu items after each click
+
+
+ def add_actions(self):
+ # first clear the menu
+ for k, v in self.id_map.iteritems():
+ self.iface.RemoveItem(k)
+
+ self.id_map = {}
+ # now add buttons
+ self.add_menu_item(_("Overview"), "")
+ self.add_menu_item(_("Preferences"), "preferences-desktop-personal")
+
class DockyHamsterSink(DockySink):
def item_path_found(self, pathtoitem, item):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]