Don't show retweet in DM pane, DM pane 'Reply' button should send DM to target user, and position cursor / dehilight text when replying
This commit is contained in:
parent
3aadbebd64
commit
1b4d2ccbfb
18
hrafn.py
18
hrafn.py
|
@ -238,7 +238,18 @@ class Hrafn():
|
||||||
def on_reply(self, widget, data):
|
def on_reply(self, widget, data):
|
||||||
self.update_entry.set_text('@' + data['screen_name'] + ' ')
|
self.update_entry.set_text('@' + data['screen_name'] + ' ')
|
||||||
self.reply_id = data['id']
|
self.reply_id = data['id']
|
||||||
|
self.focus_on_entry()
|
||||||
|
|
||||||
|
|
||||||
|
def on_reply_dm(self, widget, data):
|
||||||
|
self.update_entry.set_text('D ' + data + ' ')
|
||||||
|
self.focus_on_entry()
|
||||||
|
|
||||||
|
|
||||||
|
def focus_on_entry(self):
|
||||||
self.update_entry.grab_focus()
|
self.update_entry.grab_focus()
|
||||||
|
self.update_entry.select_region(0,0)
|
||||||
|
self.update_entry.set_position(-1)
|
||||||
|
|
||||||
|
|
||||||
def on_retweet(self, widget, data):
|
def on_retweet(self, widget, data):
|
||||||
|
@ -317,11 +328,15 @@ class Hrafn():
|
||||||
if re.match('user:', name):
|
if re.match('user:', name):
|
||||||
is_user = True
|
is_user = True
|
||||||
|
|
||||||
|
is_dm = False
|
||||||
|
if re.search('Direct Messages', name):
|
||||||
|
is_dm = True
|
||||||
|
|
||||||
entries=self.num_entries
|
entries=self.num_entries
|
||||||
if single_tweet and not conversation:
|
if single_tweet and not conversation:
|
||||||
entries=1
|
entries=1
|
||||||
|
|
||||||
new_pane = TweetPane(name, username=self.username, num_entries=entries, single_tweet=single_tweet, is_user=is_user, conversation=conversation)
|
new_pane = TweetPane(name, username=self.username, num_entries=entries, single_tweet=single_tweet, is_user=is_user, conversation=conversation, is_dm=is_dm)
|
||||||
new_pane.connect('new-tweets', self.on_read_tweets_changed)
|
new_pane.connect('new-tweets', self.on_read_tweets_changed)
|
||||||
new_pane.connect('tweets-read', self.on_read_tweets_changed)
|
new_pane.connect('tweets-read', self.on_read_tweets_changed)
|
||||||
|
|
||||||
|
@ -354,6 +369,7 @@ class Hrafn():
|
||||||
self.tweet_notebook.set_tab_reorderable(new_pane, True)
|
self.tweet_notebook.set_tab_reorderable(new_pane, True)
|
||||||
new_pane.get_tab_label().connect('close-clicked', self.remove_view_callback, name, single_tweet, conversation)
|
new_pane.get_tab_label().connect('close-clicked', self.remove_view_callback, name, single_tweet, conversation)
|
||||||
new_pane.connect('tweet-reply', self.on_reply)
|
new_pane.connect('tweet-reply', self.on_reply)
|
||||||
|
new_pane.connect('tweet-reply-dm', self.on_reply_dm)
|
||||||
new_pane.connect('tweet-retweet', self.on_retweet)
|
new_pane.connect('tweet-retweet', self.on_retweet)
|
||||||
new_pane.connect('tweet-in-reply-to', self.on_reply_to)
|
new_pane.connect('tweet-in-reply-to', self.on_reply_to)
|
||||||
new_pane.connect('tweet-conversation', self.on_conversation)
|
new_pane.connect('tweet-conversation', self.on_conversation)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
It also gets some data from its parent, including num_entries
|
It also gets some data from its parent, including num_entries
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, list_name, username, num_entries=20, single_tweet=None, is_user=False, conversation=False):
|
def __init__(self, list_name, username, num_entries=20, single_tweet=None, is_user=False, conversation=False, is_dm=False):
|
||||||
gtk.ScrolledWindow.__init__(self)
|
gtk.ScrolledWindow.__init__(self)
|
||||||
|
|
||||||
# If the username is encoded in the tweet pane's name, we really want
|
# If the username is encoded in the tweet pane's name, we really want
|
||||||
|
@ -37,6 +37,7 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
self.is_user = is_user
|
self.is_user = is_user
|
||||||
self.following = False
|
self.following = False
|
||||||
self.verified = False
|
self.verified = False
|
||||||
|
self.is_dm = is_dm
|
||||||
|
|
||||||
self.tab_label = CloseTabLabel(self.list_name)
|
self.tab_label = CloseTabLabel(self.list_name)
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
|
|
||||||
# Build us some labels...
|
# Build us some labels...
|
||||||
for i in range(0, self.num_entries):
|
for i in range(0, self.num_entries):
|
||||||
self.tweets.append(TweetBox(self.conversation, self.is_user))
|
self.tweets.append(TweetBox(self.conversation, self.is_user, self.is_dm))
|
||||||
tweet_box.pack_start(self.tweets[i], expand=False)
|
tweet_box.pack_start(self.tweets[i], expand=False)
|
||||||
self.tweets[i].connect('reply', self.on_tweet_reply)
|
self.tweets[i].connect('reply', self.on_tweet_reply)
|
||||||
self.tweets[i].connect('retweet', self.on_retweet)
|
self.tweets[i].connect('retweet', self.on_retweet)
|
||||||
|
@ -193,7 +194,10 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
|
|
||||||
|
|
||||||
def on_tweet_reply(self, widget):
|
def on_tweet_reply(self, widget):
|
||||||
self.emit('tweet-reply', {'screen_name': widget.screen_name, 'id': widget.id})
|
if self.is_dm:
|
||||||
|
self.emit('tweet-reply-dm', widget.screen_name)
|
||||||
|
else:
|
||||||
|
self.emit('tweet-reply', {'screen_name': widget.screen_name, 'id': widget.id})
|
||||||
|
|
||||||
|
|
||||||
def on_retweet(self, widget):
|
def on_retweet(self, widget):
|
||||||
|
@ -233,6 +237,9 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
gobject.signal_new("tweet-reply", TweetPane,
|
gobject.signal_new("tweet-reply", TweetPane,
|
||||||
gobject.SIGNAL_RUN_LAST,
|
gobject.SIGNAL_RUN_LAST,
|
||||||
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
||||||
|
gobject.signal_new("tweet-reply-dm", TweetPane,
|
||||||
|
gobject.SIGNAL_RUN_LAST,
|
||||||
|
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
||||||
gobject.signal_new("tweet-retweet", TweetPane,
|
gobject.signal_new("tweet-retweet", TweetPane,
|
||||||
gobject.SIGNAL_RUN_LAST,
|
gobject.SIGNAL_RUN_LAST,
|
||||||
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
|
||||||
|
@ -265,7 +272,7 @@ class TweetBox(gtk.HBox):
|
||||||
Also stores the data necessary for replying or retweeting (id, screen name)
|
Also stores the data necessary for replying or retweeting (id, screen name)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, conversation=False, is_user=False):
|
def __init__(self, conversation=False, is_user=False, is_dm=False):
|
||||||
gtk.HBox.__init__(self)
|
gtk.HBox.__init__(self)
|
||||||
|
|
||||||
self.screen_name = None
|
self.screen_name = None
|
||||||
|
@ -278,6 +285,7 @@ class TweetBox(gtk.HBox):
|
||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
|
|
||||||
self.is_user = is_user
|
self.is_user = is_user
|
||||||
|
self.is_dm = is_dm
|
||||||
|
|
||||||
self.init_widgets()
|
self.init_widgets()
|
||||||
|
|
||||||
|
@ -386,10 +394,11 @@ class TweetBox(gtk.HBox):
|
||||||
button_box.pack_end(reply_button, expand=False)
|
button_box.pack_end(reply_button, expand=False)
|
||||||
reply_button.connect("clicked", self.on_reply_clicked)
|
reply_button.connect("clicked", self.on_reply_clicked)
|
||||||
|
|
||||||
retweet_button = gtk.Button("Retweet")
|
if not self.is_dm:
|
||||||
retweet_button.set_relief(gtk.RELIEF_HALF)
|
retweet_button = gtk.Button("Retweet")
|
||||||
button_box.pack_end(retweet_button, expand=False)
|
retweet_button.set_relief(gtk.RELIEF_HALF)
|
||||||
retweet_button.connect("clicked", self.on_retweet_clicked)
|
button_box.pack_end(retweet_button, expand=False)
|
||||||
|
retweet_button.connect("clicked", self.on_retweet_clicked)
|
||||||
|
|
||||||
|
|
||||||
def set_status(self, status, read=True):
|
def set_status(self, status, read=True):
|
||||||
|
|
Reference in New Issue
Block a user