Implemented lists in View menu instead of a ComboBoxEntry

This commit is contained in:
Anna 2010-04-12 14:50:04 -04:00
parent 72d17a5de1
commit 6cc19e1087
2 changed files with 38 additions and 40 deletions

View File

@ -79,10 +79,15 @@
</child> </child>
<child> <child>
<widget class="GtkMenuItem" id="view_menu"> <widget class="GtkMenuItem" id="view_menu_item">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_View</property> <property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="view_menu">
</widget>
</child>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -163,7 +168,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="update_window_callback" last_modification_time="Thu, 08 Apr 2010 21:18:02 GMT"/> <signal name="clicked" handler="update_windows_callback" last_modification_time="Mon, 12 Apr 2010 18:33:51 GMT"/>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -173,19 +178,7 @@
</child> </child>
<child> <child>
<widget class="GtkComboBoxEntry" id="list_select"> <placeholder/>
<property name="visible">True</property>
<property name="items" translatable="yes">Home</property>
<property name="add_tearoffs">False</property>
<property name="has_frame">True</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_list_select_changed" last_modification_time="Thu, 08 Apr 2010 20:38:10 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child> </child>
<child> <child>

View File

@ -29,8 +29,6 @@ class MyTwitter():
self.tweets = [] self.tweets = []
self.list = None self.list = None
self.reply_id = None self.reply_id = None
self.last_tweet_read = None
self.latest_tweet = None
# Authenticate with twitter, set up the API object # Authenticate with twitter, set up the API object
self.api = twitter.Api(username=self.username, password=self.password) self.api = twitter.Api(username=self.username, password=self.password)
@ -47,7 +45,6 @@ class MyTwitter():
def init_widgets(self): def init_widgets(self):
# Get widgets from glade # Get widgets from glade
self.list_select = self.widget_tree.get_widget('list_select')
self.tweet_notebook = self.widget_tree.get_widget('tweet_notebook') self.tweet_notebook = self.widget_tree.get_widget('tweet_notebook')
self.view_menu = self.widget_tree.get_widget('view_menu') self.view_menu = self.widget_tree.get_widget('view_menu')
self.update_entry = self.widget_tree.get_widget('update_entry') self.update_entry = self.widget_tree.get_widget('update_entry')
@ -62,35 +59,41 @@ class MyTwitter():
self.tweet_notebook.append_page(self.tweet_panes[0]) self.tweet_notebook.append_page(self.tweet_panes[0])
self.tweet_notebook.set_tab_label_text(self.tweet_panes[0], 'Home') self.tweet_notebook.set_tab_label_text(self.tweet_panes[0], 'Home')
# Fill the ComboBox with entries # Put Home, @user, and lists in the View menu...
self.list_select.append_text('@' + self.username)
lists = self.api.GetUserLists() lists = self.api.GetUserLists()
list_names = [] list_names = []
# two passes to sort this nicely
for l in lists['lists']: for l in lists['lists']:
list_names.append(l.name) list_names.append(l.name)
list_names.sort() list_names.sort()
list_names.insert(0, 'Home')
list_names.insert(1, '@' + self.username)
for l in list_names: for l in list_names:
self.list_select.append_text(l) menu_item = gtk.MenuItem(l)
self.view_menu.append(menu_item)
menu_item.connect('activate', self.on_view_selected, l)
menu_item.show()
# Timer to update periodically # Timer to update periodically
self.update_window() self.update_windows()
gobject.timeout_add(self.refresh_time * 1000, self.update_window) gobject.timeout_add(self.refresh_time * 1000, self.update_windows)
def update_window(self): def update_windows(self):
if self.list is None or self.list == 'Home': for pane in self.tweet_panes:
list_name = pane.get_list_name()
if 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 self.list == '@' + self.username: elif list_name == '@' + self.username:
statuses = self.api.GetMentions(count=self.num_entries) statuses = self.api.GetMentions(count=self.num_entries)
else: else:
statuses = self.api.GetListStatuses(self.list, per_page=self.num_entries) statuses = self.api.GetListStatuses(list_name, per_page=self.num_entries)
self.tweet_panes[0].update_window(statuses) pane.update_window(statuses)
def update_window_callback(self, widget): def update_windows_callback(self, widget):
self.update_window() self.update_windows()
def update_status(self): def update_status(self):
@ -124,12 +127,6 @@ class MyTwitter():
print "STUB: help->about not yet implemented" print "STUB: help->about not yet implemented"
def on_list_select_changed(self, widget):
self.list = widget.get_active_text()
self.last_tweet_read = None
self.update_window()
def on_reply(self, widget): def on_reply(self, widget):
self.update_entry.set_text('@' + widget.screen_name + ' ') self.update_entry.set_text('@' + widget.screen_name + ' ')
self.reply_id = widget.id self.reply_id = widget.id
@ -148,6 +145,10 @@ class MyTwitter():
def set_tweets_read_callback(self, event): def set_tweets_read_callback(self, event):
self.set_tweets_read() self.set_tweets_read()
def on_view_selected(self, event, name):
print 'debug: on_view_selected(): ' + name
### end class MyTwitter ### end class MyTwitter
@ -217,6 +218,10 @@ class TweetPane(gtk.ScrolledWindow):
if num_new_tweets > 0: if num_new_tweets > 0:
pass # fixme: change the label here, or maybe in mytwitter? pass # fixme: change the label here, or maybe in mytwitter?
def get_list_name(self):
return self.list_name
### end class TweetPane ### end class TweetPane