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

1
TODO
View File

@ -15,3 +15,4 @@ bugs:
* Direct Messages have no names, only screen names (may not be fixable without
considerable tweaks to python-twitter)
* "ValueError: list.remove(x): x not in list" when trying to close a tab (error recurred after adding conversation support). Tabs can be reordered, then closed, as a workaround.
* Links must be right-clicked on to activate - can't left-click on the link directly. This seems to be a pygtk issue

View File

@ -206,7 +206,7 @@ class GetFollowing(ApiThread):
relationship = self.api.ShowFriendships(target_screen_name=screen_name)
following = relationship.source.following
except (HTTPError, URLError):
following = false
following = False
self.pane.set_following(following)
@ -229,7 +229,7 @@ class GetVerified(ApiThread):
user = self.api.GetUser(screen_name)
verified = user.verified
except (HTTPError, URLError):
verified = false
verified = False
self.pane.set_verified(verified)

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