Added framework for loading a sigle tweet into a pane. Nothing currently employs this framework, however
This commit is contained in:
parent
dd10342781
commit
7d22a9e4ad
25
mytwitter.py
25
mytwitter.py
|
@ -85,7 +85,9 @@ class MyTwitter():
|
||||||
pane = self.tweet_notebook.get_nth_page(i)
|
pane = self.tweet_notebook.get_nth_page(i)
|
||||||
list_name = pane.get_list_name()
|
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)
|
statuses = self.api.GetHomeTimeline(count=self.num_entries)
|
||||||
elif list_name == '@' + self.username:
|
elif list_name == '@' + self.username:
|
||||||
statuses = self.api.GetMentions(count=self.num_entries)
|
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
|
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)
|
gtk.ScrolledWindow.__init__(self)
|
||||||
|
|
||||||
|
self.single_tweet = single_tweet
|
||||||
|
|
||||||
self.list_name = list_name
|
self.list_name = list_name
|
||||||
|
|
||||||
self.mytwitter = mytwitter
|
self.mytwitter = mytwitter
|
||||||
|
@ -238,7 +242,10 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
viewport = gtk.Viewport()
|
viewport = gtk.Viewport()
|
||||||
|
|
||||||
# Build us some labels...
|
# 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())
|
self.tweets.append(TweetBox())
|
||||||
tweet_box.pack_start(self.tweets[i])
|
tweet_box.pack_start(self.tweets[i])
|
||||||
self.tweets[i].connect('reply', self.mytwitter.on_reply)
|
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.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
if self.is_single_tweet():
|
||||||
|
self.update_window(None)
|
||||||
|
|
||||||
|
|
||||||
def update_window(self, raw_statuses, using_results=False):
|
def update_window(self, raw_statuses, using_results=False):
|
||||||
if using_results:
|
if using_results:
|
||||||
|
@ -263,6 +273,10 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
else:
|
else:
|
||||||
statuses = raw_statuses
|
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 this is our first load of this list, don't treat anything as new!
|
||||||
if self.last_tweet_read is None:
|
if self.last_tweet_read is None:
|
||||||
self.last_tweet_read = statuses[0].id
|
self.last_tweet_read = statuses[0].id
|
||||||
|
@ -310,6 +324,11 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
def get_tab_label(self):
|
def get_tab_label(self):
|
||||||
return self.tab_label
|
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
|
# To keep things simple elsewhere and improve code reuse
|
||||||
# we'll build a list of home-cooked Status objects out of results.
|
# we'll build a list of home-cooked Status objects out of results.
|
||||||
# Why is this even necessary?
|
# Why is this even necessary?
|
||||||
|
|
Reference in New Issue
Block a user