Added some logic to TweetPane to track whether the pane is displaying a user's feed, and if so whether we are currently following that user.
This commit is contained in:
parent
bf23f6e3fc
commit
d572d8b8e9
10
mytwitter.py
10
mytwitter.py
|
@ -179,10 +179,14 @@ class MyTwitter():
|
|||
return
|
||||
|
||||
|
||||
# This code modified from create_custom_tab in:
|
||||
# http://www.daa.com.au/pipermail/pygtk/2006-April/012216.html
|
||||
def add_to_notebook(self, name, single_tweet=None):
|
||||
new_pane = TweetPane(name, self.num_entries, single_tweet)
|
||||
is_user = False
|
||||
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
|
||||
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())
|
||||
new_pane.get_tab_label().connect('close-clicked', self.remove_view, name)
|
||||
new_pane.connect('tweet-reply', self.on_reply)
|
||||
|
|
|
@ -13,14 +13,20 @@ 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):
|
||||
def __init__(self, list_name, num_entries=20, single_tweet=None, is_user=False, following=False):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
|
||||
self.updated_once = False
|
||||
|
||||
self.list_name = list_name
|
||||
self.single_tweet = single_tweet
|
||||
|
||||
self.list_name = list_name
|
||||
self.num_entries = num_entries
|
||||
if self.single_tweet is not None:
|
||||
self.num_entries = 1
|
||||
|
||||
self.is_user = is_user
|
||||
self.following = following
|
||||
|
||||
self.tab_label = CloseTabLabel(self.list_name)
|
||||
|
||||
|
@ -31,10 +37,6 @@ class TweetPane(gtk.ScrolledWindow):
|
|||
|
||||
self.tweets = []
|
||||
|
||||
self.num_entries = num_entries
|
||||
if self.single_tweet is not None:
|
||||
self.num_entries = 1
|
||||
|
||||
self.init_widgets()
|
||||
|
||||
|
||||
|
@ -142,6 +144,17 @@ class TweetPane(gtk.ScrolledWindow):
|
|||
self.emit('tweet-in-reply-to', data)
|
||||
|
||||
|
||||
def get_following(self):
|
||||
return following
|
||||
|
||||
|
||||
def set_following(self, following):
|
||||
self.following = following
|
||||
|
||||
|
||||
def is_user(self):
|
||||
return is_user
|
||||
|
||||
# To keep things simple elsewhere and improve code reuse
|
||||
# we'll build a list of home-cooked Status objects out of results.
|
||||
# Why is this even necessary?
|
||||
|
@ -360,7 +373,10 @@ class CloseTabLabel(gtk.EventBox):
|
|||
self.init_widgets(name)
|
||||
|
||||
|
||||
# This code is still heinous, but at least it is
|
||||
# This code modified from create_custom_tab in:
|
||||
# http://www.daa.com.au/pipermail/pygtk/2006-April/012216.html
|
||||
#
|
||||
# My version of this code is a little heinous, but at least it is
|
||||
# isolated to its own class
|
||||
def init_widgets(self, name):
|
||||
#create a custom tab for notebook containing a
|
||||
|
@ -404,7 +420,6 @@ class CloseTabLabel(gtk.EventBox):
|
|||
def on_button_press(self, event, direction):
|
||||
self.emit('label-clicked')
|
||||
|
||||
|
||||
### end class CloseTabLabel
|
||||
|
||||
# signals for CloseTabLabel
|
||||
|
|
Reference in New Issue
Block a user