Merge lp:~nicolas-espina/dockmanager/dockmanager-helpers into lp:dockmanager

Proposed by Nicolas
Status: Needs review
Proposed branch: lp:~nicolas-espina/dockmanager/dockmanager-helpers
Merge into: lp:dockmanager
Diff against target: 245 lines (+114/-23)
2 files modified
scripts/emesene_control.py (+44/-1)
scripts/pidgin_control.py (+70/-22)
To merge this branch: bzr merge lp:~nicolas-espina/dockmanager/dockmanager-helpers
Reviewer Review Type Date Requested Status
Rico Tzschichholz Needs Information
Michal Hruby Pending
Review via email: mp+33950@code.launchpad.net

Description of the change

I update the Pidgin and Emesene helpers, now the two applications uses the message count, menu entries in the dock menu to change status and the icon in the dock changes to show the actual status of the app.

This is my first approach in bzr+launchpad, so if you need something else just ask me, i have a diff file but i think that launchad makes a diff for you when i finish to send this

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

Creating and adding the menu entries only once is more stable, but you removed with this change the selective showing of them depending on the current connection state.

So at least the Connected/Disconnected status should take effect on what menu items are shown?

review: Needs Information
Revision history for this message
Nicolas (nicolas-espina) wrote :

I remove the change of states depending of the state of the IM to follow
the behavior of emesene and pidgin... They show ALL the status and no
depends of the actual. And i remove that behavior too because sometimes (and
for a strange reason that i never know) some statuses appears more than
once, so my decision to make them free of bugs was to remove that and show
all the status... BTW, the skype helper add all the entries and is really
nice

Revision history for this message
Nicolas (nicolas-espina) wrote :

I remove the change of states depending of the state of the IM to follow the behavior of emesene and pidgin... They show ALL the status and no depends of the actual. And i remove that behavior too because sometimes (and for a strange reason that i never know) some statuses appears more than once, so my decision to make them free of bugs was to remove that and show all the status... BTW, the skype helper add all the entries and is really nice

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

You might want to add some strings constants like the skype helper has and replace the duplicated usage of these icon paths. This also makes it easier to fix these hardcoded paths in future somehow.

review: Needs Fixing
Revision history for this message
Nicolas (nicolas-espina) wrote :

Ok... I have a really important exam so in the next week i finish well the code looking for the skype helper... Thanks for the help and in a close future you have notice of my helpers :D ... Cheers

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

@Nicolas: I hope you are going to finish your work. :)

review: Needs Information
Revision history for this message
Nicolas (nicolas-espina) wrote :

Ups... I forgot this completlly.. Really sorry for that... I finish all my
exams in exactly one week and i finish this =)

Sorry again

2010/12/6 Rico Tzschichholz <email address hidden>

> Review: Needs Information
> @Nicolas: I hope you are going to finish your work. :)
> --
>
> https://code.launchpad.net/~nicolas-espina/dockmanager/dockmanager-helpers/+merge/33950
> You are the owner of lp:~nicolas-espina/dockmanager/dockmanager-helpers.
>

68. By Nicolas

Now the icons are retrieved first in constants

Revision history for this message
Nicolas (nicolas-espina) wrote :

Rico: I fix the problem that my scripts have with the icon retrieves... Now i use the constants like you say... I hope that now everything is fine and ready to merge :D

Unmerged revisions

68. By Nicolas

Now the icons are retrieved first in constants

67. By Nicolas

Now pidgin show the status on Docky

66. By Nicolas

Fixed menu entries in the pidgin helper

65. By Nicolas

Updated emesene helper with some cool stuff

64. By Nicolas

