From 5c7798398bbc1f8fca06797f0cabbfa9beaf1415 Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 21 Apr 2010 10:01:59 -0400 Subject: [PATCH] Made tabs reorderable, and added code to persist the ordering changes --- TODO | 3 ++- default.glade | 2 ++ mytwitter.py | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index c54c8d5..b93a9ce 100644 --- a/TODO +++ b/TODO @@ -11,4 +11,5 @@ features: bugs: -* Direct Messages have no names... +* Direct Messages have no names +* single-tweet tabs will not persist properly diff --git a/default.glade b/default.glade index f2b490b..65666b1 100644 --- a/default.glade +++ b/default.glade @@ -158,6 +158,8 @@ GTK_POS_TOP True True + + diff --git a/mytwitter.py b/mytwitter.py index 6d2883d..15b5e06 100755 --- a/mytwitter.py +++ b/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('')