New posts now become 'read' once their tab is activated, or clicked inside of, etc...

This commit is contained in:
Anna 2010-04-12 17:12:11 -04:00
parent 2f57d64901
commit 847629f2b6

View File

@ -51,6 +51,9 @@ class MyTwitter():
self.tweet_notebook.remove_page(0) # kill the page that glade makes us have self.tweet_notebook.remove_page(0) # kill the page that glade makes us have
# When we change tabs, any unread tweets in it become read
self.tweet_notebook.connect('switch_page', self.on_tab_change)
# Add the Home tab to the notebook # Add the Home tab to the notebook
home_pane = TweetPane('Home', self) home_pane = TweetPane('Home', self)
self.add_to_notebook(home_pane, 'Home') self.add_to_notebook(home_pane, 'Home')
@ -75,6 +78,7 @@ class MyTwitter():
def update_windows(self): def update_windows(self):
print 'debug: update_windows()'
for i in range(0, self.tweet_notebook.get_n_pages()): for i in range(0, self.tweet_notebook.get_n_pages()):
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()
@ -175,6 +179,13 @@ class MyTwitter():
self.tweet_notebook.set_current_page(-1) # switch to the new pane self.tweet_notebook.set_current_page(-1) # switch to the new pane
def on_tab_change(self, event, page, page_num):
pane = self.tweet_notebook.get_nth_page(page_num)
tab_label = self.tweet_notebook.get_tab_label(pane)
pane.set_tweets_read()
tab_label.set_label_text(pane.get_list_name())
### end class MyTwitter ### end class MyTwitter
@ -218,7 +229,11 @@ class TweetPane(gtk.ScrolledWindow):
viewport.add(tweet_box) viewport.add(tweet_box)
self.connect('focus', self.set_tweets_read) # Several different actions should mark the tweets as 'read'
self.connect('focus', self.set_tweets_read_callback)
viewport.connect('button_press_event', self.set_tweets_read_callback)
self.connect('scroll-event', self.set_tweets_read_callback)
self.connect('scroll-child', self.set_tweets_read_callback)
self.add(viewport) self.add(viewport)
self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
@ -251,12 +266,11 @@ class TweetPane(gtk.ScrolledWindow):
def set_tweets_read(self): def set_tweets_read(self):
print 'debug: set_tweets_read()'
self.last_tweet_read = self.latest_tweet self.last_tweet_read = self.latest_tweet
self.num_new_tweets = 0 self.num_new_tweets = 0
def set_tweets_read_callback(self, event): def set_tweets_read_callback(self, event, arg1=None, arg2=None):
self.set_tweets_read() self.set_tweets_read()