diff --git a/mytwitter.py b/mytwitter.py index 4a4777c..b2a0908 100755 --- a/mytwitter.py +++ b/mytwitter.py @@ -85,7 +85,9 @@ class MyTwitter(): pane = self.tweet_notebook.get_nth_page(i) list_name = pane.get_list_name() - if list_name is None or list_name == 'Home': + if pane.is_single_tweet(): + continue + elif list_name is None or list_name == 'Home': statuses = self.api.GetHomeTimeline(count=self.num_entries) elif list_name == '@' + self.username: statuses = self.api.GetMentions(count=self.num_entries) @@ -213,9 +215,11 @@ class TweetPane(gtk.ScrolledWindow): It also gets some data from its parent, including num_entries ''' - def __init__(self, list_name, mytwitter): + def __init__(self, list_name, mytwitter, single_tweet=None): gtk.ScrolledWindow.__init__(self) + self.single_tweet = single_tweet + self.list_name = list_name self.mytwitter = mytwitter @@ -238,7 +242,10 @@ class TweetPane(gtk.ScrolledWindow): viewport = gtk.Viewport() # Build us some labels... - for i in range(0, self.mytwitter.num_entries): + num_entries = self.mytwitter.num_entries + if self.is_single_tweet(): + num_entries = 1 + for i in range(0, num_entries): self.tweets.append(TweetBox()) tweet_box.pack_start(self.tweets[i]) self.tweets[i].connect('reply', self.mytwitter.on_reply) @@ -256,6 +263,9 @@ class TweetPane(gtk.ScrolledWindow): self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.show_all() + if self.is_single_tweet(): + self.update_window(None) + def update_window(self, raw_statuses, using_results=False): if using_results: @@ -263,6 +273,10 @@ class TweetPane(gtk.ScrolledWindow): else: statuses = raw_statuses + if (self.is_single_tweet()): + statuses = [] + statuses.append(self.mytwitter.api.GetStatus(self.single_tweet)) + # If this is our first load of this list, don't treat anything as new! if self.last_tweet_read is None: self.last_tweet_read = statuses[0].id @@ -310,6 +324,11 @@ class TweetPane(gtk.ScrolledWindow): def get_tab_label(self): return self.tab_label + + def is_single_tweet(self): + return self.single_tweet is not None + + # 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?