Made posting an update a threaded action
This commit is contained in:
parent
8764cc77c3
commit
cc99e36ed3
2 changed files with 43 additions and 12 deletions
28
mytwitter.py
28
mytwitter.py
|
@ -182,19 +182,13 @@ class MyTwitter():
|
|||
def update_status(self):
|
||||
reply_id = self.reply_id
|
||||
text = self.update_entry.get_text()
|
||||
self.update_entry.set_text("")
|
||||
|
||||
with self.api.lock:
|
||||
try:
|
||||
self.api.PostUpdate(text, in_reply_to_status_id=reply_id)
|
||||
except HTTPError,URLError:
|
||||
self.update_status_bar('Failed to post tweet')
|
||||
self.reply_id = None
|
||||
return
|
||||
thread = apithreads.PostUpdate(self.api, text, reply_id)
|
||||
thread.sig_proxy.connect('update-posted', self.on_update_posted)
|
||||
self.update_entry.set_sensitive(False)
|
||||
self.update_status_bar('Posting...')
|
||||
thread.start()
|
||||
|
||||
self.reply_id = None
|
||||
self.update_status_bar('Tweet Posted')
|
||||
|
||||
|
||||
def update_status_callback(self, widget):
|
||||
self.update_status()
|
||||
|
@ -483,7 +477,17 @@ class MyTwitter():
|
|||
def on_resize(self, widget, event):
|
||||
self.db['width'] = event.width
|
||||
self.db['height'] = event.height
|
||||
|
||||
|
||||
|
||||
def on_update_posted(self, widget, success):
|
||||
if success:
|
||||
self.reply_id = None
|
||||
self.update_entry.set_text("")
|
||||
self.update_status_bar('Tweet Posted')
|
||||
else:
|
||||
self.update_status_bar('Failed to post tweet')
|
||||
|
||||
self.update_entry.set_sensitive(True)
|
||||
|
||||
### end class MyTwitter
|
||||
|
||||
|
|
Reference in a new issue