Merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by Eduardo Mucelli Rezende Oliveira
Status: Merged
Merged at revision: 157
Proposed branch: lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 353 lines (+296/-4)
7 files modified
Liferea/ChangeLog (+1/-0)
Liferea/Liferea (+160/-0)
Liferea/Liferea.conf (+102/-0)
Liferea/README (+6/-0)
Liferea/auto-load.conf (+16/-0)
Liferea/util.py (+9/-0)
Quote/Quote (+2/-4)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea
Reviewer Review Type Date Requested Status
Matthieu Baerts Approve
Review via email: mp+57601@code.launchpad.net

Description of the change

Added a new applet, Liferea, as requested in the Applets forum http://glx-dock.org/bg_topic.php?t=5275

To post a comment you must log in.
Revision history for this message
Matthieu Baerts (matttbe) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'Liferea'
2=== added file 'Liferea/ChangeLog'
3--- Liferea/ChangeLog 1970-01-01 00:00:00 +0000
4+++ Liferea/ChangeLog 2011-04-13 21:47:27 +0000
5@@ -0,0 +1,1 @@
6+0.0.1:(April/13/2011): Liferea applet was created with the possibility to show the number of unread, or new messages, subscribe feeds, and set the status between online, and offline. The icons were taken from http://gnome-look.org/content/show.php/Liferea+32x32+Notification+Icons?content=66504
7
8=== added file 'Liferea/Liferea'
9--- Liferea/Liferea 1970-01-01 00:00:00 +0000
10+++ Liferea/Liferea 2011-04-13 21:47:27 +0000
11@@ -0,0 +1,160 @@
12+#!/usr/bin/python
13+
14+# This is a part of the external Liferea applet for Cairo-Dock
15+#
16+# Author: Eduardo Mucelli Rezende Oliveira
17+# E-mail: edumucelli@gmail.com or eduardom@dcc.ufmg.br
18+#
19+# This program is free software: you can redistribute it and/or modify
20+# it under the terms of the GNU General Public License as published by
21+# the Free Software Foundation, either version 3 of the License, or
22+# (at your option) any later version.
23+
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU General Public License for more details.
28+
29+# This applet creates an interface with Liferea feed reader.
30+# Directly from the applet you can show the number of unread, or new messages,
31+# subscribe feeds, and change the status between online, and offline.
32+# Through the configuration screen you can choose to show the number of unread, or new messages
33+# Right-click, and change the status directly from the menu
34+# Middle-click, enter the feed URL to be subscribed, or drag-n-drop the URL on the icon
35+# Left-click controls the Liferea window and it seems like a Launcher
36+
37+import dbus, os, subprocess
38+from util import log
39+from CDApplet import CDApplet
40+
41+class Applet(CDApplet):
42+
43+ def __init__(self):
44+
45+ self.liferea = None
46+ self.number_of_unread_msgs = 0
47+ self.number_of_new_msgs = 0
48+ self.show_number_of_unread_msgs = 0
49+ self.show_number_of_new_msgs = 1
50+
51+ self.set_status_online_key = 1
52+ self.set_status_offline_key = 2
53+
54+ self.dialog_active_time = 30 # time in seconds that the dialog window will be active
55+ CDApplet.__init__(self) # call high-level init
56+
57+ def connect_to_liferea(self):
58+ try:
59+ bus = dbus.SessionBus()
60+ liferea_object = bus.get_object('org.gnome.feed.Reader', '/org/gnome/feed/Reader')
61+ self.liferea = dbus.Interface(liferea_object, dbus_interface='org.gnome.feed.Reader')
62+ except dbus.DBusException:
63+ # Something more elaborated could be done here, e.g., use gobject.idle_add and using,
64+ # as callback, a method that would keep checking if Lirefea is open. Opted for the simpler approach
65+ self.icon.PopupDialog({'message':'Impossible connect to Liferea, check if it is running', 'time-length':self.dialog_active_time},{})
66+ return self.liferea
67+
68+ def get_number_of_unread_msgs(self):
69+ self.number_of_unread_msgs = self.liferea.GetUnreadItems()
70+
71+ def get_number_of_new_msgs(self):
72+ self.number_of_new_msgs = self.liferea.GetNewItems()
73+
74+ def set_offline(self):
75+ self.liferea.SetOnline(False)
76+ self.set_offline_icon()
77+
78+ def set_offline_icon(self):
79+ self.icon.SetIcon(os.path.abspath("./data/offline.png"))
80+
81+ def set_online(self):
82+ self.liferea.SetOnline(True)
83+ self.set_online_icon()
84+
85+ def set_online_icon(self):
86+ self.icon.SetIcon(os.path.abspath("./data/online.png"))
87+
88+ def subscribe(self, url):
89+ self.liferea.Subscribe(url)
90+
91+ def switch_window_focus(self):
92+ if not self.icon.Get("has_focus"): # liferea running, but its window has no the focus
93+ try:
94+ self.icon.ShowAppli(True) # bring the window to the foreground
95+ except: # if liferea is only in notification bar, ShowAppli doesnt work ...
96+ subprocess.Popen("liferea-bin") # ... so it is necessary to recall the application
97+ else:
98+ self.icon.ShowAppli(False) # take the window to the background
99+
100+ def show_icon_information(self):
101+ if self.config_info == self.show_number_of_unread_msgs:
102+ self.icon.SetQuickInfo(unicode(self.number_of_unread_msgs))
103+ elif self.config_info == self.show_number_of_new_msgs:
104+ self.icon.SetQuickInfo(unicode(self.number_of_new_msgs))
105+
106+ def bind_to_liferea_window(self):
107+ self.icon.ControlAppli("liferea-bin")
108+
109+ def build_status_menu(self):
110+ status_menu = []
111+ index = 1
112+ for status in ["Online", "Offline"]:
113+ status_menu.append({
114+ 'type' : CDApplet.MENU_ENTRY,
115+ 'label' : status,
116+ 'menu' : CDApplet.MAIN_MENU_ID,
117+ 'id' : index,
118+ 'icon' : os.path.abspath("./data/%s.png") % status.lower()})
119+ index += 1
120+ self.icon.AddMenuItems(status_menu)
121+
122+ # CDApplet
123+
124+ def begin(self):
125+ self.bind_to_liferea_window()
126+ if self.connect_to_liferea():
127+ self.get_number_of_unread_msgs()
128+ self.get_number_of_new_msgs()
129+ self.show_icon_information()
130+
131+ def get_config(self, keyfile):
132+ self.config_info = keyfile.getint('Configuration', 'icon_info') # get the source of quotations
133+
134+ def reload(self):
135+ self.show_icon_information()
136+
137+ # Callbacks
138+
139+ def on_click(self, param):
140+ if self.liferea:
141+ self.switch_window_focus()
142+
143+ # Probably the user read something when he focus Liferea, therefore,
144+ # it is useful to check again and refresh the number of unread, and new items
145+ # I will avoid polling to keep checking this variables
146+ def on_change_focus(self, has_focus):
147+ self.get_number_of_unread_msgs()
148+ self.get_number_of_new_msgs()
149+ self.show_icon_information()
150+
151+ def on_drop_data(self, text):
152+ self.subscribe(text)
153+
154+ def on_middle_click(self):
155+ self.icon.PopupDialog ({'message':'Enter the feed URL', 'buttons':'ok;cancel'}, {'widget-type':'text-entry'})
156+
157+ def on_answer_dialog(self, key, content):
158+ if (key == 0 or key == -1) and content: # Ok or Enter
159+ self.subscribe(content)
160+
161+ def on_build_menu(self):
162+ self.build_status_menu()
163+
164+ def on_menu_select(self, selected_menu):
165+ if selected_menu == self.set_status_online_key:
166+ self.set_online()
167+ elif selected_menu == self.set_status_offline_key:
168+ self.set_offline()
169+
170+if __name__ == '__main__':
171+ Applet().run()
172
173=== added file 'Liferea/Liferea.conf'
174--- Liferea/Liferea.conf 1970-01-01 00:00:00 +0000
175+++ Liferea/Liferea.conf 2011-04-13 21:47:27 +0000
176@@ -0,0 +1,102 @@
177+#!en;0.0.1
178+
179+#[gtk-about]
180+[Icon]
181+#F[Applet]
182+frame_maininfo=
183+
184+#d Name of the dock it belongs to:
185+dock name =
186+
187+#s Name of the icon as it will appear in its caption in the dock:
188+name = Liferea
189+
190+#F[Display]
191+frame_display=
192+
193+#S+ Image's filename :
194+#{Let empty to use the default one.}
195+icon =
196+
197+#j+[0;128] Desired icon size for this applet
198+#{Set to 0 to use the default applet size}
199+icon size = 0;0
200+
201+order=
202+
203+#F[Applet's Handbook]
204+frame_hand=
205+#A
206+handbook=Liferea
207+
208+
209+#[gtk-convert]
210+[Desklet]
211+
212+#j+[48;512] Desklet's dimension (width x height) :
213+#{Depending on your WindowManager, you can resize it with ALT + middle_click or ALT + left_click for exemple.}
214+size = 164;96
215+
216+#i[-2048;2048] Desklet's position (x ; y) :
217+#{Depending on your WindowManager, you can move it with ALT + left_click}
218+x position=0
219+#i[-2048;2048] ...
220+y position=0
221+
222+#b Is detached from the dock ?
223+initially detached=false
224+#l[Normal;Keep above;Keep below;On Widget Layer;Reserve space] Accessibility :
225+#{for CompizFusion's "widget layer", set behaviour in Compiz to: (class=Cairo-dock & type=utility)}
226+accessibility=0
227+#b Should be visible on all desktops ?
228+sticky=true
229+
230+#b Lock position ?
231+#{If locked, the desklet can't be moved by simply dragging it with the left mouse button. Of course you can still move it with ALT + left_click.}
232+locked = false
233+
234+#I[-180;180] Rotation :
235+#{in degrees.}
236+rotation = 0
237+
238+use size=
239+
240+#F[Decorations;gtk-orientation-portrait]
241+frame_deco=
242+
243+#o+ Choose a decoration theme for this desklet :
244+#{Choose the 'personnal' one to define your own decorations below.}
245+decorations = default
246+
247+#v
248+sep_deco =
249+
250+#S+ Background image :
251+#{It's an image that will be displayed below the drawings, like a frame for exemple. Let empty to not use any.}
252+bg desklet =
253+#e+[0;1] Background tansparency :
254+bg alpha = 1
255+#i+[0;256] Left offset :
256+#{in pixels. Use this to adjust the left position of the drawings.}
257+left offset = 0
258+#i+[0;256] Top offset :
259+#{in pixels. Use this to adjust the top position of the drawings.}
260+top offset = 0
261+#i+[0;256] Right offset :
262+#{in pixels. Use this to adjust the right position of the drawings.}
263+right offset = 0
264+#i+[0;256] Bottom offset :
265+#{in pixels. Use this to adjust the bottom position of the drawings.}
266+bottom offset = 0
267+#S+ Foreground image :
268+#{It's an image that will be displayed above the drawings, like a reflect for exemple. Let empty to not use any.}
269+fg desklet =
270+#e+[0;1] Foreground tansparency :
271+fg alpha = 1
272+
273+
274+#[gtk-preferences]
275+[Configuration]
276+
277+#l[Number of unread messages; Number of new messages] Show in the icon:
278+icon_info = 0
279
280=== added file 'Liferea/README'
281--- Liferea/README 1970-01-01 00:00:00 +0000
282+++ Liferea/README 2011-04-13 21:47:27 +0000
283@@ -0,0 +1,6 @@
284+# Contact me
285+
286+Any doubt, suggestion or anything else, except asking for some money, I would be pleased to received a message from you. :¬)
287+
288+Author: Eduardo Mucelli Rezende Oliveira
289+E-mail: edumucelli@gmail.com or eduardom@dcc.ufmg.br
290
291=== added file 'Liferea/auto-load.conf'
292--- Liferea/auto-load.conf 1970-01-01 00:00:00 +0000
293+++ Liferea/auto-load.conf 2011-04-13 21:47:27 +0000
294@@ -0,0 +1,16 @@
295+[Register]
296+
297+# Author of the applet
298+author = Eduardo Mucelli Rezende Oliveira
299+
300+# A short description of the applet and how to use it.
301+description = This applets makes an interface with Liferea
302+
303+# Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
304+category = 5
305+
306+# Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
307+version = 0.0.1
308+
309+# Whether the applet can be instanciated several times or not.
310+multi-instance = true
311
312=== added directory 'Liferea/data'
313=== added file 'Liferea/data/offline.png'
314Binary files Liferea/data/offline.png 1970-01-01 00:00:00 +0000 and Liferea/data/offline.png 2011-04-13 21:47:27 +0000 differ
315=== added file 'Liferea/data/online.png'
316Binary files Liferea/data/online.png 1970-01-01 00:00:00 +0000 and Liferea/data/online.png 2011-04-13 21:47:27 +0000 differ
317=== added file 'Liferea/icon'
318Binary files Liferea/icon 1970-01-01 00:00:00 +0000 and Liferea/icon 2011-04-13 21:47:27 +0000 differ
319=== added file 'Liferea/util.py'
320--- Liferea/util.py 1970-01-01 00:00:00 +0000
321+++ Liferea/util.py 2011-04-13 21:47:27 +0000
322@@ -0,0 +1,9 @@
323+#!/usr/bin/python
324+
325+# This is a part of the external Liferea applet for Cairo-Dock
326+#
327+# Author: Eduardo Mucelli Rezende Oliveira
328+# E-mail: edumucelli@gmail.com or eduardom@dcc.ufmg.br
329+
330+def log (string):
331+ print "[+] Liferea: %s" % string
332
333=== modified file 'Quote/Quote'
334--- Quote/Quote 2011-03-19 14:11:42 +0000
335+++ Quote/Quote 2011-04-13 21:47:27 +0000
336@@ -78,15 +78,13 @@
337 if (self.source == quotationspage):
338 self.quote = parser.quote
339 self.author = parser.author
340- elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat):
341+ elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat or self.source == grouphug):
342 self.quote = filter(None, parser.quote) # retira os '' do array
343 elif self.source == jokestogo: # jokestogo
344 self.quote = filter(self.breakline, parser.quote)
345- elif self.source == vidademerda: # vidademerda
346+ else: # vidademerda
347 self.quote = [''.join(parser.quote)]
348 self.author = parser.author
349- else: # grouphug
350- self.quote = filter(None, parser.quote)
351 return self.quote, self.author
352
353 def breakline(self, item):

Subscribers

People subscribed via source and target branches