Added version check for feature that isn't working in pygtk 2.14, and improved the ampersand handling because the twitter API is lazy about consistently escaping characters

This commit is contained in:
Anna 2010-04-11 00:21:18 -04:00
parent b22e80c915
commit cfbae74cff

View File

@ -177,7 +177,8 @@ class TweetBox(gtk.VBox):
self.text.set_alignment(0.0, 0.0)
self.text.set_selectable(True)
self.text.set_line_wrap(True)
self.text.connect('activate-link', self.on_url_clicked)
if gtk.pygtk_version[0] > 2 or (gtk.pygtk_version[0] == 2 and gtk.pygtk_version[1] >= 18):
self.text.connect('activate-link', self.on_url_clicked)
button_box = gtk.HBox()
self.pack_start(button_box)
@ -211,8 +212,9 @@ class TweetBox(gtk.VBox):
# and the text
new_text = status.text
new_text = re.sub('& ', '& ', new_text)
new_text = re.sub(r"(http://.*?)( |$)", r'<a href="\1">\1</a>\2', new_text)
new_text = re.sub('&([^;]*?)( |$)', '&amp;\1\2', new_text)
if gtk.pygtk_version[0] > 2 or (gtk.pygtk_version[0] == 2 and gtk.pygtk_version[1] >= 18):
new_text = re.sub(r"(http://.*?)( |$)", r'<a href="\1">\1</a>\2', new_text)
self.text.set_markup(new_text)