← Back to team overview

cairo-dock-team team mailing list archive

[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea into lp:cairo-dock-plug-ins-extras

 

Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea into lp:cairo-dock-plug-ins-extras.

Requested reviews:
  Cairo-Dock Team (cairo-dock-team)

For more details, see:
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea/+merge/57601

Added a new applet, Liferea, as requested in the Applets forum http://glx-dock.org/bg_topic.php?t=5275
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea/+merge/57601
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Liferea into lp:cairo-dock-plug-ins-extras.
=== added directory 'Liferea'
=== added file 'Liferea/ChangeLog'
--- Liferea/ChangeLog	1970-01-01 00:00:00 +0000
+++ Liferea/ChangeLog	2011-04-13 21:47:27 +0000
@@ -0,0 +1,1 @@
+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

=== added file 'Liferea/Liferea'
--- Liferea/Liferea	1970-01-01 00:00:00 +0000
+++ Liferea/Liferea	2011-04-13 21:47:27 +0000
@@ -0,0 +1,160 @@
+#!/usr/bin/python
+
+# This is a part of the external Liferea applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+#
+# 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.
+
+# This applet creates an interface with Liferea feed reader.
+# Directly from the applet you can show the number of unread, or new messages,
+# subscribe feeds, and change the status between online, and offline.
+# Through the configuration screen you can choose to show the number of unread, or new messages
+# Right-click, and change the status directly from the menu
+# Middle-click, enter the feed URL to be subscribed, or drag-n-drop the URL on the icon
+# Left-click controls the Liferea window and it seems like a Launcher
+
+import dbus, os, subprocess
+from util import log
+from CDApplet import CDApplet
+
+class Applet(CDApplet):
+
+    def __init__(self):
+        
+        self.liferea = None
+        self.number_of_unread_msgs = 0
+        self.number_of_new_msgs = 0
+        self.show_number_of_unread_msgs = 0
+        self.show_number_of_new_msgs = 1
+
+        self.set_status_online_key = 1
+        self.set_status_offline_key = 2
+
+        self.dialog_active_time = 30                                                    # time in seconds that the dialog window will be active
+        CDApplet.__init__(self)                                                         # call high-level init
+
+    def connect_to_liferea(self):
+        try:
+            bus = dbus.SessionBus()
+            liferea_object = bus.get_object('org.gnome.feed.Reader', '/org/gnome/feed/Reader')
+            self.liferea = dbus.Interface(liferea_object, dbus_interface='org.gnome.feed.Reader')
+        except dbus.DBusException:
+            # Something more elaborated could be done here, e.g., use gobject.idle_add and using,
+            # as callback, a method that would keep checking if Lirefea is open. Opted for the simpler approach
+            self.icon.PopupDialog({'message':'Impossible connect to Liferea, check if it is running', 'time-length':self.dialog_active_time},{})
+        return self.liferea
+
+    def get_number_of_unread_msgs(self):
+        self.number_of_unread_msgs = self.liferea.GetUnreadItems()
+
+    def get_number_of_new_msgs(self):
+        self.number_of_new_msgs = self.liferea.GetNewItems()
+
+    def set_offline(self):
+        self.liferea.SetOnline(False)
+        self.set_offline_icon()
+
+    def set_offline_icon(self):
+        self.icon.SetIcon(os.path.abspath("./data/offline.png"))
+
+    def set_online(self):
+        self.liferea.SetOnline(True)
+        self.set_online_icon()
+
+    def set_online_icon(self):
+        self.icon.SetIcon(os.path.abspath("./data/online.png"))
+
+    def subscribe(self, url):
+        self.liferea.Subscribe(url) 
+
+    def switch_window_focus(self):
+        if not self.icon.Get("has_focus"):                                          # liferea running, but its window has no the focus
+            try:                                                                    
+                self.icon.ShowAppli(True)                                           # bring the window to the foreground
+            except:                                                                 # if liferea is only in notification bar, ShowAppli doesnt work ...
+                subprocess.Popen("liferea-bin")                                         # ... so it is necessary to recall the application
+        else:
+            self.icon.ShowAppli(False)                                              # take the window to the background
+
+    def show_icon_information(self):
+        if self.config_info == self.show_number_of_unread_msgs:
+            self.icon.SetQuickInfo(unicode(self.number_of_unread_msgs))
+        elif self.config_info == self.show_number_of_new_msgs:
+            self.icon.SetQuickInfo(unicode(self.number_of_new_msgs))
+    
+    def bind_to_liferea_window(self):
+        self.icon.ControlAppli("liferea-bin")
+
+    def build_status_menu(self):
+        status_menu = []
+        index = 1
+        for status in ["Online", "Offline"]:
+            status_menu.append({
+                'type'  : CDApplet.MENU_ENTRY,
+                'label' : status,
+                'menu'  : CDApplet.MAIN_MENU_ID,
+                'id'    : index,
+                'icon'  : os.path.abspath("./data/%s.png") % status.lower()})
+            index += 1
+        self.icon.AddMenuItems(status_menu)
+
+    # CDApplet
+
+    def begin(self):
+        self.bind_to_liferea_window()
+        if self.connect_to_liferea():
+            self.get_number_of_unread_msgs()
+            self.get_number_of_new_msgs()
+            self.show_icon_information()
+
+    def get_config(self, keyfile):
+        self.config_info = keyfile.getint('Configuration', 'icon_info')                 # get the source of quotations
+
+    def reload(self):
+        self.show_icon_information()
+
+    # Callbacks
+
+    def on_click(self, param):
+        if self.liferea:
+            self.switch_window_focus()
+
+    # Probably the user read something when he focus Liferea, therefore,
+    # it is useful to check again and refresh the number of unread, and new items
+    # I will avoid polling to keep checking this variables
+    def on_change_focus(self, has_focus):
+        self.get_number_of_unread_msgs()
+        self.get_number_of_new_msgs()
+        self.show_icon_information()
+
+    def on_drop_data(self, text):
+        self.subscribe(text)
+
+    def on_middle_click(self):
+        self.icon.PopupDialog ({'message':'Enter the feed URL', 'buttons':'ok;cancel'}, {'widget-type':'text-entry'})
+
+    def on_answer_dialog(self, key, content):
+        if (key == 0 or key == -1) and content:                                         # Ok or Enter
+            self.subscribe(content)
+
+    def on_build_menu(self):
+        self.build_status_menu()
+
+    def on_menu_select(self, selected_menu):
+        if selected_menu == self.set_status_online_key:
+            self.set_online()
+        elif selected_menu == self.set_status_offline_key:
+            self.set_offline()
+    
+if __name__ == '__main__':
+    Applet().run()

=== added file 'Liferea/Liferea.conf'
--- Liferea/Liferea.conf	1970-01-01 00:00:00 +0000
+++ Liferea/Liferea.conf	2011-04-13 21:47:27 +0000
@@ -0,0 +1,102 @@
+#!en;0.0.1
+
+#[gtk-about]
+[Icon]
+#F[Applet]
+frame_maininfo=
+
+#d Name of the dock it belongs to:
+dock name = 
+
+#s Name of the icon as it will appear in its caption in the dock:
+name = Liferea
+
+#F[Display]
+frame_display=
+
+#S+ Image's filename :
+#{Let empty to use the default one.}
+icon = 
+
+#j+[0;128] Desired icon size for this applet
+#{Set to 0 to use the default applet size}
+icon size = 0;0
+
+order=
+
+#F[Applet's Handbook]
+frame_hand=
+#A
+handbook=Liferea
+
+
+#[gtk-convert]
+[Desklet]
+
+#j+[48;512] Desklet's dimension (width x height) :
+#{Depending on your WindowManager, you can resize it with ALT + middle_click or ALT + left_click for exemple.}
+size = 164;96
+
+#i[-2048;2048] Desklet's position (x ; y) :
+#{Depending on your WindowManager, you can move it with ALT + left_click}
+x position=0
+#i[-2048;2048] ...
+y position=0
+
+#b Is detached from the dock ?
+initially detached=false
+#l[Normal;Keep above;Keep below;On Widget Layer;Reserve space] Accessibility :
+#{for CompizFusion's "widget layer", set behaviour in Compiz to: (class=Cairo-dock & type=utility)}
+accessibility=0
+#b Should be visible on all desktops ?
+sticky=true
+
+#b Lock position ?
+#{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.}
+locked = false
+
+#I[-180;180] Rotation :
+#{in degrees.}
+rotation = 0
+
+use size=
+
+#F[Decorations;gtk-orientation-portrait]
+frame_deco=
+
+#o+ Choose a decoration theme for this desklet :
+#{Choose the 'personnal' one to define your own decorations below.}
+decorations = default
+
+#v
+sep_deco =
+
+#S+ Background image :
+#{It's an image that will be displayed below the drawings, like a frame for exemple. Let empty to not use any.}
+bg desklet =
+#e+[0;1] Background tansparency :
+bg alpha = 1
+#i+[0;256] Left offset :
+#{in pixels. Use this to adjust the left position of the drawings.}
+left offset = 0
+#i+[0;256] Top offset :
+#{in pixels. Use this to adjust the top position of the drawings.}
+top offset = 0
+#i+[0;256] Right offset :
+#{in pixels. Use this to adjust the right position of the drawings.}
+right offset = 0
+#i+[0;256] Bottom offset :
+#{in pixels. Use this to adjust the bottom position of the drawings.}
+bottom offset = 0
+#S+ Foreground image :
+#{It's an image that will be displayed above the drawings, like a reflect for exemple. Let empty to not use any.}
+fg desklet =
+#e+[0;1] Foreground tansparency :
+fg alpha = 1
+
+
+#[gtk-preferences]
+[Configuration]
+
+#l[Number of unread messages; Number of new messages] Show in the icon:
+icon_info = 0

=== added file 'Liferea/README'
--- Liferea/README	1970-01-01 00:00:00 +0000
+++ Liferea/README	2011-04-13 21:47:27 +0000
@@ -0,0 +1,6 @@
+# Contact me
+
+Any doubt, suggestion or anything else, except asking for some money, I would be pleased to received a message from you. :¬)
+
+Author: Eduardo Mucelli Rezende Oliveira
+E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx

