Merge lp:~tom-blacknight/docky/emesene into lp:docky

Proposed by ukblacknight
Status: Merged
Merged at revision: 1179
Proposed branch: lp:~tom-blacknight/docky/emesene
Merge into: lp:docky
Diff against target: 150 lines (+119/-0)
4 files modified
scripts/Makefile.am (+1/-0)
scripts/emesene_control.py (+114/-0)
scripts/metadata/Makefile.am (+1/-0)
scripts/metadata/emesene_control.py.info (+3/-0)
To merge this branch: bzr merge lp:~tom-blacknight/docky/emesene
Reviewer Review Type Date Requested Status
Rico Tzschichholz Approve
Robert Dyer Pending
Review via email: mp+20899@code.launchpad.net

Description of the change

Emesene Helper

Works for emesene svn 2267 and greater (The svn will be packaged soon for release before Ubuntu 10.04).

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

It should be fine to merge it into trunk. Despite the fact that the needed emesene version isn't released yet. There could be some note in emesene_control.py.info with the required svn revision.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/Makefile.am'
2--- scripts/Makefile.am 2010-02-26 08:30:46 +0000
3+++ scripts/Makefile.am 2010-03-08 16:04:18 +0000
4@@ -3,6 +3,7 @@
5 dist_script_SCRIPTS = \
6 banshee_control.py \
7 deluge_badge.py \
8+ emesene_control.py \
9 gajim_badge.py \
10 gtg_menus.py \
11 liferea_badge.py \
12
13=== added file 'scripts/emesene_control.py'
14--- scripts/emesene_control.py 1970-01-01 00:00:00 +0000
15+++ scripts/emesene_control.py 2010-03-08 16:04:18 +0000
16@@ -0,0 +1,114 @@
17+#!/usr/bin/env python
18+
19+#
20+# Copyright (C) 2009-2010 Jason Smith, Rico Tzschichholz
21+#
22+# This program is free software: you can redistribute it and/or modify
23+# it under the terms of the GNU General Public License as published by
24+# the Free Software Foundation, either version 3 of the License, or
25+# (at your option) any later version.
26+#
27+# This program is distributed in the hope that it will be useful,
28+# but WITHOUT ANY WARRANTY; without even the implied warranty of
29+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+# GNU General Public License for more details.
31+#
32+# You should have received a copy of the GNU General Public License
33+# along with this program. If not, see <http://www.gnu.org/licenses/>.
34+#
35+
36+import atexit
37+import gobject
38+import glib
39+import dbus
40+import dbus.glib
41+import sys
42+import os
43+
44+try:
45+ from docky.docky import DockyItem, DockySink
46+ from signal import signal, SIGTERM
47+ from sys import exit
48+except ImportError, e:
49+ print e
50+ exit()
51+
52+emesenebus = "org.emesene.dbus"
53+emesenepath = "/org/emesene/dbus"
54+emeseneiface = "org.emesene.dbus"
55+
56+class DockyEmeseneItem(DockyItem):
57+ def __init__(self, path):
58+ DockyItem.__init__(self, path)
59+ self.msg_count = 0
60+ self.emesene = None
61+
62+ self.bus.add_signal_receiver(self.name_owner_changed_cb, dbus_interface='org.freedesktop.DBus', signal_name = 'NameOwnerChanged')
63+ obj = self.bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
64+ self.bus_interface = dbus.Interface(obj, "org.freedesktop.DBus")
65+
66+ self.bus_interface.ListNames (reply_handler=self.list_names_handler, error_handler=self.list_names_error_handler)
67+
68+ self.bus.add_signal_receiver(self.conversation_updated, "unread_messages", emeseneiface, emesenebus, emesenepath)
69+
70+ def list_names_handler(self, names):
71+ if emesenebus in names:
72+ self.init_emesene_objects()
73+ self.update_badge()
74+
75+ def list_names_error_handler(self, error):
76+ print "error getting bus names - %s" % str(error)
77+
78+ def name_owner_changed_cb(self, name, old_owner, new_owner):
79+ if name == emesenebus:
80+ if new_owner:
81+ self.init_emesene_objects()
82+ else:
83+ self.emesene = None
84+ self.msg_count = 0
85+ self.update_badge()
86+
87+ def init_emesene_objects(self):
88+ try:
89+ obj = self.bus.get_object(emesenebus, emesenepath)
90+ self.emesene = dbus.Interface(obj, emeseneiface)
91+ except:
92+ print 'Emesene dbus could not be found.'
93+
94+ def conversation_updated(self,count):
95+ self.update_badge()
96+
97+ def update_badge(self):
98+ if not self.emesene:
99+ self.iface.ResetBadgeText()
100+ return False
101+
102+ print 'update the badge'
103+
104+ count = self.emesene.get_message_count()
105+ if count > 0:
106+ self.iface.SetBadgeText("%s" % count)
107+ else:
108+ self.iface.ResetBadgeText()
109+
110+ return True
111+
112+class DockyEmeseneSink(DockySink):
113+ def item_path_found(self, pathtoitem, item):
114+ if item.GetOwnsDesktopFile() and item.GetDesktopFile().endswith ("emesene.desktop"):
115+ self.items[pathtoitem] = DockyEmeseneItem(pathtoitem)
116+
117+
118+emesenesink = DockyEmeseneSink()
119+
120+def cleanup():
121+ dockysink.dispose()
122+
123+if __name__ == "__main__":
124+ mainloop = gobject.MainLoop(is_running=True)
125+
126+ atexit.register (cleanup)
127+ signal(SIGTERM, lambda signum, strack_frame: exit(1))
128+ print 'Starting emesene handler...'
129+
130+ mainloop.run()
131
132=== modified file 'scripts/metadata/Makefile.am'
133--- scripts/metadata/Makefile.am 2010-02-26 08:30:46 +0000
134+++ scripts/metadata/Makefile.am 2010-03-08 16:04:18 +0000
135@@ -3,6 +3,7 @@
136 dist_script_DATA = \
137 banshee_control.py.info \
138 deluge_badge.py.info \
139+ emesene_control.py.info \
140 gajim_badge.py.info \
141 gtg_menus.py.info \
142 liferea_badge.py.info \
143
144=== added file 'scripts/metadata/emesene_control.py.info'
145--- scripts/metadata/emesene_control.py.info 1970-01-01 00:00:00 +0000
146+++ scripts/metadata/emesene_control.py.info 2010-03-08 16:04:18 +0000
147@@ -0,0 +1,3 @@
148+NAME="Emesene Controls"
149+DESCRIPTION="See your message count status on Emesene"
150+ICON="emesene"

Subscribers

People subscribed via source and target branches

to status/vote changes: