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: 245
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: 167 lines (+37/-12)
5 files modified
Twitter/ChangeLog (+1/-0)
Twitter/Twitter (+29/-6)
Twitter/Twitter.conf (+1/-1)
Twitter/auto-load.conf (+1/-1)
Twitter/menu.py (+5/-4)
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+98761@code.launchpad.net

Description of the change

Added user timeline.

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-19 00:02:27 +0000
3+++ Twitter/ChangeLog 2012-03-22 00:19:17 +0000
4@@ -1,3 +1,4 @@
5+0.2.1: (March/22/2012): Added user timeline.
6 0.2: (March/19/2012): Possible to retweet tweets. Tweets being shown with standard menu.
7 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.
8 0.1.3: (March/14/2012): Direct messages are shown in a gtk-based menu, and it is possible to reply them. Fixing the post method, and the stream callback.
9
10=== modified file 'Twitter/Twitter'
11--- Twitter/Twitter 2012-03-21 00:02:15 +0000
12+++ Twitter/Twitter 2012-03-22 00:19:17 +0000
13@@ -223,17 +223,25 @@
14 self.refresh_emblem_counter()
15 self.play_alert_sound()
16
17- # TODO: Use the Menu class
18 def show_user_timeline(self):
19 self.inform_start_of_waiting_process()
20+
21 timeline = self.api.user_timeline()
22+ print timeline[0]
23 if len(timeline) > 0:
24- message = "".join (["[<b>%s</b>] %s\n" % (status['user']['screen_name'], status['text']) for status in timeline])
25+ ut_menu = menu.Menu(self.icon) # callback not set since there is no action when clicking ...
26+ for status in timeline: # ... on the menu generated from this list
27+ text = status['text']
28+ sender = status['user']['name']
29+ uid = status['id_str']
30+ ut_menu.add(Tweet(text, sender, uid))
31+ ut_menu.pop_up()
32 else:
33 message = _("Oh, dear, your timeline is empty :-(")
34- dialog = {'use-markup':True}
35+ dialog = {'use-markup':True}
36+ self.show_popup_message(message, dialog)
37+
38 self.inform_end_of_waiting_process()
39- self.show_popup_message(message, dialog)
40
41 def show_new_tweets(self):
42 self.inform_start_of_waiting_process()
43@@ -413,7 +421,7 @@
44 'type' : CDApplet.MENU_ENTRY,
45 'label' : label,
46 'id' : self.direct_messages_menu_id,
47- 'icon' : os.path.abspath("./data/received.png")
48+ 'icon' : os.path.abspath("./data/message.png")
49 })
50 self.icon.AddMenuItems(direct_messages_menu)
51
52@@ -437,9 +445,20 @@
53 'type' : CDApplet.MENU_ENTRY,
54 'label' : label,
55 'id' : self.tweets_menu_id,
56- 'icon' : os.path.abspath("./data/new.png")
57+ 'icon' : os.path.abspath("./data/tweet.png")
58 })
59 self.icon.AddMenuItems(tweets_menu)
60+
61+ def build_user_timeline_menu(self):
62+ user_timeline_menu = []
63+
64+ user_timeline_menu.append ({
65+ 'type' : CDApplet.MENU_ENTRY,
66+ 'label' : _("My tweets"),
67+ 'id' : self.user_timeline_menu_id,
68+ 'icon' : os.path.abspath("./data/tweet.png")
69+ })
70+ self.icon.AddMenuItems(user_timeline_menu)
71
72 def __init__(self):
73 self.user = User()
74@@ -459,6 +478,7 @@
75 self.direct_messages_menu_id = 1000
76 self.credentials_menu_id = 2000
77 self.tweets_menu_id = 3000
78+ self.user_timeline_menu_id = 4000
79
80 self.tweet_stream = Queue.Queue()
81 self.message_stream = Queue.Queue()
82@@ -524,6 +544,7 @@
83
84 def on_build_menu(self):
85 self.build_credentials_menu()
86+ self.build_user_timeline_menu()
87 self.build_direct_messages_menu()
88 self.build_tweets_menu()
89
90@@ -540,6 +561,8 @@
91 self.show_home_timeline() # show the last 20 tweets on the home timeline
92 else: # new tweets on the stream
93 self.show_new_tweets() # show new tweets
94+ elif selected_menu == self.user_timeline_menu_id:
95+ self.show_user_timeline()
96
97 if __name__ == '__main__':
98 Applet().run()
99
100=== modified file 'Twitter/Twitter.conf'
101--- Twitter/Twitter.conf 2012-03-21 00:02:15 +0000
102+++ Twitter/Twitter.conf 2012-03-22 00:19:17 +0000
103@@ -1,4 +1,4 @@
104-#!en;0.2
105+#!en;0.2.1
106
107 #[gtk-about]
108 [Icon]
109
110=== modified file 'Twitter/auto-load.conf'
111--- Twitter/auto-load.conf 2012-03-19 00:02:27 +0000
112+++ Twitter/auto-load.conf 2012-03-22 00:19:17 +0000
113@@ -10,7 +10,7 @@
114 category = 3
115
116 # 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.
117-version = 0.2
118+version = 0.2.1
119
120 # Whether the applet can be instanciated several times or not.
121 multi-instance = true
122
123=== added file 'Twitter/data/message.png'
124Binary files Twitter/data/message.png 1970-01-01 00:00:00 +0000 and Twitter/data/message.png 2012-03-22 00:19:17 +0000 differ
125=== added file 'Twitter/data/message_small.png'
126Binary files Twitter/data/message_small.png 1970-01-01 00:00:00 +0000 and Twitter/data/message_small.png 2012-03-22 00:19:17 +0000 differ
127=== removed file 'Twitter/data/new.png'
128Binary files Twitter/data/new.png 2012-03-05 14:44:13 +0000 and Twitter/data/new.png 1970-01-01 00:00:00 +0000 differ
129=== removed file 'Twitter/data/received.png'
130Binary files Twitter/data/received.png 2012-03-05 14:44:13 +0000 and Twitter/data/received.png 1970-01-01 00:00:00 +0000 differ
131=== removed file 'Twitter/data/received_menu.png'
132Binary files Twitter/data/received_menu.png 2012-03-14 00:06:29 +0000 and Twitter/data/received_menu.png 1970-01-01 00:00:00 +0000 differ
133=== added file 'Twitter/data/tweet.png'
134Binary files Twitter/data/tweet.png 1970-01-01 00:00:00 +0000 and Twitter/data/tweet.png 2012-03-22 00:19:17 +0000 differ
135=== modified file 'Twitter/menu.py'
136--- Twitter/menu.py 2012-03-19 00:02:27 +0000
137+++ Twitter/menu.py 2012-03-22 00:19:17 +0000
138@@ -10,7 +10,7 @@
139
140 class Menu(gtk.Menu):
141
142- def __init__(self, icon, callback):
143+ def __init__(self, icon, callback=None):
144 gtk.Menu.__init__(self)
145
146 self.messages = []
147@@ -22,16 +22,17 @@
148
149 def pop_up(self):
150 for message in self.messages:
151- text = "<b>%s</b>\n%s" % (message.sender, message.text)
152 item = gtk.ImageMenuItem()
153 # the true label is set after with set_markup()
154 if isinstance(message, DirectMessage):
155 item.set_label(message.sender) # used to track who sent the message in order to reply it.
156 elif isinstance(message, Tweet):
157 item.set_label(message.uid) # used to retweet the tweet
158- item.set_image(gtk.image_new_from_file(os.path.abspath("./data/received_menu.png")))
159+ item.set_image(gtk.image_new_from_file(os.path.abspath("./data/message_small.png")))
160+ text = "<b>%s</b>\n%s" % (message.sender, message.text)
161 item.get_children()[0].set_markup(text)
162- item.connect('activate', self.callback)
163+ if self.callback: # for tweets posted by the user, there is not callback to be set
164+ item.connect('activate', self.callback)
165 self.append(item)
166 # add a separator if mail is not last in list
167 if self.messages.index(message) != len(self.messages) - 1:

Subscribers

People subscribed via source and target branches