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'))
|
||||
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:
|
||||
self.refresh_time = 10
|
||||
|
||||
|
@ -61,8 +64,9 @@ class MyTwitter():
|
|||
# When we change tabs, any unread tweets in it become read
|
||||
self.tweet_notebook.connect('switch_page', self.on_tab_change)
|
||||
|
||||
# Add the Home tab to the notebook
|
||||
self.add_to_notebook('Home')
|
||||
# Add the tabs from last session to the notebook
|
||||
for tab in self.db['open_tabs']:
|
||||
self.add_to_notebook(tab)
|
||||
|
||||
# Put Home, @user, Direct Messages, and lists in the View menu...
|
||||
lists = self.api.GetUserLists()
|
||||
|
@ -171,7 +175,12 @@ class MyTwitter():
|
|||
|
||||
# Remove one of the views from the tweet notebook.
|
||||
# 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):
|
||||
ot = self.db['open_tabs']
|
||||
ot.remove(name)
|
||||
self.db['open_tabs'] = ot
|
||||
|
||||
for i in range(self.tweet_notebook.get_n_pages()):
|
||||
pane = self.tweet_notebook.get_nth_page(i)
|
||||
if (pane.get_list_name() == name):
|
||||
|
@ -198,6 +207,13 @@ class MyTwitter():
|
|||
self.tweet_notebook.set_current_page(i)
|
||||
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
|
||||
following = False
|
||||
verified = False
|
||||
|
|
Reference in New Issue
Block a user