Theoretically fixed the reply button. Don't want to annoy anyone by checking right now.

This commit is contained in:
Anna 2010-04-09 17:45:21 -04:00
parent 23573bc648
commit a61af65195
2 changed files with 40 additions and 14 deletions

View File

@ -187,7 +187,7 @@
<property name="has_frame">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">False</property>
<signal name="changed" handler="char_counter" last_modification_time="Thu, 08 Apr 2010 19:43:47 GMT"/>
<signal name="changed" handler="text_watcher" last_modification_time="Fri, 09 Apr 2010 21:33:28 GMT"/>
</widget>
<packing>
<property name="padding">0</property>

View File

@ -9,6 +9,10 @@ class MyTwitter():
""" Display Tweets, post to twitter """
# Precompile a regex for searching for @ at the beginning of a string
at_check = re.compile('^@')
def __init__(self):
config = ConfigParser.ConfigParser()
config.read(os.path.expanduser("~/.mytwitter"))
@ -50,8 +54,8 @@ class MyTwitter():
for i in range(0, self.num_entries):
self.tweets.append(TweetBox())
self.tweet_box.pack_start(self.tweets[i])
self.tweets[i].reply_button.connect('clicked', self.on_reply)
self.tweets[i].retweet_button.connect('clicked', self.on_retweet)
self.tweets[i].connect('reply', self.on_reply)
self.tweets[i].connect('retweet', self.on_retweet)
self.tweet_box.show_all()
# Fill the ComboBox with entries
@ -94,17 +98,23 @@ class MyTwitter():
self.update_status()
def char_counter(self, widget):
new_count = str(len(self.update_entry.get_text())) + "/140"
def text_watcher(self, widget):
''' Watch text entered on the update_entry, update things '''
text_len = self.update_entry.get_text_length()
new_count = str(text_len) + "/140"
self.update_count.set_label(new_count)
# If reply_id is set, unset it if we have removed the @ symbol
if self.reply_id is not None and not MyTwitter.at_check.match(self.update_entry.get_text()):
self.reply_id = None
def gtk_main_quit(self, widget):
gtk.main_quit()
def on_about(self, widget):
print "DEBUG: help->about not yet implemented"
print "STUB: help->about not yet implemented"
def on_list_select_changed(self, widget):
@ -112,12 +122,10 @@ class MyTwitter():
self.update_window()
# fixme: this doesn't work; we're passing in the Button widget and not the
# TweetBox widget... certain I need to do something convoluted to fix
# this
def on_reply(self, widget):
self.update_entry.set_text('@' + widget.screen_name + ' ')
self.reply_id = widget.id
self.update_entry.grab_focus()
# fixme: need to implement the retweet API in python-twitter to continue
@ -173,11 +181,12 @@ class TweetBox(gtk.VBox):
button_box = gtk.HBox()
self.pack_start(button_box)
self.reply_button = gtk.Button("Reply")
button_box.pack_start(self.reply_button, expand=False)
self.retweet_button = gtk.Button("Retweet")
button_box.pack_start(self.retweet_button, expand=False)
# the parent object will bind reply and retweet
reply_button = gtk.Button("Reply")
button_box.pack_start(reply_button, expand=False)
reply_button.connect("clicked", self.on_reply_clicked)
retweet_button = gtk.Button("Retweet")
button_box.pack_start(retweet_button, expand=False)
retweet_button.connect("clicked", self.on_retweet_clicked)
def set_status(self, status):
@ -201,11 +210,28 @@ class TweetBox(gtk.VBox):
# and the text
self.text.set_markup(status.text)
def on_reply_clicked(self, widget):
self.emit('reply')
def on_retweet_clicked(self, widget):
self.emit('retweet')
# end class TweetBox
# main
# Create custom events for TweetBox
gobject.signal_new("reply", TweetBox,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, ())
gobject.signal_new("retweet", TweetBox,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, ())
my_twitter = MyTwitter()
gtk.main()