Made tabs reorderable, and added code to persist the ordering changes
This commit is contained in:
parent
5220961620
commit
5c7798398b
3 changed files with 18 additions and 5 deletions
18
mytwitter.py
18
mytwitter.py
|
@ -65,7 +65,8 @@ class MyTwitter():
|
|||
|
||||
self.context_id = self.status_bar.get_context_id('message')
|
||||
|
||||
self.tweet_notebook.remove_page(0) # kill the page that glade makes us have
|
||||
# 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
|
||||
|
@ -73,9 +74,6 @@ class MyTwitter():
|
|||
self.account_select.append_text(username)
|
||||
self.account_select.set_active(0)
|
||||
|
||||
# When we change tabs, any unread tweets in it become read
|
||||
self.tweet_notebook.connect('switch_page', self.on_tab_change)
|
||||
|
||||
# Add the tabs from last session to the notebook
|
||||
for tab in self.db['open_tabs']:
|
||||
self.add_to_notebook(tab)
|
||||
|
@ -268,6 +266,7 @@ class MyTwitter():
|
|||
verified = self.check_verified(name)
|
||||
new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following, verified=verified)
|
||||
self.tweet_notebook.append_page_menu(new_pane, new_pane.get_tab_label(), gtk.Label(name))
|
||||
self.tweet_notebook.set_tab_reorderable(new_pane, True)
|
||||
new_pane.get_tab_label().connect('close-clicked', self.remove_view_callback, name)
|
||||
new_pane.connect('tweet-reply', self.on_reply)
|
||||
new_pane.connect('tweet-retweet', self.on_retweet)
|
||||
|
@ -303,6 +302,17 @@ class MyTwitter():
|
|||
self.verified_label.hide()
|
||||
|
||||
|
||||
def on_tabs_reordered(self, widget, child, page_num):
|
||||
# Clear the persistent tabs list, and recreate it
|
||||
# from scratch
|
||||
tab_names = []
|
||||
|
||||
for i in range(self.tweet_notebook.get_n_pages()):
|
||||
tab_names.append(self.tweet_notebook.get_nth_page(i).get_list_name())
|
||||
|
||||
self.db['open_tabs'] = tab_names
|
||||
|
||||
|
||||
def on_search(self, event):
|
||||
search_string = self.search_entry.get_text()
|
||||
self.search_entry.set_text('')
|
||||
|
|
Reference in a new issue