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

Proposed by Eduardo Mucelli Rezende Oliveira
Status: Merged
Merged at revision: 257
Proposed branch: lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 108 lines (+40/-5)
3 files modified
Twitter/ChangeLog (+1/-0)
Twitter/Twitter (+28/-5)
Twitter/Twitter.conf (+11/-0)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter
Reviewer Review Type Date Requested Status
Cairo-Dock Devs Pending
Review via email: mp+102034@code.launchpad.net

Description of the change

Configurable notifications.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Twitter/ChangeLog'
2--- Twitter/ChangeLog 2012-03-22 00:14:49 +0000
3+++ Twitter/ChangeLog 2012-04-15 17:45:24 +0000
4@@ -1,3 +1,4 @@
5+0.2.2: (April/15/2012): Configurable notifications.
6 0.2.1: (March/22/2012): Added user timeline.
7 0.2: (March/19/2012): Possible to retweet tweets. Tweets being shown with standard menu.
8 0.1.4: (March/18/2012): Alerts for new direct messages arriving on the stream, possible to answer them. Organizing the menus for new/all tweets, and messages. Play alert sound when tweet/message arrives on the stream.
9
10=== modified file 'Twitter/Twitter'
11--- Twitter/Twitter 2012-04-03 19:37:31 +0000
12+++ Twitter/Twitter 2012-04-15 17:45:24 +0000
13@@ -202,32 +202,43 @@
14
15 def play_alert_sound(self):
16 os.popen('aplay %s' % os.path.abspath("./data/alert.wav"))
17+
18+ def animate_icon(self, animation):
19+ if len(animation) == 0:
20+ animation = 'default'
21+ self.icon.DemandsAttention(True, animation)
22+
23+ def send_alert(self):
24+ if self.config['sound']:
25+ self.play_alert_sound()
26+ if self.config['animation']:
27+ self.animate_icon(self.config['animation_type'])
28
29 # Twitter methods
30
31 # This method is a callback that is called as soon as a new entry arrives on the stream
32 # The method is passed as parameter when creating the instance for the TwitterStreamAPI
33 # TwitterStreamAPI(access_key, access_secret, self.on_receive_new_entry_into_stream_callback)
34- # TODO: Make configurable the alerts, sound, animation, etc
35 def on_receive_new_entry_into_stream_callback(self, entry):
36 if 'user' in entry: # tweet
37 if not entry['user']['screen_name'] == self.user.screen_name: # not sent by the own user
38 logp("Inserting new tweet on the stream Queue: %s" % entry)
39 self.tweet_stream.put(entry) # put the new tweet on the stream queue
40 self.refresh_emblem_counter()
41- self.play_alert_sound()
42+ if self.config['alert']: # user wants alert?
43+ self.send_alert()
44 elif 'direct_message' in entry: # direct messages
45 if not entry['direct_message']['sender']['screen_name'] == self.user.screen_name: # not sent by the own user
46 logp("Inserting new message on the message Queue: %s" % entry)
47 self.message_stream.put(entry) # put the new message on the message queue
48 self.refresh_emblem_counter()
49- self.play_alert_sound()
50+ if self.config['alert']: # user wants alert?
51+ self.send_alert()
52
53 def show_user_timeline(self):
54 self.inform_start_of_waiting_process()
55
56 timeline = self.api.user_timeline()
57- print timeline[0]
58 if len(timeline) > 0:
59 ut_menu = menu.Menu(self.icon) # callback not set since there is no action when clicking ...
60 for status in timeline: # ... on the menu generated from this list
61@@ -508,6 +519,10 @@
62
63 def get_config(self, keyfile):
64 self.config['emblem_size'] = keyfile.get('Configuration', 'emblem_size')
65+ self.config['alert'] = keyfile.getboolean('Configuration', 'alert')
66+ self.config['sound'] = keyfile.getboolean('Configuration', 'sound')
67+ self.config['animation'] = keyfile.getboolean('Configuration', 'animation')
68+ self.config['animation_type'] = keyfile.get('Configuration', 'animation_type')
69
70 def reload(self):
71 self.refresh_emblem_counter()
72@@ -548,8 +563,16 @@
73 logp("Retweeting")
74 self.api.retweet(self.retweet_tweet_id)
75
76+ # If there is nothing to be seen, the left click opens the dialog to write a tweet
77+ # Otherwise we check if there is something new, likely to be what the user wants
78+ # to see quickly
79 def on_click(self, key):
80- self.ask_for_tweet()
81+ if not self.tweet_stream.empty():
82+ self.show_new_tweets()
83+ elif not self.message_stream.empty():
84+ self.show_new_direct_messages()
85+ else:
86+ self.ask_for_tweet()
87
88 def on_middle_click(self):
89 self.show_home_timeline()
90
91=== modified file 'Twitter/Twitter.conf'
92--- Twitter/Twitter.conf 2012-04-02 18:38:28 +0000
93+++ Twitter/Twitter.conf 2012-04-15 17:45:24 +0000
94@@ -104,3 +104,14 @@
95
96 #L+[Small;Medium;Large] Size of the emblem that shows the number of new tweets, and messages:
97 emblem_size=Medium
98+#B[3] Alert when you receive a new tweet or message?
99+alert=true
100+#b Play a sound?
101+#{Should the applet play a sound as a notification?}
102+sound=true
103+#B[1] Icon animation?
104+#{Should the applet animate the icon as a notification?}
105+animation=true
106+#a Choose animation:
107+#{Which animation should apply to the icon?}
108+animation_type=

Subscribers

People subscribed via source and target branches