=== added file 'Liferea/auto-load.conf'
--- Liferea/auto-load.conf	1970-01-01 00:00:00 +0000
+++ Liferea/auto-load.conf	2011-04-13 21:47:27 +0000
@@ -0,0 +1,16 @@
+[Register]
+
+# Author of the applet
+author = Eduardo Mucelli Rezende Oliveira
+
+# A short description of the applet and how to use it.
+description = This applets makes an interface with Liferea
+
+# Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
+category = 5
+
+# 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.
+version = 0.0.1
+
+# Whether the applet can be instanciated several times or not.
+multi-instance = true

=== added directory 'Liferea/data'
=== added file 'Liferea/data/offline.png'
Binary 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
=== added file 'Liferea/data/online.png'
Binary 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
=== added file 'Liferea/icon'
Binary files Liferea/icon	1970-01-01 00:00:00 +0000 and Liferea/icon	2011-04-13 21:47:27 +0000 differ
=== added file 'Liferea/util.py'
--- Liferea/util.py	1970-01-01 00:00:00 +0000
+++ Liferea/util.py	2011-04-13 21:47:27 +0000
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+# This is a part of the external Liferea applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+
+def log (string):
+    print "[+] Liferea: %s" % string

=== modified file 'Quote/Quote'
--- Quote/Quote	2011-03-19 14:11:42 +0000
+++ Quote/Quote	2011-04-13 21:47:27 +0000
@@ -78,15 +78,13 @@
 			if (self.source == quotationspage):  
 				self.quote = parser.quote
 				self.author = parser.author
-			elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat):
+			elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat or self.source == grouphug):
 				self.quote = filter(None, parser.quote)							 	# retira os '' do array
 			elif self.source == jokestogo:										  	# jokestogo
 				self.quote = filter(self.breakline, parser.quote)
-			elif self.source == vidademerda:									   	# vidademerda
+			else:									   	# vidademerda
 				self.quote = [''.join(parser.quote)]
 				self.author = parser.author
-			else:																	#  grouphug
-				self.quote = filter(None, parser.quote)
 		return self.quote, self.author
 
 	def breakline(self, item):


Follow ups