Made retweets threaded
This commit is contained in:
parent
08dd6957ff
commit
c2aae17e5b
|
@ -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):
|
class SigProxy(gtk.Alignment):
|
||||||
"""
|
"""
|
||||||
This little class exists just so that we can have a gtk class in our
|
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.SIGNAL_RUN_LAST,
|
||||||
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
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
|
# We use these classes to emulate a Status object when we need
|
||||||
# one to be built out of something else.
|
# one to be built out of something else.
|
||||||
|
|
20
mytwitter.py
20
mytwitter.py
|
@ -221,11 +221,11 @@ class MyTwitter():
|
||||||
|
|
||||||
|
|
||||||
def on_retweet(self, widget, data):
|
def on_retweet(self, widget, data):
|
||||||
with self.api.lock:
|
thread = apithreads.PostRetweet(self.api, data['id'])
|
||||||
try:
|
thread.sig_proxy.connect('retweet-posted', self.on_retweet_posted)
|
||||||
self.api.PostRetweet(data['id'])
|
self.update_entry.set_sensitive(False)
|
||||||
except HTTPError,URLError:
|
self.update_status_bar('Posting retweet...')
|
||||||
self.update_status_bar('Failed to retweet')
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
def on_reply_to(self, widget, data):
|
def on_reply_to(self, widget, data):
|
||||||
|
@ -489,6 +489,16 @@ class MyTwitter():
|
||||||
|
|
||||||
self.update_entry.set_sensitive(True)
|
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
|
### end class MyTwitter
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user