Made retweets threaded

This commit is contained in:
Anna 2010-05-19 00:04:01 -04:00
parent 08dd6957ff
commit c2aae17e5b
2 changed files with 40 additions and 5 deletions

View File

@ -283,6 +283,27 @@ class PostUpdate(ApiThread):
class PostRetweet(ApiThread):
def __init__(self, api, retweet_id):
ApiThread.__init__(self, api)
self.sig_proxy = SigProxy()
self.retweet_id = retweet_id
def run(self):
try:
with self.api.lock:
self.api.PostRetweet(self.retweet_id)
success = True
except (HTTPError, URLError):
success = False
self.sig_proxy.emit('retweet-posted', success)
### End class PostRetweet
class SigProxy(gtk.Alignment):
"""
This little class exists just so that we can have a gtk class in our
@ -303,6 +324,10 @@ gobject.signal_new("update-posted", SigProxy,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
gobject.signal_new("retweet-posted", SigProxy,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
# We use these classes to emulate a Status object when we need
# one to be built out of something else.

View File

@ -221,11 +221,11 @@ class MyTwitter():
def on_retweet(self, widget, data):
with self.api.lock:
try:
self.api.PostRetweet(data['id'])
except HTTPError,URLError:
self.update_status_bar('Failed to retweet')
thread = apithreads.PostRetweet(self.api, data['id'])
thread.sig_proxy.connect('retweet-posted', self.on_retweet_posted)
self.update_entry.set_sensitive(False)
self.update_status_bar('Posting retweet...')
thread.start()
def on_reply_to(self, widget, data):
@ -489,6 +489,16 @@ class MyTwitter():
self.update_entry.set_sensitive(True)
def on_retweet_posted(self, widget, success):
if success:
self.update_status_bar('Retweet Posted')
else:
self.update_status_bar('Failed to retweet')
self.update_entry.set_sensitive(True)
### end class MyTwitter