Moved active account choice to a menu, and indicate it with a label beside the tweet update field. Temporarily broke ability to actually change accounts, though
This commit is contained in:
parent
e4ff126d12
commit
5b74eed1e0
|
@ -61,7 +61,7 @@
|
|||
<child>
|
||||
<widget class="GtkMenuItem" id="view_menu_item">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_View</property>
|
||||
<property name="label" translatable="yes">_Views</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
||||
<child>
|
||||
|
@ -71,6 +71,19 @@
|
|||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="accounts_menu_item">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Accounts</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenu" id="accounts_menu">
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem10">
|
||||
<property name="visible">True</property>
|
||||
|
@ -299,32 +312,15 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<widget class="GtkHBox" id="update_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBoxEntry" id="account_select">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">null</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_account_changed" last_modification_time="Tue, 20 Apr 2010 18:28:53 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="account_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Active Account:</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
|
@ -340,25 +336,11 @@
|
|||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">2</property>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">1</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="update_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="update_entry">
|
||||
|
|
48
mytwitter.py
48
mytwitter.py
|
@ -91,6 +91,7 @@ class MyTwitter():
|
|||
self.window = self.widget_tree.get_widget('window')
|
||||
self.tweet_notebook = self.widget_tree.get_widget('tweet_notebook')
|
||||
self.view_menu = self.widget_tree.get_widget('view_menu')
|
||||
self.accounts_menu = self.widget_tree.get_widget('accounts_menu')
|
||||
self.update_entry = self.widget_tree.get_widget('update_entry')
|
||||
self.update_count = self.widget_tree.get_widget('update_count')
|
||||
self.status_bar = self.widget_tree.get_widget('status_bar')
|
||||
|
@ -98,7 +99,7 @@ class MyTwitter():
|
|||
self.following_button = self.widget_tree.get_widget('following_button')
|
||||
self.at_button = self.widget_tree.get_widget('at_button')
|
||||
self.verified_label = self.widget_tree.get_widget('verified_label')
|
||||
self.account_select = self.widget_tree.get_widget('account_select')
|
||||
self.account_label = self.widget_tree.get_widget('account_label')
|
||||
|
||||
|
||||
def init_widgets(self):
|
||||
|
@ -108,14 +109,30 @@ class MyTwitter():
|
|||
|
||||
self.context_id = self.status_bar.get_context_id('message')
|
||||
|
||||
# Add the accounts to the accounts menu
|
||||
# Setup the new sub-menu
|
||||
first_item = None
|
||||
keys =self.accounts.keys()
|
||||
keys.sort()
|
||||
for name in keys:
|
||||
print 'adding: ' + name
|
||||
menu_item = gtk.RadioMenuItem(first_item, label=name, use_underline=False)
|
||||
menu_item.set_draw_as_radio(False)
|
||||
if name == self.username:
|
||||
menu_item.set_active(True)
|
||||
|
||||
if first_item is None:
|
||||
first_item = menu_item
|
||||
|
||||
menu_item.connect('group-changed', self.on_account_changed, name)
|
||||
self.accounts_menu.append(menu_item)
|
||||
menu_item.show()
|
||||
|
||||
# Set the account label
|
||||
self.update_account_label()
|
||||
|
||||
# Manual tweaks to the glade UI, to overcome its limitations
|
||||
self.tweet_notebook.remove_page(0)
|
||||
self.account_select.remove_text(0)
|
||||
|
||||
# Add entries to the account select box, set the default entry
|
||||
for username in self.accounts.keys():
|
||||
self.account_select.append_text(username)
|
||||
self.account_select.set_active(0)
|
||||
|
||||
# Add the tabs from last session to the notebook
|
||||
page_num = self.db['active_page']
|
||||
|
@ -129,6 +146,10 @@ class MyTwitter():
|
|||
gobject.timeout_add(self.refresh_time * 1000, self.update_windows)
|
||||
|
||||
|
||||
def update_account_label(self):
|
||||
self.account_label.set_text(self.username + ': ')
|
||||
|
||||
|
||||
# Spawns a thread for each pane, which updates that pane.
|
||||
def update_windows(self):
|
||||
for i in range(0, self.tweet_notebook.get_n_pages()):
|
||||
|
@ -480,16 +501,17 @@ class MyTwitter():
|
|||
self.remove_view(current_pane.get_list_name(), current_pane.get_single_tweet(), current_pane.get_conversation())
|
||||
|
||||
|
||||
def on_account_changed(self, widget):
|
||||
new_user = self.account_select.get_active_text()
|
||||
if self.accounts.has_key(new_user):
|
||||
self.username = new_user
|
||||
def on_account_changed(self, widget, new_account):
|
||||
print 'debug: on_account_changed()'
|
||||
if self.accounts.has_key(new_account):
|
||||
self.username = new_account
|
||||
self.api = self.accounts[self.username]
|
||||
self.update_account_label()
|
||||
|
||||
|
||||
def on_lists_ready(self, widget, username, list_names):
|
||||
# Setup the new sub-menu
|
||||
outer_menu_item = gtk.MenuItem(username)
|
||||
outer_menu_item = gtk.MenuItem(username, False)
|
||||
self.view_menu.append(outer_menu_item)
|
||||
new_menu = gtk.Menu()
|
||||
outer_menu_item.set_submenu(new_menu)
|
||||
|
@ -501,7 +523,7 @@ class MyTwitter():
|
|||
|
||||
# Add the items to the submenu, connect handler
|
||||
for l in list_names:
|
||||
menu_item = gtk.MenuItem(l)
|
||||
menu_item = gtk.MenuItem(l, False)
|
||||
new_menu.append(menu_item)
|
||||
menu_item.connect('activate', self.on_view_selected, username, l)
|
||||
menu_item.show()
|
||||
|
|
Reference in New Issue
Block a user