← Back to team overview

cairo-dock-team team mailing list archive

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

 

Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter 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/Twitter/+merge/98761

Added user timeline.
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter/+merge/98761
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter into lp:cairo-dock-plug-ins-extras.
=== modified file 'Twitter/ChangeLog'
--- Twitter/ChangeLog	2012-03-19 00:02:27 +0000
+++ Twitter/ChangeLog	2012-03-22 00:19:17 +0000
@@ -1,3 +1,4 @@
+0.2.1: (March/22/2012): Added user timeline.
 0.2: (March/19/2012): Possible to retweet tweets. Tweets being shown with standard menu.
 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.
 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.

=== modified file 'Twitter/Twitter'
--- Twitter/Twitter	2012-03-21 00:02:15 +0000
+++ Twitter/Twitter	2012-03-22 00:19:17 +0000
@@ -223,17 +223,25 @@
         self.refresh_emblem_counter()
         self.play_alert_sound()
 
-  # TODO: Use the Menu class
   def show_user_timeline(self):
     self.inform_start_of_waiting_process()
+    
     timeline = self.api.user_timeline()
+    print timeline[0]
     if len(timeline) > 0:
-      message = "".join (["[<b>%s</b>] %s\n" % (status['user']['screen_name'], status['text']) for status in timeline])
+      ut_menu = menu.Menu(self.icon)                                                        # callback not set since there is no action when clicking ...
+      for status in timeline:                                                               # ... on the menu generated from this list
+        text = status['text']
+        sender = status['user']['name']
+        uid = status['id_str']
+        ut_menu.add(Tweet(text, sender, uid))
+      ut_menu.pop_up()
     else:
       message = _("Oh, dear, your timeline is empty :-(")
-    dialog = {'use-markup':True}
+      dialog = {'use-markup':True}
+      self.show_popup_message(message, dialog)
+
     self.inform_end_of_waiting_process()
-    self.show_popup_message(message, dialog)    
 
   def show_new_tweets(self):
     self.inform_start_of_waiting_process()
@@ -413,7 +421,7 @@
         'type'  : CDApplet.MENU_ENTRY,
         'label' : label,
         'id'    : self.direct_messages_menu_id,
-        'icon'  : os.path.abspath("./data/received.png")
+        'icon'  : os.path.abspath("./data/message.png")
     })
     self.icon.AddMenuItems(direct_messages_menu)
 
@@ -437,9 +445,20 @@
         'type'  : CDApplet.MENU_ENTRY,
         'label' : label,
         'id'    : self.tweets_menu_id,
-        'icon'  : os.path.abspath("./data/new.png")
+        'icon'  : os.path.abspath("./data/tweet.png")
     })
     self.icon.AddMenuItems(tweets_menu)
+    
+  def build_user_timeline_menu(self):
+    user_timeline_menu = []
+    
+    user_timeline_menu.append ({
+        'type'  : CDApplet.MENU_ENTRY,
+        'label' : _("My tweets"),
+        'id'    : self.user_timeline_menu_id,
+        'icon'  : os.path.abspath("./data/tweet.png")
+    })
+    self.icon.AddMenuItems(user_timeline_menu)
 
   def __init__(self):
     self.user = User()
@@ -459,6 +478,7 @@
     self.direct_messages_menu_id  = 1000
     self.credentials_menu_id      = 2000
     self.tweets_menu_id           = 3000
+    self.user_timeline_menu_id    = 4000
     
     self.tweet_stream   = Queue.Queue()
     self.message_stream = Queue.Queue()
@@ -524,6 +544,7 @@
 
   def on_build_menu(self):
     self.build_credentials_menu()
+    self.build_user_timeline_menu()
     self.build_direct_messages_menu()
     self.build_tweets_menu()
 
@@ -540,6 +561,8 @@
         self.show_home_timeline()                                                     # show the last 20 tweets on the home timeline
       else:                                                                           # new tweets on the stream
         self.show_new_tweets()                                                        # show new tweets
+    elif selected_menu == self.user_timeline_menu_id:
+      self.show_user_timeline()
 
 if __name__ == '__main__':
   Applet().run()

=== modified file 'Twitter/Twitter.conf'
--- Twitter/Twitter.conf	2012-03-21 00:02:15 +0000
+++ Twitter/Twitter.conf	2012-03-22 00:19:17 +0000
@@ -1,4 +1,4 @@
-#!en;0.2
+#!en;0.2.1
 
 #[gtk-about]
 [Icon]

=== modified file 'Twitter/auto-load.conf'
--- Twitter/auto-load.conf	2012-03-19 00:02:27 +0000
+++ Twitter/auto-load.conf	2012-03-22 00:19:17 +0000
@@ -10,7 +10,7 @@
 category = 3
 
 # 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.2
+version = 0.2.1
 
 # Whether the applet can be instanciated several times or not.
 multi-instance = true

=== added file 'Twitter/data/message.png'
Binary 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
=== added file 'Twitter/data/message_small.png'
Binary 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
=== removed file 'Twitter/data/new.png'
Binary 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
=== removed file 'Twitter/data/received.png'
Binary 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
=== removed file 'Twitter/data/received_menu.png'
Binary 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
=== added file 'Twitter/data/tweet.png'
Binary 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
=== modified file 'Twitter/menu.py'
--- Twitter/menu.py	2012-03-19 00:02:27 +0000
+++ Twitter/menu.py	2012-03-22 00:19:17 +0000
@@ -10,7 +10,7 @@
 
 class Menu(gtk.Menu):
 
-  def __init__(self, icon, callback):
+  def __init__(self, icon, callback=None):
     gtk.Menu.__init__(self)
     
     self.messages = []
@@ -22,16 +22,17 @@
   
   def pop_up(self):
     for message in self.messages:
-      text = "<b>%s</b>\n%s" % (message.sender, message.text)
       item = gtk.ImageMenuItem()
       # the true label is set after with set_markup()
       if isinstance(message, DirectMessage):
         item.set_label(message.sender)                                                # used to track who sent the message in order to reply it.
       elif isinstance(message, Tweet):
         item.set_label(message.uid)                                                   # used to retweet the tweet
-      item.set_image(gtk.image_new_from_file(os.path.abspath("./data/received_menu.png")))
+      item.set_image(gtk.image_new_from_file(os.path.abspath("./data/message_small.png")))
+      text = "<b>%s</b>\n%s" % (message.sender, message.text)
       item.get_children()[0].set_markup(text)
-      item.connect('activate', self.callback)
+      if self.callback:                                                               # for tweets posted by the user, there is not callback to be set
+        item.connect('activate', self.callback)
       self.append(item)
       # add a separator if mail is not last in list
       if self.messages.index(message) != len(self.messages) - 1:


Follow ups