[hamster-applet] will be hosting the docky helper ourself
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] will be hosting the docky helper ourself
- Date: Thu, 15 Jul 2010 22:45:01 +0000 (UTC)
commit b5e790d71b368dfd27cb8432abd83348d2b22b21
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu Jul 15 23:44:48 2010 +0100
will be hosting the docky helper ourself
src/docky_control/hamster_control.py | 87 +++++++++++++++++++++++++++++
src/docky_control/hamster_control.py.info | 3 +
wscript | 7 ++
3 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/src/docky_control/hamster_control.py b/src/docky_control/hamster_control.py
new file mode 100755
index 0000000..65fd1ec
--- /dev/null
+++ b/src/docky_control/hamster_control.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+
+#
+# Copyright (C) 2010 Toms Baugis
+#
+# Original code from Banshee control,
+# Copyright (C) 2009-2010 Jason Smith, Rico Tzschichholz
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import atexit
+import gobject
+import sys, os
+
+import gtk
+from docky.docky import DockyItem, DockySink
+from signal import signal, SIGTERM
+from sys import exit
+
+
+from hamster import client, stuff
+from hamster import i18n
+i18n.setup_i18n()
+
+
+class DockyHamsterItem(DockyItem):
+ def __init__(self, path):
+ DockyItem.__init__(self, path)
+
+ self.storage = client.Storage()
+ self.storage.connect("facts-changed", lambda storage: self.refresh_hamster())
+ self.storage.connect("activities-changed", lambda storage: self.refresh_hamster())
+
+ self.update_text()
+ gobject.timeout_add_seconds(60, self.refresh_hamster)
+
+
+ def refresh_hamster(self):
+ try:
+ self.update_text()
+ finally: # we want to go on no matter what, so in case of any error we find out about it sooner
+ return True
+
+
+ def update_text(self):
+ today = self.storage.get_todays_facts()
+
+ if today and today[-1]['end_time'] is None:
+ fact = today[-1]
+
+ self.iface.SetText("%(name)s - %(category)s" % fact)
+ self.iface.SetBadgeText(stuff.format_duration(fact['delta'], human=False))
+ else:
+ self.iface.ResetText()
+ self.iface.ResetBadgeText()
+
+
+class DockyHamsterSink(DockySink):
+ def item_path_found(self, pathtoitem, item):
+ if item.GetOwnsDesktopFile() and item.GetDesktopFile().endswith("hamster-standalone.desktop"):
+ self.items[pathtoitem] = DockyHamsterItem(pathtoitem)
+
+dockysink = DockyHamsterSink()
+
+def cleanup():
+ dockysink.dispose()
+
+if __name__ == "__main__":
+ mainloop = gobject.MainLoop(is_running=True)
+
+ atexit.register (cleanup)
+ signal(SIGTERM, lambda signum, stack_frame: exit(1))
+
+ while mainloop.is_running():
+ mainloop.run()
diff --git a/src/docky_control/hamster_control.py.info b/src/docky_control/hamster_control.py.info
new file mode 100644
index 0000000..1c7e1da
--- /dev/null
+++ b/src/docky_control/hamster_control.py.info
@@ -0,0 +1,3 @@
+NAME="Hamster Controls"
+DESCRIPTION="Status icon for the Project Hamster time tracker"
+ICON="hamster-applet"
diff --git a/wscript b/wscript
index 439c9bf..d3589ab 100644
--- a/wscript
+++ b/wscript
@@ -63,6 +63,13 @@ def build(bld):
bld.install_files('${PYTHONDIR}/hamster', 'src/hamster/*.py')
bld.install_files('${PYTHONDIR}/hamster/widgets', 'src/hamster/widgets/*.py')
+ bld.install_files('${DATADIR}/docky/helpers',
+ 'src/docky_control/hamster_control.py',
+ chmod = 0755)
+ bld.install_files('${DATADIR}/docky/helpers/metadata',
+ 'src/docky_control/hamster_control.py.info')
+
+
bld.new_task_gen("subst",
source= "org.gnome.hamster.service.in",
target= "org.gnome.hamster.service",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]