diff --git a/TODO b/TODO
index c473fa7..95af01c 100644
--- a/TODO
+++ b/TODO
@@ -16,4 +16,4 @@ bugs:
* Direct Messages have no names, only screen names (may not be fixable without
considerable tweaks to python-twitter)
* Can't always kill tabs - open tab list not always correctly populated?
-* Can't always kill application
+* Follow/Unfollow and Verified don't get set on current tab when it first appears... need a signal to come back from the TweetPane.
diff --git a/apithreads.py b/apithreads.py
index bd1e4a0..26e2bc1 100644
--- a/apithreads.py
+++ b/apithreads.py
@@ -17,10 +17,19 @@ class SafeApi(Api):
-class GetTweets(Thread):
- def __init__(self, api, list_name, pane, num_entries, username):
+class ApiThread(Thread):
+ def __init__(self, api):
Thread.__init__(self)
self.api = api
+ self.setDaemon(True)
+
+# End class ApiThread
+
+
+
+class GetTweets(ApiThread):
+ def __init__(self, api, list_name, pane, num_entries, username):
+ ApiThread.__init__(self, api)
self.list_name = list_name
self.pane = pane
self.num_entries = num_entries
@@ -58,7 +67,7 @@ class GetTweets(Thread):
else:
statuses = results_to_statuses(self.api.Search(self.list_name, rpp=self.num_entries))
- except HTTPError,URLError:
+ except (HTTPError, URLError):
statuses = None
gtk.gdk.threads_enter()
@@ -72,10 +81,9 @@ class GetTweets(Thread):
-class GetSingleTweet(Thread):
- def __init__(self, api, pane, single_tweet):
- Thread.__init__(self)
- self.api = api
+class GetSingleTweet(ApiThread):
+ def __init__(self, pane, single_tweet):
+ ApiThread.__init__(self, api)
self.pane = pane
self.single_tweet = single_tweet
@@ -85,7 +93,7 @@ class GetSingleTweet(Thread):
with self.api.lock:
try:
statuses.append(self.api.GetStatus(self.single_tweet))
- except HTTPError,URLError:
+ except (HTTPError, URLError):
statuses = None
gtk.gdk.threads_enter()
@@ -99,10 +107,9 @@ class GetSingleTweet(Thread):
-class GetFollowing(Thread):
+class GetFollowing(ApiThread):
def __init__(self, api, pane, user):
- Thread.__init__(self)
- self.api = api
+ ApiThread.__init__(self, api)
self.pane = pane
self.user = user
@@ -114,7 +121,7 @@ class GetFollowing(Thread):
with self.api.lock:
relationship = self.api.ShowFriendships(target_screen_name=screen_name)
following = relationship.source.following
- except HTTPError,URLError:
+ except (HTTPError, URLError):
following = false
self.pane.set_following(following)
@@ -123,10 +130,9 @@ class GetFollowing(Thread):
-class GetVerified(Thread):
+class GetVerified(ApiThread):
def __init__(self, api, pane, user):
- Thread.__init__(self)
- self.api = api
+ ApiThread.__init__(self, api)
self.pane = pane
self.user = user
@@ -138,12 +144,11 @@ class GetVerified(Thread):
with self.api.lock:
user = self.api.GetUser(screen_name)
verified = user.verified
- except HTTPError,URLError:
+ except (HTTPError, URLError):
verified = false
self.pane.set_verified(verified)
-
### End class GetVerified
diff --git a/default.glade b/default.glade
index 65666b1..ece8e70 100644
--- a/default.glade
+++ b/default.glade
@@ -221,7 +221,7 @@
True
GTK_RELIEF_NORMAL
True
-
+
0
diff --git a/mytwitter.py b/mytwitter.py
index 9bde396..cfc6d61 100755
--- a/mytwitter.py
+++ b/mytwitter.py
@@ -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):