|
|
|
@ -28,6 +28,7 @@ import Queue
|
|
|
|
|
import re |
|
|
|
|
import urllib2 |
|
|
|
|
import webbrowser |
|
|
|
|
import gettext |
|
|
|
|
|
|
|
|
|
from cgi import escape as html_escape |
|
|
|
|
|
|
|
|
@ -41,14 +42,23 @@ _log = logging.getLogger('ui.pygtk')
|
|
|
|
|
|
|
|
|
|
URL_RE = re.compile(r'(https?://[^\s\n\r]+)', re.I) |
|
|
|
|
|
|
|
|
|
MESSAGE_FORMAT = '%s' \ |
|
|
|
|
'<b>%s</b> ' \ |
|
|
|
|
'<small>(%s' \ |
|
|
|
|
'%s' \ |
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
|
# I18n bits |
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
|
#t = gettext.translation('ui_pygtk') |
|
|
|
|
#_ = t.gettext |
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
|
# String with the format to the message |
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
|
MESSAGE_FORMAT = '%(favourite_star)s' \ |
|
|
|
|
'<b>%(full_name)s</b> ' \ |
|
|
|
|
'<small>(%(username)s' \ |
|
|
|
|
'%(message_type)s' \ |
|
|
|
|
')</small>:' \ |
|
|
|
|
'%s\n' \ |
|
|
|
|
'%s\n' \ |
|
|
|
|
'<small>%s</small>' |
|
|
|
|
'%(read_status)s\n' \ |
|
|
|
|
'%(message)s\n' \ |
|
|
|
|
'<small>%(message_age)s</small>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
@ -576,15 +586,19 @@ class Interface(object):
|
|
|
|
|
data = store.get_value(position, 0) |
|
|
|
|
time = timesince.timesince(data.message_time) |
|
|
|
|
|
|
|
|
|
message_values = {} |
|
|
|
|
|
|
|
|
|
# unescape escaped entities that pango is not okay with |
|
|
|
|
message = html_escape(data.message) |
|
|
|
|
username = html_escape(data.username) |
|
|
|
|
full_name = html_escape(data.name) |
|
|
|
|
message_values['message'] = html_escape(data.message) |
|
|
|
|
message_values['username'] = html_escape(data.username) |
|
|
|
|
message_values['full_name'] = html_escape(data.name) |
|
|
|
|
message_values['message_age'] = time |
|
|
|
|
|
|
|
|
|
# highlight URLs |
|
|
|
|
mask = r'<span foreground="%s">\1</span>' % ( |
|
|
|
|
self._options[self.NAMESPACE]['link_colour']) |
|
|
|
|
message = URL_RE.sub(mask, message) |
|
|
|
|
message_values['message'] = URL_RE.sub(mask, |
|
|
|
|
message_values['message']) |
|
|
|
|
|
|
|
|
|
# use a different highlight for the current user |
|
|
|
|
# TODO: How to handle this with several networks? |
|
|
|
@ -593,14 +607,14 @@ class Interface(object):
|
|
|
|
|
# message) |
|
|
|
|
|
|
|
|
|
if not data.read: |
|
|
|
|
read_status = ' ●' |
|
|
|
|
message_values['read_status'] = ' ●' |
|
|
|
|
else: |
|
|
|
|
read_status = '' |
|
|
|
|
message_values['read_status'] = '' |
|
|
|
|
|
|
|
|
|
if data.favourite: |
|
|
|
|
favourite = '★' |
|
|
|
|
message_values['favourite_star'] = '★' |
|
|
|
|
else: |
|
|
|
|
favourite = '☆' |
|
|
|
|
message_values['favourite_star'] = '☆' |
|
|
|
|
|
|
|
|
|
info = [] |
|
|
|
|
if data.reposted_by: |
|
|
|
@ -610,10 +624,8 @@ class Interface(object):
|
|
|
|
|
info.append(' — <i>in reply to %s</i>' % |
|
|
|
|
(data.parent_owner)) |
|
|
|
|
|
|
|
|
|
info_message = ''.join(info) |
|
|
|
|
|
|
|
|
|
markup = MESSAGE_FORMAT % (favourite, full_name, username, |
|
|
|
|
info_message, read_status, message, time) |
|
|
|
|
message_values['message_type'] = ''.join(info) |
|
|
|
|
markup = MESSAGE_FORMAT % (message_values) |
|
|
|
|
|
|
|
|
|
cell.set_property('markup', markup) |
|
|
|
|
|
|
|
|
|