Add support for replying to a specific tweet
This commit is contained in:
parent
69954f77f0
commit
b0fee54cf4
|
@ -76,6 +76,8 @@ class Tweep(object):
|
|||
last_status = None
|
||||
since_id = None
|
||||
progress = None
|
||||
reply_id = None
|
||||
reply_author = None
|
||||
|
||||
# Timelines
|
||||
friends = None
|
||||
|
@ -94,7 +96,15 @@ class Tweep(object):
|
|||
self.last_status = status
|
||||
self.statusbar = 'Updating...'
|
||||
self.statusentry = ''
|
||||
self.api.update(status, callback=self._status_complete)
|
||||
in_reply_to = None
|
||||
if status.startswith('@%s' % self.reply_author):
|
||||
in_reply_to = self.reply_id
|
||||
|
||||
self.api.update(status, in_reply_to=in_reply_to,
|
||||
callback=self._status_complete)
|
||||
|
||||
self.reply_author = None
|
||||
self.reply_id = None
|
||||
|
||||
def status_autocomplete(self, widget, event, **kwargs):
|
||||
if not gtk.gdk.keyval_name(event.keyval) == 'Tab':
|
||||
|
@ -208,6 +218,15 @@ class Tweep(object):
|
|||
def toggle_followers(self, button, **kwargs):
|
||||
print ('followers', locals())
|
||||
|
||||
def setup_reply(self, **kwargs):
|
||||
if not kwargs.get('tweet_id') or not kwargs.get('author'):
|
||||
return
|
||||
|
||||
self.reply_id = kwargs['tweet_id']
|
||||
self.reply_author = kwargs['author']
|
||||
textfield = self.widget_tree.get_widget('StatusEntry')
|
||||
textfield.set_text('@%s ' % self.reply_author)
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.timelines = []
|
||||
|
@ -215,6 +234,7 @@ class Tweep(object):
|
|||
self.window = self.widget_tree.get_widget('TweepyMainWindow')
|
||||
self.window.connect('destroy', self.destroy)
|
||||
self.progress = ProgressController(self.widget_tree)
|
||||
signals.observe(signals.TWEET_REPLY_TO, self.setup_reply)
|
||||
|
||||
self._events = {
|
||||
'on_QuitMenuItem_activate' : self.destroy,
|
||||
|
|
|
@ -10,7 +10,7 @@ import gobject
|
|||
# Enumeration of signals
|
||||
PROGRESS_START = -100
|
||||
PROGRESS_STOP = -101
|
||||
|
||||
TWEET_REPLY_TO = -102
|
||||
|
||||
__main_lock = threading.RLock()
|
||||
__signals = None
|
||||
|
|
|
@ -125,6 +125,7 @@ class TwitterApi(object):
|
|||
|
||||
@decorators.threaded
|
||||
def update(self, status, in_reply_to=None, callback=None):
|
||||
logging.debug('update("%s", in_reply_to=%s)' % (status, in_reply_to))
|
||||
signals.emit(signals.PROGRESS_START)
|
||||
args = {'status' : status}
|
||||
if in_reply_to:
|
||||
|
@ -150,6 +151,7 @@ class TwitterApi(object):
|
|||
|
||||
@decorators.threaded
|
||||
def retweet(self, status_id, callback=None):
|
||||
logging.debug('retweet(%s)' % status_id)
|
||||
signals.emit(signals.PROGRESS_START)
|
||||
headers = {
|
||||
'Content-type' : 'application/x-www-form-urlencoded',
|
||||
|
|
|
@ -16,6 +16,7 @@ import gtk.gdk
|
|||
# TweepyDeck imports
|
||||
from TweepyDeck import bases
|
||||
from TweepyDeck import decorators
|
||||
from TweepyDeck import signals
|
||||
from TweepyDeck import util
|
||||
|
||||
views = []
|
||||
|
@ -182,7 +183,8 @@ class Status(object):
|
|||
return ' '.join(self._markup_generator(pieces))
|
||||
|
||||
def on_reply_clicked(self, *args, **kwargs):
|
||||
print ('Reply to:', self.tweet_id, self.author)
|
||||
signals.emit(signals.TWEET_REPLY_TO, tweet_id=self.tweet_id,
|
||||
author=self.author)
|
||||
|
||||
def on_retweet_clicked(self, *args, **kwargs):
|
||||
app = util.get_global('app')
|
||||
|
|
Loading…
Reference in New Issue