diff -r 89f0828cd6be -r 3e2a626e68d8 src/chat_control.py --- a/src/chat_control.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/chat_control.py Mon Jul 20 04:43:34 2009 +0100 @@ -1317,7 +1317,7 @@ else: self._convert_to_gc_button.set_sensitive(False) - def update_mood(self): + def update_mood(self, jid=None): mood = None text = None @@ -1395,7 +1395,7 @@ else: self._activity_image.hide() - def update_tune(self): + def update_tune(self, jid=None): artist = None title = None source = None diff -r 89f0828cd6be -r 3e2a626e68d8 src/common/connection_handlers.py --- a/src/common/connection_handlers.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/common/connection_handlers.py Mon Jul 20 04:43:34 2009 +0100 @@ -1822,8 +1822,6 @@ mtype = msg.getType() # check if the message is pubsub#event if msg.getTag('event') is not None: - if mtype == 'groupchat': - return if msg.getTag('error') is None: self._pubsubEventCB(con, msg) return @@ -2101,16 +2099,16 @@ # XEP-0107: User Mood items = event.getTag('items', {'node': common.xmpp.NS_MOOD}) - if items: pep.user_mood(items, self.name, jid) + if items: pep.user_mood(items, self.name, jid, msg.getType() == 'groupchat') # XEP-0118: User Tune items = event.getTag('items', {'node': common.xmpp.NS_TUNE}) - if items: pep.user_tune(items, self.name, jid) + if items: pep.user_tune(items, self.name, jid, msg.getType() == 'groupchat') # XEP-0080: User Geolocation items = event.getTag('items', {'node': common.xmpp.NS_GEOLOC}) if items: pep.user_geoloc(items, self.name, jid) # XEP-0108: User Activity items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY}) - if items: pep.user_activity(items, self.name, jid) + if items: pep.user_activity(items, self.name, jid, msg.getType() == 'groupchat') # XEP-0172: User Nickname items = event.getTag('items', {'node': common.xmpp.NS_NICK}) if items: pep.user_nickname(items, self.name, jid) diff -r 89f0828cd6be -r 3e2a626e68d8 src/common/contacts.py --- a/src/common/contacts.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/common/contacts.py Mon Jul 20 04:43:34 2009 +0100 @@ -139,7 +139,7 @@ '''Information concerning each groupchat contact''' def __init__(self, room_jid='', name='', show='', status='', role='', affiliation='', jid = '', resource = '', our_chatstate = None, - composing_xep = None, chatstate = None): + composing_xep = None, chatstate = None, tune = {}, mood = {}, activity = {}): self.room_jid = room_jid self.name = name self.show = show @@ -154,7 +154,10 @@ self.our_chatstate = our_chatstate self.composing_xep = composing_xep self.chatstate = chatstate - + self.tune = tune + self.mood = mood + self.activity = activity + def get_full_jid(self): return self.room_jid + '/' + self.name @@ -583,9 +586,9 @@ caps_hash=gc_contact.caps_hash) def create_gc_contact(self, room_jid='', name='', show='', status='', - role='', affiliation='', jid='', resource=''): + role='', affiliation='', jid='', resource='', tune={}, mood={}, activity={}): return GC_Contact(room_jid, name, show, status, role, affiliation, jid, - resource) + resource, tune=tune, mood=mood, activity=activity) def add_gc_contact(self, account, gc_contact): # No such account before ? diff -r 89f0828cd6be -r 3e2a626e68d8 src/common/pep.py --- a/src/common/pep.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/common/pep.py Mon Jul 20 04:43:34 2009 +0100 @@ -192,7 +192,7 @@ 'studying': _('Studying'), 'writing': _('Writing')}} -def user_mood(items, name, jid): +def user_mood(items, name, jid, is_gc): has_child = False retract = False mood = None @@ -227,30 +227,52 @@ del acc.mood['text'] (user, resource) = common.gajim.get_room_and_nick_from_fjid(jid) - for contact in common.gajim.contacts.get_contacts(name, user): - if has_child: - if 'mood' in contact.mood: - del contact.mood['mood'] - if 'text' in contact.mood: - del contact.mood['text'] - if mood is not None: - contact.mood['mood'] = mood - if text is not None: - contact.mood['text'] = text - elif retract: - if 'mood' in contact.mood: - del contact.mood['mood'] - if 'text' in contact.mood: - del contact.mood['text'] - + if not is_gc: + for contact in common.gajim.contacts.get_contacts(name, user): + if has_child: + if 'mood' in contact.mood: + del contact.mood['mood'] + if 'text' in contact.mood: + del contact.mood['text'] + if mood is not None: + contact.mood['mood'] = mood + if text is not None: + contact.mood['text'] = text + elif retract: + if 'mood' in contact.mood: + del contact.mood['mood'] + if 'text' in contact.mood: + del contact.mood['text'] + else: + acc = common.gajim.connections[name] + room_jid, nick = common.gajim.get_room_and_nick_from_fjid(jid) + contact = common.gajim.contacts.get_gc_contact(name, room_jid, nick) + if contact: + if has_child: + if 'mood' in contact.mood: + del contact.mood['mood'] + if 'text' in contact.mood: + del contact.mood['text'] + if mood is not None: + contact.mood['mood'] = mood + if text is not None: + contact.mood['text'] = text + elif retract: + if 'mood' in contact.mood: + del contact.mood['mood'] + if 'text' in contact.mood: + del contact.mood['text'] + if jid == common.gajim.get_jid_from_account(name): common.gajim.interface.roster.draw_account(name) - common.gajim.interface.roster.draw_mood(user, name) + if not is_gc: + common.gajim.interface.roster.draw_mood(user, name) + ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name) if ctrl: - ctrl.update_mood() + ctrl.update_mood(jid) -def user_tune(items, name, jid): +def user_tune(items, name, jid, is_gc): has_child = False retract = False artist = None @@ -259,6 +281,8 @@ track = None length = None + + for item in items.getTags('item'): child = item.getTag('tune') if child is not None: @@ -313,51 +337,91 @@ del acc.tune['length'] user = common.gajim.get_room_and_nick_from_fjid(jid)[0] - for contact in common.gajim.contacts.get_contacts(name, user): - if has_child: - if 'artist' in contact.tune: - del contact.tune['artist'] - if 'title' in contact.tune: - del contact.tune['title'] - if 'source' in contact.tune: - del contact.tune['source'] - if 'track' in contact.tune: - del contact.tune['track'] - if 'length' in contact.tune: - del contact.tune['length'] - if artist is not None: - contact.tune['artist'] = artist - if title is not None: - contact.tune['title'] = title - if source is not None: - contact.tune['source'] = source - if track is not None: - contact.tune['track'] = track - if length is not None: - contact.tune['length'] = length - elif retract: - if 'artist' in contact.tune: - del contact.tune['artist'] - if 'title' in contact.tune: - del contact.tune['title'] - if 'source' in contact.tune: - del contact.tune['source'] - if 'track' in contact.tune: - del contact.tune['track'] - if 'length' in contact.tune: - del contact.tune['length'] + if not is_gc: + for contact in common.gajim.contacts.get_contacts(name, user): + if has_child: + if 'artist' in contact.tune: + del contact.tune['artist'] + if 'title' in contact.tune: + del contact.tune['title'] + if 'source' in contact.tune: + del contact.tune['source'] + if 'track' in contact.tune: + del contact.tune['track'] + if 'length' in contact.tune: + del contact.tune['length'] + if artist is not None: + contact.tune['artist'] = artist + if title is not None: + contact.tune['title'] = title + if source is not None: + contact.tune['source'] = source + if track is not None: + contact.tune['track'] = track + if length is not None: + contact.tune['length'] = length + elif retract: + if 'artist' in contact.tune: + del contact.tune['artist'] + if 'title' in contact.tune: + del contact.tune['title'] + if 'source' in contact.tune: + del contact.tune['source'] + if 'track' in contact.tune: + del contact.tune['track'] + if 'length' in contact.tune: + del contact.tune['length'] + else: + acc = common.gajim.connections[name] + room_jid, nick = common.gajim.get_room_and_nick_from_fjid(jid) + contact = common.gajim.contacts.get_gc_contact(name, room_jid, nick) + if contact: + if has_child: + if 'artist' in contact.tune: + del contact.tune['artist'] + if 'title' in contact.tune: + del contact.tune['title'] + if 'source' in contact.tune: + del contact.tune['source'] + if 'track' in contact.tune: + del contact.tune['track'] + if 'length' in contact.tune: + del contact.tune['length'] + if artist is not None: + contact.tune['artist'] = artist + if title is not None: + contact.tune['title'] = title + if source is not None: + contact.tune['source'] = source + if track is not None: + contact.tune['track'] = track + if length is not None: + contact.tune['length'] = length + elif retract: + if 'artist' in contact.tune: + del contact.tune['artist'] + if 'title' in contact.tune: + del contact.tune['title'] + if 'source' in contact.tune: + del contact.tune['source'] + if 'track' in contact.tune: + del contact.tune['track'] + if 'length' in contact.tune: + del contact.tune['length'] + if jid == common.gajim.get_jid_from_account(name): common.gajim.interface.roster.draw_account(name) - common.gajim.interface.roster.draw_tune(user, name) + if not is_gc: + common.gajim.interface.roster.draw_tune(user, name) ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name) if ctrl: - ctrl.update_tune() + ctrl.update_tune(jid) def user_geoloc(items, name, jid): pass -def user_activity(items, name, jid): +def user_activity(items, name, jid, is_gc): has_child = False retract = False activity = None @@ -402,34 +466,61 @@ del acc.activity['text'] user = common.gajim.get_room_and_nick_from_fjid(jid)[0] - for contact in common.gajim.contacts.get_contacts(name, user): - if has_child: - if 'activity' in contact.activity: - del contact.activity['activity'] - if 'subactivity' in contact.activity: - del contact.activity['subactivity'] - if 'text' in contact.activity: - del contact.activity['text'] - if activity is not None: - contact.activity['activity'] = activity - if subactivity is not None and subactivity != 'other': - contact.activity['subactivity'] = subactivity - if text is not None: - contact.activity['text'] = text - elif retract: - if 'activity' in contact.activity: - del contact.activity['activity'] - if 'subactivity' in contact.activity: - del contact.activity['subactivity'] - if 'text' in contact.activity: - del contact.activity['text'] - + if not is_gc: + for contact in common.gajim.contacts.get_contacts(name, user): + if has_child: + if 'activity' in contact.activity: + del contact.activity['activity'] + if 'subactivity' in contact.activity: + del contact.activity['subactivity'] + if 'text' in contact.activity: + del contact.activity['text'] + if activity is not None: + contact.activity['activity'] = activity + if subactivity is not None and subactivity != 'other': + contact.activity['subactivity'] = subactivity + if text is not None: + contact.activity['text'] = text + elif retract: + if 'activity' in contact.activity: + del contact.activity['activity'] + if 'subactivity' in contact.activity: + del contact.activity['subactivity'] + if 'text' in contact.activity: + del contact.activity['text'] + else: + acc = common.gajim.connections[name] + room_jid, nick = common.gajim.get_room_and_nick_from_fjid(jid) + contact = common.gajim.contacts.get_gc_contact(name, room_jid, nick) + if contact: + if has_child: + if 'activity' in contact.activity: + del contact.activity['activity'] + if 'subactivity' in contact.activity: + del contact.activity['subactivity'] + if 'text' in contact.activity: + del contact.activity['text'] + if activity is not None: + contact.activity['activity'] = activity + if subactivity is not None and subactivity != 'other': + contact.activity['subactivity'] = subactivity + if text is not None: + contact.activity['text'] = text + elif retract: + if 'activity' in contact.activity: + del contact.activity['activity'] + if 'subactivity' in contact.activity: + del contact.activity['subactivity'] + if 'text' in contact.activity: + del contact.activity['text'] + if jid == common.gajim.get_jid_from_account(name): common.gajim.interface.roster.draw_account(name) - common.gajim.interface.roster.draw_activity(user, name) + if not is_gc: + common.gajim.interface.roster.draw_activity(user, name) ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name) if ctrl: - ctrl.update_activity() + ctrl.update_activity(jid) def user_nickname(items, name, jid): has_child = False @@ -481,6 +572,10 @@ common.gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0') + + for room_jid in common.gajim.gc_connected[account]: + common.gajim.connections[account].send_pb_publish(room_jid, xmpp.NS_MOOD, item, + '0') def user_send_activity(account, activity, subactivity='', message=''): if not common.gajim.connections[account].pep_supported: @@ -497,6 +592,10 @@ common.gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0') + for room_jid in common.gajim.gc_connected[account]: + common.gajim.connections[account].send_pb_publish(room_jid, xmpp.NS_ACTIVITY, item, + '0') + def user_send_tune(account, artist='', title='', source='', track=0, length=0, items=None): if not (common.gajim.config.get_per('accounts', account, 'publish_tune') and\ @@ -523,7 +622,11 @@ common.gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0') - + + for room_jid in common.gajim.gc_connected[account]: + common.gajim.connections[account].send_pb_publish(room_jid, xmpp.NS_TUNE, item, + '0') + def user_send_nickname(account, nick): if not common.gajim.connections[account].pep_supported: return diff -r 89f0828cd6be -r 3e2a626e68d8 src/groupchat_control.py --- a/src/groupchat_control.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/groupchat_control.py Mon Jul 20 04:43:34 2009 +0100 @@ -42,6 +42,7 @@ from common import gajim from common import helpers +from common.pep import MOODS, ACTIVITIES from chat_control import ChatControl from chat_control import ChatControlBase @@ -54,7 +55,10 @@ C_TYPE, # type of the row ('contact' or 'role') C_TEXT, # text shown in the cellrenderer C_AVATAR, # avatar of the contact -) = range(5) +C_TUNE, # user tune of the contact +C_MOOD, # mood of the contact +C_ACTIVITY # activity of the contact +) = range(8) def set_renderer_color(treeview, renderer, set_background=True): '''set style for group row, using PRELIGHT system color''' @@ -64,6 +68,83 @@ else: fgcolor = treeview.style.fg[gtk.STATE_PRELIGHT] renderer.set_property('foreground-gdk', fgcolor) + +def _fill_mood_pixbuf_renderer(column, renderer, model, titer, + data = None): + '''When a row is added, set properties for avatar renderer''' + theme = gajim.config.get('roster_theme') + type_ = model[titer][C_TYPE] + if type_ == 'group': + renderer.set_property('visible', False) + return + # allocate space for the icon only if needed + if model[titer][C_MOOD]: + renderer.set_property('visible', True) + else: + renderer.set_property('visible', False) + +# if not model[titer][C_JID] \ +# or not model[titer][C_ACCOUNT]: +# # This can append at the moment we add the row +# return + color = gajim.config.get_per('themes', + theme, 'contactbgcolor') + if color: + renderer.set_property( + 'cell-background', color) + else: + renderer.set_property( + 'cell-background', None) + + # align pixbuf to the right + renderer.set_property('xalign', 1) + +def _fill_activity_pixbuf_renderer(column, renderer, model, titer, + data = None): + '''When a row is added, set properties for avatar renderer''' + theme = gajim.config.get('roster_theme') + type_ = model[titer][C_TYPE] + if type_ == 'group': + renderer.set_property('visible', False) + return + # allocate space for the icon only if needed + if model[titer][C_ACTIVITY]: + renderer.set_property('visible', True) + else: + renderer.set_property('visible', False) + +# if not model[titer][C_JID] \ +# or not model[titer][C_ACCOUNT]: +# # This can append at the moment we add the row +# return + color = gajim.config.get_per('themes', + theme, 'contactbgcolor') + if color: + renderer.set_property( + 'cell-background', color) + else: + renderer.set_property( + 'cell-background', None) + + # align pixbuf to the right + renderer.set_property('xalign', 1) + +def _fill_tune_pixbuf_renderer(column, renderer, model, titer, + data = None): + '''When a row is added, set properties for avatar renderer''' + theme = gajim.config.get('roster_theme') + + if not model.iter_parent(titer): # is a group header + renderer.set_property('visible', False) + return + + # allocate space for the icon only if needed + if model[titer][C_TUNE]: + renderer.set_property('visible', True) + else: + renderer.set_property('visible', False) + # align pixbuf to the right) + renderer.set_property('xalign', 1) def tree_cell_data_func(column, renderer, model, iter_, tv=None): # cell data func is global, because we don't want it to keep @@ -166,8 +247,7 @@ def update_contact(self): self.contact = gajim.contacts.contact_from_gc_contact(self.gc_contact) - - + class GroupchatControl(ChatControlBase): TYPE_ID = message_control.TYPE_GC # alphanum sorted @@ -299,7 +379,7 @@ self.on_treeview_size_allocate) self.handlers[id_] = self.list_treeview #status_image, shown_nick, type, nickname, avatar - store = gtk.TreeStore(gtk.Image, str, str, str, gtk.gdk.Pixbuf) + store = gtk.TreeStore(gtk.Image, str, str, str, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) store.set_sort_func(C_NICK, self.tree_compare_iters) store.set_sort_column_id(C_NICK, gtk.SORT_ASCENDING) self.list_treeview.set_model(store) @@ -334,6 +414,24 @@ column.set_cell_data_func(renderer_text, tree_cell_data_func, self.list_treeview) + render_pixbuf = gtk.CellRendererPixbuf() # tune icon + column.pack_start(render_pixbuf, expand=False) + column.add_attribute(render_pixbuf, 'pixbuf', C_TUNE) + column.set_cell_data_func(render_pixbuf, _fill_tune_pixbuf_renderer, + self.list_treeview) + + render_pixbuf = gtk.CellRendererPixbuf() # mood icon + column.pack_start(render_pixbuf, expand=False) + column.add_attribute(render_pixbuf, 'pixbuf', C_MOOD) + column.set_cell_data_func(render_pixbuf, _fill_mood_pixbuf_renderer, + self.list_treeview) + + render_pixbuf = gtk.CellRendererPixbuf() # activity icon + column.pack_start(render_pixbuf, expand=False) + column.add_attribute(render_pixbuf, 'pixbuf', C_ACTIVITY) + column.set_cell_data_func(render_pixbuf, _fill_activity_pixbuf_renderer, + self.list_treeview) + if gajim.config.get('avatar_position_in_roster') == 'right': add_avatar_renderer() @@ -516,6 +614,36 @@ for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): self.draw_contact(nick) + def update_tune(self, jid=None): + if not jid: + return + + nick = gajim.get_room_and_nick_from_fjid(jid)[1] + iter_ = self.get_contact_iter(nick) + contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + self.nick) + self.draw_tune(nick) + + def update_mood(self, jid=None): + if not jid: + return + + nick = gajim.get_room_and_nick_from_fjid(jid)[1] + iter_ = self.get_contact_iter(nick) + contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + self.nick) + self.draw_mood(nick) + + def update_activity(self, jid=None): + if not jid: + return + + nick = gajim.get_room_and_nick_from_fjid(jid)[1] + iter_ = self.get_contact_iter(nick) + contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + self.nick) + self.draw_activity(nick) + def _change_style(self, model, path, iter_): model[iter_][C_NICK] = model[iter_][C_NICK] @@ -1072,6 +1200,9 @@ image = gtk.image_new_from_pixbuf(pixbuf1) model[iter_][C_IMG] = image model[iter_][C_TEXT] = name + self.draw_tune(nick) + self.draw_mood(nick) + self.draw_activity(nick) def draw_avatar(self, nick): if not gajim.config.get('show_avatars_in_roster'): @@ -1103,6 +1234,72 @@ def draw_all_roles(self): for role in ('visitor', 'participant', 'moderator'): self.draw_role(role) + + def draw_tune(self, nick): + model = self.list_treeview.get_model() + iter_ = self.get_contact_iter(nick) + if not iter_: + return + gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + nick) + + if ('artist' in gc_contact.tune or 'title' in gc_contact.tune): + path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png') + pixbuf = gtk.gdk.pixbuf_new_from_file(path) + else: + pixbuf = None + model[iter_][C_TUNE] = pixbuf + return False + + def draw_mood(self, nick): + model = self.list_treeview.get_model() + iter_ = self.get_contact_iter(nick) + if not iter_: + return + gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + nick) + + if 'mood' in gc_contact.mood and gc_contact.mood['mood'].strip() in MOODS: + pixbuf = gtkgui_helpers.load_mood_icon( + gc_contact.mood['mood'].strip()).get_pixbuf() + elif 'mood' in gc_contact.mood: + pixbuf = gtkgui_helpers.load_mood_icon( + 'unknown').get_pixbuf() + else: + pixbuf = None + + model[iter_][C_MOOD] = pixbuf + + return False + + def draw_activity(self, nick): + model = self.list_treeview.get_model() + iter_ = self.get_contact_iter(nick) + if not iter_: + return + gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, + nick) + + if 'activity' in gc_contact.activity \ + and gc_contact.activity['activity'].strip() in ACTIVITIES: + if 'subactivity' in gc_contact.activity \ + and gc_contact.activity['subactivity'].strip() in \ + ACTIVITIES[gc_contact.activity['activity'].strip()]: + pixbuf = gtkgui_helpers.load_activity_icon( + gc_contact.activity['activity'].strip(), + gc_contact.activity['subactivity'].strip()).get_pixbuf() + else: + pixbuf = gtkgui_helpers.load_activity_icon( + gc_contact.activity['activity'].strip()).get_pixbuf() + elif 'activity' in gc_contact.activity: + pixbuf = gtkgui_helpers.load_activity_icon( + 'unknown').get_pixbuf() + else: + pixbuf = None + + model[iter_][C_ACTIVITY] = pixbuf + + return False def chg_contact_status(self, nick, show, status, role, affiliation, jid, reason, actor, statusCode, new_nick, avatar_sha, tim=None): @@ -1382,13 +1579,13 @@ if not role_iter: role_iter = model.append(None, (gajim.interface.jabber_state_images['16']['closed'], role, - 'role', role_name, None)) + 'role', role_name, None, None, None, None)) self.draw_all_roles() - iter_ = model.append(role_iter, (None, nick, 'contact', name, None)) + iter_ = model.append(role_iter, (None, nick, 'contact', name, None, None, None, None)) if not nick in gajim.contacts.get_nick_list(self.account, self.room_jid): gc_contact = gajim.contacts.create_gc_contact(room_jid=self.room_jid, name=nick, show=show, status=status, role=role, - affiliation=affiliation, jid=j, resource=resource) + affiliation=affiliation, jid=j, resource=resource, tune={}, mood={}, activity={}) gajim.contacts.add_gc_contact(self.account, gc_contact) self.draw_contact(nick) self.draw_avatar(nick) diff -r 89f0828cd6be -r 3e2a626e68d8 src/tooltips.py --- a/src/tooltips.py Wed Jul 08 21:41:40 2009 +0200 +++ b/src/tooltips.py Mon Jul 20 04:43:34 2009 +0100 @@ -335,6 +335,9 @@ {'owner_or_admin_or_member': uf_affiliation} properties.append((affiliation_str, None)) + + self._append_pep_info(contact, properties) + # Add avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) @@ -377,6 +380,73 @@ gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3) self.win.add(vcard_table) + def _append_pep_info(self, contact, properties): + ''' + Append Tune, Mood, Activity information of the specified contact + to the given property list. + ''' + if 'mood' in contact.mood: + mood = contact.mood['mood'].strip() + mood = MOODS.get(mood, mood) + mood = gobject.markup_escape_text(mood) + mood_string = _('Mood:') + ' %s' % mood + if 'text' in contact.mood \ + and contact.mood['text'] != '': + mood_text = contact.mood['text'].strip() + mood_text = \ + gobject.markup_escape_text(mood_text) + mood_string += ' (%s)' % mood_text + properties.append((mood_string, None)) + + if 'activity' in contact.activity: + activity = act_plain = \ + contact.activity['activity'].strip() + activity = gobject.markup_escape_text(activity) + if act_plain in ACTIVITIES: + activity = ACTIVITIES[activity]['category'] + activity_string = _('Activity:') + ' %s' % activity + if 'subactivity' in contact.activity: + activity_sub = \ + contact.activity['subactivity'].strip() + if act_plain in ACTIVITIES and activity_sub in \ + ACTIVITIES[act_plain]: + activity_sub = ACTIVITIES[act_plain][activity_sub] + activity_sub = \ + gobject.markup_escape_text(activity_sub) + activity_string += ': %s' % activity_sub + else: + activity_string += '' + if 'text' in contact.activity: + activity_text = contact.activity['text'].strip() + activity_text = gobject.markup_escape_text( + activity_text) + activity_string += ' (%s)' % activity_text + properties.append((activity_string, None)) + + if 'artist' in contact.tune \ + or 'title' in contact.tune: + if 'artist' in contact.tune: + artist = contact.tune['artist'].strip() + artist = gobject.markup_escape_text(artist) + else: + artist = _('Unknown Artist') + if 'title' in contact.tune: + title = contact.tune['title'].strip() + title = gobject.markup_escape_text(title) + else: + title = _('Unknown Title') + if 'source' in contact.tune: + source = contact.tune['source'].strip() + source = gobject.markup_escape_text(source) + else: + source = _('Unknown Source') + tune_string = _('Tune:') + ' ' + \ + _('"%(title)s" by %(artist)s\n' + 'from %(source)s') % {'title': title, + 'artist': artist, 'source': source} + properties.append((tune_string, None)) + + class RosterTooltip(NotificationAreaTooltip): ''' Tooltip that is shown in the roster treeview ''' def __init__(self):