First merge of the main branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/emesene_control.py'
2--- scripts/emesene_control.py 2010-08-06 23:14:20 +0000
3+++ scripts/emesene_control.py 2010-12-19 23:01:35 +0000
4@@ -37,11 +37,24 @@
5 emesenepath = "/org/emesene/dbus"
6 emeseneiface = "org.emesene.dbus"
7
8+STATUS_ICON_ONLINE = '/usr/share/emesene/themes/default/online.png'
9+STATUS_ICON_INVISIBLE = '/usr/share/emesene/themes/default/invisible.png'
10+STATUS_ICON_AWAY = '/usr/share/emesene/themes/default/away.png'
11+STATUS_ICON_IDLE = '/usr/share/emesene/themes/default/idle.png'
12+STATUS_ICON_BUSY = '/usr/share/emesene/themes/default/busy.png'
13+
14 class EmeseneItem(DockManagerItem):
15 def __init__(self, sink, path):
16 DockManagerItem.__init__(self, sink, path)
17 self.emesene = None
18
19+ #Menu Items
20+
21+ self.add_menu_item("Online", STATUS_ICON_ONLINE, "Status")
22+ self.add_menu_item("Away", STATUS_ICON_AWAY, "Status")
23+ self.add_menu_item("Busy", STATUS_ICON_BUSY, "Status")
24+ self.add_menu_item("Invisible", STATUS_ICON_INVISIBLE, "Status")
25+
26 self.bus.add_signal_receiver(self.name_owner_changed_cb, dbus_interface='org.freedesktop.DBus', signal_name = 'NameOwnerChanged')
27 obj = self.bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
28 self.bus_interface = dbus.Interface(obj, "org.freedesktop.DBus")
29@@ -49,6 +62,8 @@
30 self.bus_interface.ListNames (reply_handler=self.list_names_handler, error_handler=self.list_names_error_handler)
31
32 self.bus.add_signal_receiver(self.conversation_updated, "unread_messages", emeseneiface, emesenebus, emesenepath)
33+ self.bus.add_signal_receiver(self.status_changed, "status_changed", emeseneiface, emesenebus, emesenepath)
34+
35
36 def list_names_handler(self, names):
37 if emesenebus in names:
38@@ -69,10 +84,29 @@
39 def init_emesene_objects(self):
40 obj = self.bus.get_object(emesenebus, emesenepath)
41 self.emesene = dbus.Interface(obj, emeseneiface)
42+ self.update_icon(self.emesene.get_status())
43
44 def conversation_updated(self, count):
45 self.update_badge()
46
47+ def status_changed(self, a, b):
48+ self.update_icon(b)
49+ self.update_badge()
50+
51+ def update_icon(self,status):
52+ if status == 'NLN':
53+ status_image = STATUS_ICON_ONLINE
54+ elif status == 'AWY':
55+ status_image = STATUS_ICON_AWAY
56+ elif status == 'BSY':
57+ status_image = STATUS_ICON_BUSY
58+ elif status == 'HDN':
59+ status_image = STATUS_ICON_INVISIBLE
60+ elif status == 'IDL':
61+ status_image = STATUS_ICON_IDLE
62+ self.set_icon(status_image)
63+ return True
64+
65 def update_badge(self):
66 if not self.emesene:
67 self.reset_badge()
68@@ -86,13 +120,22 @@
69
70 return True
71
72+ def menu_pressed(self, menu_id):
73+ if self.id_map[menu_id] == "Online":
74+ self.emesene.set_status('NLN')
75+ elif self.id_map[menu_id] == "Away":
76+ self.emesene.set_status('AWY')
77+ elif self.id_map[menu_id] == "Busy":
78+ self.emesene.set_status('BSY')
79+ elif self.id_map[menu_id] == "Invisible":
80+ self.emesene.set_status('HDN')
81+
82 class EmeseneSink(DockManagerSink):
83 def item_path_found(self, pathtoitem, item):
84 if item.Get(DOCKITEM_IFACE, "DesktopFile", dbus_interface="org.freedesktop.DBus.Properties").endswith ("emesene.desktop"):
85 self.items[pathtoitem] = EmeseneItem(self, pathtoitem)
86
87 emesenesink = EmeseneSink()
88-
89 def cleanup():
90 emesenesink.dispose()
91
92
93=== modified file 'scripts/pidgin_control.py'
94--- scripts/pidgin_control.py 2010-08-06 23:14:20 +0000
95+++ scripts/pidgin_control.py 2010-12-19 23:01:35 +0000
96@@ -38,6 +38,12 @@
97 pidginpath = "/im/pidgin/purple/PurpleObject"
98 pidginitem = "im.pidgin.purple.PurpleInterface"
99
100+STATUS_ICON_AVAILABLE = '/usr/share/pixmaps/pidgin/status/48/available.png'
101+STATUS_ICON_AWAY = '/usr/share/pixmaps/pidgin/status/48/away.png'
102+STATUS_ICON_BUSY = '/usr/share/pixmaps/pidgin/status/48/busy.png'
103+STATUS_ICON_INVISIBLE = '/usr/share/pixmaps/pidgin/status/48/invisible.png'
104+STATUS_ICON_DISCONNECT = '/usr/share/pixmaps/pidgin/status/48/offline.png'
105+
106
107 class PidginDBus():
108 def __init__(self):
109@@ -52,6 +58,10 @@
110 def IsAway(self):
111 status = self.iface.PurpleSavedstatusGetCurrent()
112 return not self.iface.PurpleSavedstatusGetType(status) == 5
113+
114+ def getStatus(self):
115+ status = self.iface.PurpleSavedstatusGetCurrent()
116+ return self.iface.PurpleSavedstatusGetType(status)
117
118 def Available(self):
119 new_status = self.iface.PurpleSavedstatusNew("", 2)
120@@ -65,11 +75,27 @@
121 new_status = self.iface.PurpleSavedstatusNew("", 5)
122 self.iface.PurpleSavedstatusActivate(new_status)
123
124+ def Busy(self):
125+ new_status = self.iface.PurpleSavedstatusNew("", 3)
126+ self.iface.PurpleSavedstatusActivate(new_status)
127+
128+ def Invisible(self):
129+ new_status = self.iface.PurpleSavedstatusNew("", 4)
130+ self.iface.PurpleSavedstatusActivate(new_status)
131+
132
133 class PidginItem(DockManagerItem):
134 def __init__(self, sink, path):
135 DockManagerItem.__init__(self, sink, path)
136 self.pidgin = None
137+
138+ #Menu Items
139+
140+ self.add_menu_item ("Available", STATUS_ICON_AVAILABLE,"Status")
141+ self.add_menu_item ("Away", STATUS_ICON_AWAY,"Status")
142+ self.add_menu_item ("Busy", STATUS_ICON_BUSY,"Status")
143+ self.add_menu_item ("Invisible", STATUS_ICON_INVISIBLE,"Status")
144+ self.add_menu_item ("Disconnect", STATUS_ICON_DISCONNECT,"Status")
145
146 self.bus.add_signal_receiver(self.name_owner_changed_cb,
147 dbus_interface='org.freedesktop.DBus',
148@@ -86,7 +112,7 @@
149 def list_names_handler(self, names):
150 if pidginbus in names:
151 self.init_pidgin_objects()
152- self.set_menu_buttons()
153+# self.set_menu_buttons()
154 self.update_badge()
155
156 def list_names_error_handler(self, error):
157@@ -98,37 +124,55 @@
158 self.init_pidgin_objects()
159 else:
160 self.pidgin = None
161- self.set_menu_buttons()
162+# self.set_menu_buttons()
163 self.update_badge()
164
165 def init_pidgin_objects(self):
166 self.pidgin = PidginDBus()
167+ self.update_icon()
168
169- def status_changed(self, a, b, c):
170- self.set_menu_buttons()
171+ def status_changed(self, account, old, new):
172+# self.set_menu_buttons()
173+ self.update_icon()
174 self.update_badge()
175+
176+ def update_icon(self):
177+ status = self.pidgin.getStatus()
178+ if status == 2:
179+ status_image = STATUS_ICON_AVAILABLE
180+ elif status == 5:
181+ status_image = STATUS_ICON_AWAY
182+ elif status == 3:
183+ status_image = STATUS_ICON_BUSY
184+ elif status == 4:
185+ status_image = STATUS_ICON_INVISIBLE
186+ elif status == 1:
187+ status_image = STATUS_ICON_DISCONNECT
188+ self.set_icon(status_image)
189+ return True
190+
191
192 def conversation_updated(self, conv, type):
193 self.update_badge()
194
195- def clear_menu_buttons(self):
196- for k in self.id_map.keys():
197- self.remove_menu_item(k)
198-
199- def set_menu_buttons(self):
200- self.clear_menu_buttons()
201-
202- if not self.pidgin or not self.iface:
203- return
204+# def clear_menu_buttons(self):
205+# for k in self.id_map.keys():
206+# self.remove_menu_item(k)
207
208- if self.pidgin.IsConnected():
209- if self.pidgin.IsAway():
210- self.add_menu_item ("Set Away", "/usr/share/pixmaps/pidgin/status/16/away.png")
211- else:
212- self.add_menu_item ("Set Available", "/usr/share/pixmaps/pidgin/status/16/available.png")
213- self.add_menu_item ("Disconnect", "/usr/share/pixmaps/pidgin/status/16/offline.png")
214- else:
215- self.add_menu_item ("Connect", "/usr/share/pixmaps/pidgin/status/16/available.png")
216+# def set_menu_buttons(self):
217+# self.clear_menu_buttons()
218+#
219+# if not self.pidgin or not self.iface:
220+# return
221+#
222+# if self.pidgin.IsConnected():
223+# if self.pidgin.IsAway():
224+# self.add_menu_item ("Set Away", "/usr/share/pixmaps/pidgin/status/16/away.png")
225+# else:
226+# self.add_menu_item ("Set Available", "/usr/share/pixmaps/pidgin/status/16/available.png")
227+# self.add_menu_item ("Disconnect", "/usr/share/pixmaps/pidgin/status/16/offline.png")
228+# else:
229+# self.add_menu_item ("Connect", "/usr/share/pixmaps/pidgin/status/16/available.png")
230
231 def update_badge(self):
232 if not self.pidgin:
233@@ -150,8 +194,12 @@
234
235 if menu_id == "Disconnect":
236 self.pidgin.Disconnect()
237- elif menu_id == "Set Away":
238+ elif menu_id == "Away":
239 self.pidgin.Away()
240+ elif menu_id == "Invisible":
241+ self.pidgin.Invisible()
242+ elif menu_id == "Busy":
243+ self.pidgin.Busy()
244 else:
245 self.pidgin.Available()
246

Subscribers

People subscribed via source and target branches

to status/vote changes: