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: 253
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: 55 lines (+19/-7)
1 file modified
Twitter/Twitter (+19/-7)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter
Reviewer Review Type Date Requested Status
Matthieu Baerts Approve
Review via email: mp+100676@code.launchpad.net

Description of the change

Twitter: Informing the user if the tweet is longer than 140 characters

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

It works fine :)
Thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Twitter/Twitter'
2--- Twitter/Twitter 2012-03-22 14:32:26 +0000
3+++ Twitter/Twitter 2012-04-03 19:39:20 +0000
4@@ -332,16 +332,23 @@
5
6 def ask_for_direct_message_reply(self, destinatary):
7 dialog = {'buttons':'ok;cancel'}
8- widget = {'widget-type':'text-entry', 'nb-chars':141} # 140 characters max, a direct message
9+ widget = {'widget-type':'text-entry', 'nb-chars':self.tweet_length + 1} # 140 characters max, a direct message
10 self.show_popup_message((_("%s, write a reply to %s")) % (self.user.screen_name, destinatary), dialog, widget)
11 self.dialog_type = self.responding_sending_direct_message_reply
12 self.replying_direct_message_to = destinatary
13
14- def ask_for_tweet(self):
15+ # Opens the dialog to be filled with the tweet and also
16+ # informs about tweet longer than 140 characters
17+ def ask_for_tweet(self, default="", warning=False):
18 dialog = {'buttons':'ok;cancel'}
19- widget = {'widget-type':'text-entry', 'nb-chars':141} # 140 characters max, a tweet :)
20- self.show_popup_message((_("%s, send a tweet")) % self.user.screen_name, dialog, widget)
21- self.dialog_type = self.responding_tweet
22+ widget = {'widget-type':'text-entry', 'nb-chars':self.tweet_length + 1, 'initial-value':default} # 140 characters max, a tweet :)
23+ if not warning:
24+ message = _("%s, send a tweet") % self.user.screen_name
25+ self.dialog_type = self.responding_tweet
26+ else: # user entered more than 140 characters
27+ message = _("Your tweet has more than %d characters, please make it shorter") % self.tweet_length
28+ self.dialog_type = self.responding_tweet
29+ self.show_popup_message(message, dialog, widget)
30
31 def ask_for_retweet(self, tweet_id):
32 dialog = {'buttons':'ok;cancel'}
33@@ -480,6 +487,8 @@
34 self.tweets_menu_id = 3000
35 self.user_timeline_menu_id = 4000
36
37+ self.tweet_length = 140
38+
39 self.tweet_stream = Queue.Queue()
40 self.message_stream = Queue.Queue()
41
42@@ -527,8 +536,11 @@
43 else:
44 logm("A problem has occurred while getting access to the API")
45 elif self.dialog_type == self.responding_tweet:
46- logp("Sending a tweet '%s'" % content)
47- self.api.tweet(content)
48+ if len(content) > self.tweet_length:
49+ self.ask_for_tweet(content, True)
50+ else:
51+ logp("Sending a tweet '%s'" % content)
52+ self.api.tweet(content)
53 elif self.dialog_type == self.responding_sending_direct_message_reply:
54 logp("Sending a direct message '%s'" % content)
55 self.api.new_direct_message(content, self.replying_direct_message_to)

Subscribers

People subscribed via source and target branches