Made @names into clickable links that load the user tab

This commit is contained in:
Anna
2010-05-18 16:26:32 -04:00
parent dad6c68159
commit 8764cc77c3
3 changed files with 8 additions and 9 deletions

View File

@ -374,6 +374,7 @@ class TweetBox(gtk.HBox):
new_text = re.sub(r'&([^;]*?)( |$)', r'&\1\2', new_text)
if gtk.gtk_version[0] > 2 or (gtk.gtk_version[0] == 2 and gtk.gtk_version[1] >= 18):
new_text = re.sub(r"(http://.*?)( |$)", r'<a href="\1">\1</a>\2', new_text)
new_text = re.sub(r'@(.*?)( |$)', r'@<a href="@\1">\1</a>\2', new_text)
self.text.set_markup(new_text)
# If this is in reply to something, set appropriate label
@ -431,16 +432,13 @@ class TweetBox(gtk.HBox):
def on_mouse_clicked(self, widget, event):
if event.button == 1:
self.set_read(True)
# fixme: call on_url_clicked if there is an active uri
# Apparently, this must wait until pygtk 2.18
def on_url_clicked(self, widget, event):
def on_url_clicked(self, widget, uri):
self.set_read()
# fixme: we're catching this signal just to debug why it doesn't get emitted
# seems to be related to EventBox?
print 'debug: on_url_clicked()'
if re.match(r'@', uri):
self.emit('show-user', re.sub(r'@', '', uri))
return True
# end class TweetBox