Added persistence to open tabs - open tabs will be open next time the program is launched
This commit is contained in:
parent
c9317af7e8
commit
c0e2bc834e
20
mytwitter.py
20
mytwitter.py
|
@ -24,6 +24,9 @@ class MyTwitter():
|
||||||
db_file = os.path.expanduser(config.get('global', 'dbfile'))
|
db_file = os.path.expanduser(config.get('global', 'dbfile'))
|
||||||
self.db = shelve.open(db_file)
|
self.db = shelve.open(db_file)
|
||||||
|
|
||||||
|
if not self.db.has_key('open_tabs'):
|
||||||
|
self.db['open_tabs'] = ['Home', '@' + self.username, 'Direct Messages']
|
||||||
|
|
||||||
if self.refresh_time < 10:
|
if self.refresh_time < 10:
|
||||||
self.refresh_time = 10
|
self.refresh_time = 10
|
||||||
|
|
||||||
|
@ -61,8 +64,9 @@ class MyTwitter():
|
||||||
# When we change tabs, any unread tweets in it become read
|
# When we change tabs, any unread tweets in it become read
|
||||||
self.tweet_notebook.connect('switch_page', self.on_tab_change)
|
self.tweet_notebook.connect('switch_page', self.on_tab_change)
|
||||||
|
|
||||||
# Add the Home tab to the notebook
|
# Add the tabs from last session to the notebook
|
||||||
self.add_to_notebook('Home')
|
for tab in self.db['open_tabs']:
|
||||||
|
self.add_to_notebook(tab)
|
||||||
|
|
||||||
# Put Home, @user, Direct Messages, and lists in the View menu...
|
# Put Home, @user, Direct Messages, and lists in the View menu...
|
||||||
lists = self.api.GetUserLists()
|
lists = self.api.GetUserLists()
|
||||||
|
@ -171,7 +175,12 @@ class MyTwitter():
|
||||||
|
|
||||||
# Remove one of the views from the tweet notebook.
|
# Remove one of the views from the tweet notebook.
|
||||||
# Called when the close button is clicked on one of the views
|
# Called when the close button is clicked on one of the views
|
||||||
|
# or Ctrl + W is pressed while the view is active
|
||||||
def remove_view(self, name):
|
def remove_view(self, name):
|
||||||
|
ot = self.db['open_tabs']
|
||||||
|
ot.remove(name)
|
||||||
|
self.db['open_tabs'] = ot
|
||||||
|
|
||||||
for i in range(self.tweet_notebook.get_n_pages()):
|
for i in range(self.tweet_notebook.get_n_pages()):
|
||||||
pane = self.tweet_notebook.get_nth_page(i)
|
pane = self.tweet_notebook.get_nth_page(i)
|
||||||
if (pane.get_list_name() == name):
|
if (pane.get_list_name() == name):
|
||||||
|
@ -198,6 +207,13 @@ class MyTwitter():
|
||||||
self.tweet_notebook.set_current_page(i)
|
self.tweet_notebook.set_current_page(i)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# We check for the name so that the special case of
|
||||||
|
# the first run is handled...
|
||||||
|
if single_tweet is None and name not in self.db['open_tabs']:
|
||||||
|
ot = self.db['open_tabs']
|
||||||
|
ot.append(name)
|
||||||
|
self.db['open_tabs'] = ot
|
||||||
|
|
||||||
is_user = False
|
is_user = False
|
||||||
following = False
|
following = False
|
||||||
verified = False
|
verified = False
|
||||||
|
|
Reference in New Issue
Block a user