diff --git a/src/common/helpers.py b/src/common/helpers.py
index a6c9dbaf3..98162da2d 100644
--- a/src/common/helpers.py
+++ b/src/common/helpers.py
@@ -290,6 +290,21 @@ def get_uf_role(role, plural = False):
else:
role_name = _('Visitor')
return role_name
+
+def get_uf_affiliation(affiliation):
+ '''Get a nice and translated affilition for muc'''
+ if affiliation == 'none':
+ affiliation_name = Q_('?Group Chat Contact Affiliation:None')
+ elif affiliation == 'owner':
+ affiliation_name = _('Owner')
+ elif affiliation == 'admin':
+ affiliation_name = _('Administrator')
+ elif affiliation == 'member':
+ affiliation_name = _('Member')
+ else: # Argl ! An unknown affiliation !
+ affiliation_name = affiliation.capitalize()
+ return affiliation_name
+
def get_sorted_keys(adict):
keys = adict.keys()
diff --git a/src/tooltips.py b/src/tooltips.py
index 56c4dd461..a03f9810a 100644
--- a/src/tooltips.py
+++ b/src/tooltips.py
@@ -179,8 +179,10 @@ class StatusTable:
status = unicode(status, encoding='utf-8')
# reduce to 200 chars, 1 line
status = gtkgui_helpers.reduce_chars_newlines(status, 200, 1)
- str_status += ' - ' + status
- return gtkgui_helpers.escape_for_pango_markup(str_status)
+ str_status = gtkgui_helpers.escape_for_pango_markup(str_status)
+ status = gtkgui_helpers.escape_for_pango_markup(status)
+ str_status += ' - ' + status + ''
+ return str_status
def add_status_row(self, file_path, show, str_status, status_time = None, show_lock = False):
''' appends a new row with status icon to the table '''
@@ -213,13 +215,6 @@ class StatusTable:
gtk.ICON_SIZE_MENU)
self.table.attach(lock_image, 4, 5, self.current_row,
self.current_row + 1, 0, 0, 0, 0)
- if status_time:
- self.current_row += 1
- # decode locale encoded string, the same way as below (10x nk)
- local_time = time.strftime("%c", status_time)
- local_time = local_time.decode(locale.getpreferredencoding())
- status_time_label = gtk.Label(local_time)
- status_time_label.set_alignment(0, 0)
class NotificationAreaTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the notification area '''
@@ -364,32 +359,34 @@ class GCTooltip(BaseTooltip):
vcard_table.set_homogeneous(False)
vcard_current_row = 1
properties = []
- status_message_present = False
- show = helpers.get_uf_show(contact.show)
- nick_show_markup = '' + \
+ nick_markup = '' + \
gtkgui_helpers.escape_for_pango_markup(contact.get_shown_name()) \
- + ' (' + show + ')'
- properties.append((nick_show_markup, None))
+ + ''
+ properties.append((nick_markup, None))
- #status message :
- if contact.status:
- status_message = contact.status.strip()
- if status_message != '':
+ if contact.status: # status message
+ status = contact.status.strip()
+ if status != '':
# escape markup entities
- status_message = gtkgui_helpers.reduce_chars_newlines(status_message, 200, 5)
- status_message = '' +\
- gtkgui_helpers.escape_for_pango_markup(status_message) + ''
- properties.append((status_message, None))
- status_message_present = True
+ status = gtkgui_helpers.reduce_chars_newlines(status, 200, 5)
+ status = '' +\
+ gtkgui_helpers.escape_for_pango_markup(status) + ''
+ properties.append((status, None))
+ else: # no status message, show SHOW instead
+ show = helpers.get_uf_show(contact.show)
+ show = '' + show + ''
+ properties.append((show, None))
if contact.jid.strip() != '':
- properties.append((_('JID: '), contact.jid))
- if contact.affiliation != "none":
- properties.append((_('Affiliation: '), contact.affiliation.capitalize()))
+ properties.append((_('Jabber ID: '), contact.jid))
if hasattr(contact, 'resource') and contact.resource.strip() != '':
properties.append((_('Resource: '),
gtkgui_helpers.escape_for_pango_markup(contact.resource) ))
+ if contact.affiliation != 'none':
+ affiliation = helpers.get_uf_affiliation(contact.affiliation) +\
+ _(' of the room')
+ properties.append((affiliation, None))
# Add avatar
puny_name = helpers.sanitize_filename(contact.name)
@@ -491,23 +488,10 @@ class RosterTooltip(NotificationAreaTooltip):
vcard_table.set_homogeneous(False)
vcard_current_row = 1
properties = []
- jid_markup = '' + prim_contact.jid + ''
- properties.append((jid_markup, None))
-
- properties.append((_('Name: '), gtkgui_helpers.escape_for_pango_markup(
- prim_contact.get_shown_name())))
- if prim_contact.sub:
- properties.append(( _('Subscription: '),
- gtkgui_helpers.escape_for_pango_markup(helpers.get_uf_sub(prim_contact.sub))))
- if prim_contact.keyID:
- keyID = None
- if len(prim_contact.keyID) == 8:
- keyID = prim_contact.keyID
- elif len(prim_contact.keyID) == 16:
- keyID = prim_contact.keyID[8:]
- if keyID:
- properties.append((_('OpenPGP: '),
- gtkgui_helpers.escape_for_pango_markup(keyID)))
+ name_markup = u'' + gtkgui_helpers.escape_for_pango_markup(
+ prim_contact.get_shown_name())+ ''
+ properties.append((name_markup, None))
+
num_resources = 0
# put contacts in dict, where key is priority
contacts_dict = {}
@@ -518,11 +502,6 @@ class RosterTooltip(NotificationAreaTooltip):
contacts_dict[contact.priority].append(contact)
else:
contacts_dict[contact.priority] = [contact]
-
- if num_resources == 1 and contact.resource:
- properties.append((_('Resource: '),
- gtkgui_helpers.escape_for_pango_markup(contact.resource) + ' (' + \
- unicode(contact.priority) + ')'))
if num_resources > 1:
properties.append((_('Status: '), ' '))
contact_keys = contacts_dict.keys()
@@ -540,6 +519,26 @@ class RosterTooltip(NotificationAreaTooltip):
else: # only one resource
if contact.show:
show = helpers.get_uf_show(contact.show)
+ if contact.last_status_time:
+ vcard_current_row += 1
+ if contact.show == 'offline':
+ text = ' - ' + _('Last status : %s')
+ else:
+ text = _(' since %s')
+
+ if time.strftime('%j', time.localtime())== \
+ time.strftime('%j', contact.last_status_time):
+ # it's today, show only the locale hour representation
+ local_time = time.strftime('%X', contact.last_status_time)
+ else:
+ # time.strftime returns locale encoded string
+ local_time = time.strftime('%c', contact.last_status_time)
+ local_time = local_time.decode(locale.getpreferredencoding())
+ text = text % local_time
+ show += text
+ show = u'' + show + ''
+ # we append show at end of properties below
+
if contact.status:
status = contact.status.strip()
if status:
@@ -548,26 +547,32 @@ class RosterTooltip(NotificationAreaTooltip):
status = gtkgui_helpers.reduce_chars_newlines(status, 200, 5)
# escape markup entities.
status = gtkgui_helpers.escape_for_pango_markup(status)
- show += ' - ' + status
- properties.append((_('Status: '), show))
-
- if contact.last_status_time:
- vcard_current_row += 1
- if contact.show == 'offline':
- text = _('Last status on %s')
- else:
- text = _('Since %s')
-
- if time.strftime('%j', time.localtime())== \
- time.strftime('%j', contact.last_status_time):
- # it's today, show only the locale hour representation
- local_time = time.strftime('%X', contact.last_status_time)
- else:
- # time.strftime returns locale encoded string
- local_time = time.strftime('%c', contact.last_status_time)
- local_time = local_time.decode(locale.getpreferredencoding())
- text = text % local_time
- properties.append(('%s' % text, None))
+ properties.append((u'%s' % status, None))
+
+
+ properties.append((_('Jabber ID: '), prim_contact.jid ))
+ if prim_contact.sub and prim_contact.sub != 'both':
+ # ('both' is the normal sub so we don't show it)
+ properties.append(( _('Subscription: '),
+ gtkgui_helpers.escape_for_pango_markup(helpers.get_uf_sub(prim_contact.sub))))
+ if prim_contact.keyID:
+ keyID = None
+ if len(prim_contact.keyID) == 8:
+ keyID = prim_contact.keyID
+ elif len(prim_contact.keyID) == 16:
+ keyID = prim_contact.keyID[8:]
+ if keyID:
+ properties.append((_('OpenPGP: '),
+ gtkgui_helpers.escape_for_pango_markup(keyID)))
+
+ if num_resources <= 1:
+ # contact is offline(show only show) or has only one ressource
+ if num_resources == 1 and contact.resource:
+ properties.append((_('Resource: '),
+ gtkgui_helpers.escape_for_pango_markup(contact.resource) + ' (' + \
+ unicode(contact.priority) + ')'))
+ properties.append((show, None))
+
while properties:
property = properties.pop(0)
vcard_current_row += 1