Did some ApiThread refactoring, made the refresh button only refresh the current pane, and helped child threads die on exit

This commit is contained in:
Anna 2010-05-06 13:18:02 -04:00
parent d2cf7c2ff5
commit fe1b1cabf2
4 changed files with 67 additions and 57 deletions

View file

@ -140,49 +140,54 @@ class MyTwitter():
def update_windows(self):
for i in range(0, self.tweet_notebook.get_n_pages()):
pane = self.tweet_notebook.get_nth_page(i)
list_name = pane.get_list_name()
# Single tweets should never be updated here
if pane.get_single_tweet() is not None:
continue
# Determine username and appropriate account to use
found = False
username = re.sub('/Home', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
username = re.sub('@', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
username = re.sub('/Direct Messages', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
account = self.api
username = self.username
apithreads.GetTweets(api=account,
list_name=list_name,
pane=pane,
num_entries=self.num_entries,
username=username
).start()
self.update_single_window(pane)
# We have to return true, so the timeout_add event will keep happening
return True
def update_windows_callback(self, widget):
self.update_windows()
def update_single_window(self, pane):
list_name = pane.get_list_name()
# Single tweets should never be updated here
if pane.get_single_tweet() is not None:
return
# Determine username and appropriate account to use
found = False
username = re.sub('/Home', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
username = re.sub('@', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
username = re.sub('/Direct Messages', '', list_name)
if self.accounts.has_key(username):
account = self.accounts[username]
found = True
if not found:
account = self.api
username = self.username
apithreads.GetTweets(api=account,
list_name=list_name,
pane=pane,
num_entries=self.num_entries,
username=username
).start()
def update_window_callback(self, widget):
pane = self.tweet_notebook.get_nth_page(self.tweet_notebook.get_current_page())
self.update_single_window(pane)
def update_status(self):