From 6bde20333f358f1b672011e3db767ecf391f28b6 Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 16 Apr 2010 17:32:17 -0400 Subject: [PATCH] Added Verified Account label to verified accounts --- default.glade | 26 +++++++++++++++++++++++++ mytwitter.py | 17 ++++++++++++++-- python-twitter-GetUser_verified.patch | 28 +++++++++++++++++++++++++++ twitterwidgets.py | 7 ++++++- 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 python-twitter-GetUser_verified.patch diff --git a/default.glade b/default.glade index 919e554..b6fa3db 100644 --- a/default.glade +++ b/default.glade @@ -261,6 +261,32 @@ False + + + + True + Verified Account + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + GTK_PACK_END + + 0 diff --git a/mytwitter.py b/mytwitter.py index 9bf8746..bb175b3 100755 --- a/mytwitter.py +++ b/mytwitter.py @@ -50,6 +50,7 @@ class MyTwitter(): self.search_entry = self.widget_tree.get_widget('search_entry') self.following_button = self.widget_tree.get_widget('following_button') self.at_button = self.widget_tree.get_widget('at_button') + self.verified_label = self.widget_tree.get_widget('verified_label') self.context_id = self.status_bar.get_context_id('message') @@ -196,10 +197,12 @@ class MyTwitter(): is_user = False following = False + verified = False if re.match('user:', name): is_user = True following = self.check_following(name) - new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following) + verified = self.check_verified(name) + new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following, verified=verified) self.tweet_notebook.append_page_menu(new_pane, new_pane.get_tab_label(), gtk.Label(name)) new_pane.get_tab_label().connect('close-clicked', self.remove_view_callback, name) new_pane.connect('tweet-reply', self.on_reply) @@ -230,6 +233,10 @@ class MyTwitter(): self.at_button.show() else: self.at_button.hide() + if pane.get_verified(): + self.verified_label.show() + else: + self.verified_label.hide() def on_search(self, event): @@ -263,6 +270,13 @@ class MyTwitter(): return relationship.source.following + # Name is the name of a pane, with the 'user: ' in place + def check_verified(self, name): + screen_name = re.sub('user: ', '', name) + user = self.api.GetUser(screen_name) + return user.verified + + def update_follow_button(self, pane): if not pane.get_is_user(): self.following_button.set_label('') @@ -358,7 +372,6 @@ class User(): self.name = None - # main parser = optparse.OptionParser() parser.add_option('-c' ,'--config', dest="filename", default="~/.mytwitter") diff --git a/python-twitter-GetUser_verified.patch b/python-twitter-GetUser_verified.patch new file mode 100644 index 0000000..f7711cf --- /dev/null +++ b/python-twitter-GetUser_verified.patch @@ -0,0 +1,28 @@ +diff -r 51ac454d5d89 twitter.py +--- a/twitter.py Thu Dec 31 15:06:42 2009 -0500 ++++ b/twitter.py Fri Apr 16 17:30:32 2010 -0400 +@@ -221,6 +221,7 @@ + _CopyProperty(data, user, 'profile_link_color', 'profile.link_color') + _CopyProperty(data, user, 'profile_text_color', 'profile.text_color') + _CopyProperty(data, user, 'protected') ++ _CopyProperty(data, user, 'verified') + _CopyProperty(data, user, 'utc_offset') + _CopyProperty(data, user, 'time_zone') + _CopyProperty(data, user, 'url') +diff -r 51ac454d5d89 twitter_pb2.py +--- a/twitter_pb2.py Thu Dec 31 15:06:42 2009 -0500 ++++ b/twitter_pb2.py Fri Apr 16 17:30:32 2010 -0400 +@@ -253,6 +253,13 @@ + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), ++ descriptor.FieldDescriptor( ++ name='verified', full_name='twitter.User.verified', index=18, ++ number=19, type=8, cpp_type=7, label=1, ++ default_value=False, ++ message_type=None, enum_type=None, containing_type=None, ++ is_extension=False, extension_scope=None, ++ options=None), + ], + extensions=[ + ], diff --git a/twitterwidgets.py b/twitterwidgets.py index c45e342..da849dc 100644 --- a/twitterwidgets.py +++ b/twitterwidgets.py @@ -13,7 +13,7 @@ class TweetPane(gtk.ScrolledWindow): It also gets some data from its parent, including num_entries ''' - def __init__(self, list_name, num_entries=20, single_tweet=None, is_user=False, following=False): + def __init__(self, list_name, num_entries=20, single_tweet=None, is_user=False, following=False, verified=False): gtk.ScrolledWindow.__init__(self) self.updated_once = False @@ -27,6 +27,7 @@ class TweetPane(gtk.ScrolledWindow): self.is_user = is_user self.following = following + self.verified = verified self.tab_label = CloseTabLabel(self.list_name) @@ -148,6 +149,10 @@ class TweetPane(gtk.ScrolledWindow): return self.following + def get_verified(self): + return self.verified + + def set_following(self, following): self.following = following