From 8764cc77c3a40a4736a6f2b3c17551b33677cc8b Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 18 May 2010 16:26:32 -0400 Subject: [PATCH] Made @names into clickable links that load the user tab --- TODO | 1 + apithreads.py | 4 ++-- twitterwidgets.py | 12 +++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 01f7820..0add7af 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/apithreads.py b/apithreads.py index 4e8895a..fbe49d9 100644 --- a/apithreads.py +++ b/apithreads.py @@ -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) diff --git a/twitterwidgets.py b/twitterwidgets.py index c1ab609..a88cda2 100644 --- a/twitterwidgets.py +++ b/twitterwidgets.py @@ -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'\1\2', new_text) + new_text = re.sub(r'@(.*?)( |$)', r'@\1\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