Added right-click labels to the pane tabs, and a follow/unfollow button. It still seems to work inconsistently.

This commit is contained in:
Anna
2010-04-14 14:24:40 -04:00
parent d572d8b8e9
commit 5f75520380
3 changed files with 55 additions and 7 deletions

View File

@ -48,6 +48,7 @@ class MyTwitter():
self.update_count = self.widget_tree.get_widget('update_count')
self.status_bar = self.widget_tree.get_widget('status_bar')
self.search_entry = self.widget_tree.get_widget('search_entry')
self.following_button = self.widget_tree.get_widget('following_button')
self.context_id = self.status_bar.get_context_id('message')
@ -184,10 +185,9 @@ class MyTwitter():
following = False
if re.match('user:', name):
is_user = True
relationship = self.api.ShowFriendships(source_screen_name=self.username, target_screen_name=re.sub('user: ', '', name))
following = relationship.target.following
following = self.check_following(name)
new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following)
self.tweet_notebook.append_page(new_pane, new_pane.get_tab_label())
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, name)
new_pane.connect('tweet-reply', self.on_reply)
new_pane.connect('tweet-retweet', self.on_retweet)
@ -210,6 +210,7 @@ class MyTwitter():
def on_tab_change(self, event, page, page_num):
pane = self.tweet_notebook.get_nth_page(page_num)
pane.set_tweets_read()
self.update_follow_button(pane)
def on_search(self, event):
@ -228,6 +229,40 @@ class MyTwitter():
self.status_bar.pop(self.context_id)
self.status_bar.push(self.context_id, text)
def on_following_button_clicked(self, event):
current_pane = self.tweet_notebook.get_nth_page(self.tweet_notebook.get_current_page())
user_name = re.sub('^user: ', '', current_pane.get_list_name())
if current_pane.get_following():
self.api.DestroyFriendship(user_name)
current_pane.set_following(self.check_following(user_name))
else:
self.api.CreateFriendship(user_name)
current_pane.set_following(self.check_following(user_name))
self.update_follow_button(current_pane)
# Name is the name of a pane, with the 'user: ' in place
def check_following(self, name):
print 'debug check_following(' + name + ')'
screen_name = re.sub('user: ', '', name)
relationship = self.api.ShowFriendships(target_screen_name=screen_name)
return relationship.source.following
def update_follow_button(self, pane):
if not pane.get_is_user():
self.following_button.set_label('')
self.following_button.hide()
elif pane.get_following():
self.following_button.set_label('Unfollow')
self.following_button.show()
else:
self.following_button.set_label('Follow')
self.following_button.show()
### end class MyTwitter