def populate(self, contact): """ Populate the Tooltip Grid with data of from the contact """ self.clear_tooltip() self.nick.set_text(contact.get_shown_name()) self.nick.show() # Status Message if contact.status: status = contact.status.strip() if status != '': self.status.set_text(status) self.status.show() # Status show = helpers.get_uf_show(contact.show) self.user_show.set_markup(colorize_status(show)) self.user_show.show() # JID if contact.jid.strip(): self.jid.set_text(contact.jid) self.jid.show() self.jid_label.show() # Resource if hasattr(contact, 'resource') and contact.resource.strip(): self.resource.set_text(contact.resource) self.resource.show() self.resource_label.show() # Affiliation if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) uf_affiliation = \ _('%(owner_or_admin_or_member)s of this group chat') \ % {'owner_or_admin_or_member': uf_affiliation} uf_affiliation = self.colorize_affiliation(uf_affiliation) self.affiliation.set_markup(uf_affiliation) self.affiliation.show() # Avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room, puny_name)) if file_: with open(file_, 'rb') as file_data: pix = gtkgui_helpers.get_pixbuf_from_data(file_data.read()) pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip') self.avatar.set_from_pixbuf(pix) self.avatar.show() self.fillelement.show()
def names(self, verbose=False): ggc = gajim.contacts.get_gc_contact gnl = gajim.contacts.get_nick_list get_contact = lambda nick: ggc(self.account, self.room_jid, nick) get_role = lambda nick: get_contact(nick).role nicks = gnl(self.account, self.room_jid) nicks = sorted(nicks) nicks = sorted(nicks, key=get_role) if not verbose: return ", ".join(nicks) for nick in nicks: contact = get_contact(nick) role = helpers.get_uf_role(contact.role) affiliation = helpers.get_uf_affiliation(contact.affiliation) self.echo("%s - %s - %s" % (nick, role, affiliation))
def populate(self, contact): if not contact: return self.create_window() vcard_table = gtk.Table(3, 1) vcard_table.set_property('column-spacing', 2) vcard_table.set_homogeneous(False) vcard_current_row = 1 properties = [] nick_markup = '<b>' + \ gobject.markup_escape_text(contact.get_shown_name()) \ + '</b>' properties.append((nick_markup, None)) if contact.status: # status message status = contact.status.strip() if status != '': # escape markup entities status = helpers.reduce_chars_newlines(status, 300, 5) status = '<i>' +\ gobject.markup_escape_text(status) + '</i>' properties.append((status, None)) else: # no status message, show SHOW instead show = helpers.get_uf_show(contact.show) show = '<i>' + show + '</i>' properties.append((show, None)) if contact.jid.strip() != '': properties.append((_('Jabber ID: '), contact.jid)) if hasattr(contact, 'resource') and contact.resource.strip() != '': properties.append((_('Resource: '), gobject.markup_escape_text(contact.resource) )) if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) affiliation_str = \ _('%(owner_or_admin_or_member)s of this group chat') %\ {'owner_or_admin_or_member': uf_affiliation} properties.append((affiliation_str, None)) # Add avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room, puny_name)) if file: self.avatar_image.set_from_file(file) pix = self.avatar_image.get_pixbuf() pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip') self.avatar_image.set_from_pixbuf(pix) else: self.avatar_image.set_from_pixbuf(None) while properties: property = properties.pop(0) vcard_current_row += 1 vertical_fill = gtk.FILL if not properties: vertical_fill |= gtk.EXPAND label = gtk.Label() label.set_alignment(0, 0) if property[1]: label.set_markup(property[0]) vcard_table.attach(label, 1, 2, vcard_current_row, vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0) label = gtk.Label() label.set_alignment(0, 0) label.set_markup(property[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, 3, vcard_current_row, vcard_current_row + 1, gtk.EXPAND | gtk.FILL, vertical_fill, 0, 0) else: label.set_markup(property[0]) label.set_line_wrap(True) vcard_table.attach(label, 1, 3, vcard_current_row, vcard_current_row + 1, gtk.FILL, vertical_fill, 0) self.avatar_image.set_alignment(0, 0) vcard_table.attach(self.avatar_image, 3, 4, 2, vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3) self.win.add(vcard_table)
def populate(self, contact): if not contact: return self.create_window() vcard_table = Gtk.Grid() vcard_table.insert_row(0) vcard_table.insert_row(0) vcard_table.insert_row(0) vcard_table.insert_column(0) vcard_table.set_property('column-spacing', 2) vcard_current_row = 1 properties = [] nick_markup = '<b>' + GLib.markup_escape_text(contact.get_shown_name())\ + '</b>' properties.append((nick_markup, None)) if contact.status: # status message status = contact.status.strip() if status != '': # escape markup entities status = helpers.reduce_chars_newlines(status, 300, 5) status = '<i>' + GLib.markup_escape_text(status) + '</i>' properties.append((status, None)) show = helpers.get_uf_show(contact.show) show = self.colorize_status(show) properties.append((show, None)) if contact.jid.strip(): properties.append((_('Jabber ID: '), '\u200E' + "<b>%s</b>" % \ contact.jid)) if hasattr(contact, 'resource') and contact.resource.strip(): properties.append((_('Resource: '), GLib.markup_escape_text( contact.resource))) if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) uf_affiliation = \ _('%(owner_or_admin_or_member)s of this group chat') % \ {'owner_or_admin_or_member': uf_affiliation} uf_affiliation = self.colorize_affiliation(uf_affiliation) properties.append((uf_affiliation, None)) # Add avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room, puny_name)) if file_: with open(file_, 'rb') as file_data: pix = gtkgui_helpers.get_pixbuf_from_data(file_data.read()) pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip') self.avatar_image.set_from_pixbuf(pix) else: self.avatar_image.set_from_pixbuf(None) while properties: property_ = properties.pop(0) vcard_current_row += 1 label = Gtk.Label() if not properties: label.set_vexpand(True) label.set_halign(Gtk.Align.START) label.set_valign(Gtk.Align.START) if property_[1]: label.set_markup(property_[0]) vcard_table.attach(label, 1, vcard_current_row, 1, 1) label = Gtk.Label() if not properties: label.set_vexpand(True) label.set_halign(Gtk.Align.START) label.set_valign(Gtk.Align.START) label.set_markup(property_[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, vcard_current_row, 1, 1) else: label.set_markup(property_[0]) label.set_line_wrap(True) vcard_table.attach(label, 1, vcard_current_row, 2, 1) self.avatar_image.set_halign(Gtk.Align.START) self.avatar_image.set_valign(Gtk.Align.START) vcard_table.attach(self.avatar_image, 3, 2, 1, vcard_current_row - 1) gajim.plugin_manager.gui_extension_point('gc_tooltip_populate', self, contact, vcard_table) self.win.add(vcard_table)
def fill_jabber_page(self): self.xml.get_object('nickname_label').set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + '</span></b>') self.xml.get_object('jid_label').set_text(self.contact.jid) subscription_label = self.xml.get_object('subscription_label') ask_label = self.xml.get_object('ask_label') if self.gc_contact: self.xml.get_object('subscription_title_label').set_markup(Q_("?Role in Group Chat:<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_object('ask_title_label').set_markup(_("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation(self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) eb = self.xml.get_object('subscription_label_eventbox') if self.contact.sub == 'from': tt_text = _("This contact is interested in your presence information, but you are not interested in his/her presence") elif self.contact.sub == 'to': tt_text = _("You are interested in the contact's presence information, but he/she is not interested in yours") elif self.contact.sub == 'both': tt_text = _("You and the contact are interested in each other's presence information") else: # None tt_text = _("You are not interested in the contact's presence, and neither he/she is interested in yours") eb.set_tooltip_text(tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) eb = self.xml.get_object('ask_label_eventbox') if self.contact.ask == 'subscribe': tt_text = _("You are waiting contact's answer about your subscription request") else: tt_text = _("There is no pending subscription request.") eb.set_tooltip_text(tt_text) resources = '%s (%s)' % (self.contact.resource, unicode( self.contact.priority)) uf_resources = self.contact.resource + _(' resource with priority ')\ + unicode(self.contact.priority) if not self.contact.status: self.contact.status = '' # Request list time status only if contact is offline if self.contact.show == 'offline': if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gajim.connections[self.account].request_last_status_time(j, r, self.contact.jid) else: gajim.connections[self.account].request_last_status_time( self.contact.jid, '') # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gobject.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: gobject.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gobject.idle_add(gajim.connections[self.account].\ request_entity_time, j, r, self.contact.jid) else: gobject.idle_add(gajim.connections[self.account].\ request_entity_time, self.contact.jid, self.contact.resource) self.os_info = {0: {'resource': self.real_resource, 'client': '', 'os': ''}} self.time_info = {0: {'resource': self.real_resource, 'time': ''}} i = 1 contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += '\n%s (%s)' % (c.resource, unicode(c.priority)) uf_resources += '\n' + c.resource + \ _(' resource with priority ') + unicode(c.priority) if c.show not in ('offline', 'error'): gobject.idle_add( gajim.connections[self.account].request_os_info, c.jid, c.resource) gobject.idle_add(gajim.connections[self.account].\ request_entity_time, c.jid, c.resource) self.os_info[i] = {'resource': c.resource, 'client': '', 'os': ''} self.time_info[i] = {'resource': c.resource, 'time': ''} i += 1 self.xml.get_object('resource_prio_label').set_text(resources) resource_prio_label_eventbox = self.xml.get_object( 'resource_prio_label_eventbox') resource_prio_label_eventbox.set_tooltip_text(uf_resources) self.fill_status_label() if self.gc_contact: # If we know the real jid, remove the resource from vcard request gajim.connections[self.account].request_vcard(self.real_jid_for_vcard, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)
def fill_jabber_page(self): self.xml.get_object("nickname_label").set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + "</span></b>" ) self.xml.get_object("jid_label").set_text(self.contact.jid) subscription_label = self.xml.get_object("subscription_label") ask_label = self.xml.get_object("ask_label") if self.gc_contact: self.xml.get_object("subscription_title_label").set_markup(Q_("?Role in Group Chat:<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_object("ask_title_label").set_markup(_("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation(self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) eb = self.xml.get_object("subscription_label_eventbox") if self.contact.sub == "from": tt_text = _( "This contact is interested in your presence information, but you are not interested in his/her presence" ) elif self.contact.sub == "to": tt_text = _( "You are interested in the contact's presence information, but he/she is not interested in yours" ) elif self.contact.sub == "both": tt_text = _("You and the contact are interested in each other's presence information") else: # None tt_text = _( "You are not interested in the contact's presence, and neither he/she is interested in yours" ) eb.set_tooltip_text(tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) eb = self.xml.get_object("ask_label_eventbox") if self.contact.ask == "subscribe": tt_text = _("You are waiting contact's answer about your subscription request") else: tt_text = _("There is no pending subscription request.") eb.set_tooltip_text(tt_text) resources = "%s (%s)" % (self.contact.resource, str(self.contact.priority)) uf_resources = self.contact.resource + _(" resource with priority ") + str(self.contact.priority) if not self.contact.status: self.contact.status = "" # Request list time status only if contact is offline if self.contact.show == "offline": if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gajim.connections[self.account].request_last_status_time(j, r, self.contact.jid) else: gajim.connections[self.account].request_last_status_time(self.contact.jid, "") # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ("offline", "error") and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: GLib.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ("offline", "error") and not self.contact.is_observer(): self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].request_entity_time, j, r, self.contact.jid) else: GLib.idle_add( gajim.connections[self.account].request_entity_time, self.contact.jid, self.contact.resource ) self.os_info = {0: {"resource": self.real_resource, "client": "", "os": ""}} self.time_info = {0: {"resource": self.real_resource, "time": ""}} i = 1 contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += "\n%s (%s)" % (c.resource, str(c.priority)) uf_resources += "\n" + c.resource + _(" resource with priority ") + str(c.priority) if c.show not in ("offline", "error"): GLib.idle_add(gajim.connections[self.account].request_os_info, c.jid, c.resource) GLib.idle_add(gajim.connections[self.account].request_entity_time, c.jid, c.resource) self.os_info[i] = {"resource": c.resource, "client": "", "os": ""} self.time_info[i] = {"resource": c.resource, "time": ""} i += 1 self.xml.get_object("resource_prio_label").set_text(resources) resource_prio_label_eventbox = self.xml.get_object("resource_prio_label_eventbox") resource_prio_label_eventbox.set_tooltip_text(uf_resources) self.fill_status_label() if self.gc_contact: # If we know the real jid, remove the resource from vcard request gajim.connections[self.account].request_vcard(self.real_jid_for_vcard, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)
def populate(self, contact): if not contact: return self.create_window() vcard_table = Gtk.Grid() vcard_table.insert_row(0) vcard_table.insert_row(0) vcard_table.insert_row(0) vcard_table.insert_column(0) vcard_table.set_property('column-spacing', 2) vcard_current_row = 1 properties = [] nick_markup = '<b>' + GLib.markup_escape_text(contact.get_shown_name())\ + '</b>' properties.append((nick_markup, None)) if contact.status: # status message status = contact.status.strip() if status != '': # escape markup entities status = helpers.reduce_chars_newlines(status, 300, 5) status = '<i>' + GLib.markup_escape_text(status) + '</i>' properties.append((status, None)) show = helpers.get_uf_show(contact.show) show = self.colorize_status(show) properties.append((show, None)) if contact.jid.strip(): properties.append((_('Jabber ID: '), '\u200E' + "<b>%s</b>" % \ contact.jid)) if hasattr(contact, 'resource') and contact.resource.strip(): properties.append((_('Resource: '), GLib.markup_escape_text( contact.resource))) if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) uf_affiliation = \ _('%(owner_or_admin_or_member)s of this group chat') % \ {'owner_or_admin_or_member': uf_affiliation} uf_affiliation = self.colorize_affiliation(uf_affiliation) properties.append((uf_affiliation, None)) # Add avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) file_ = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room, puny_name)) if file_: with open(file_, 'rb') as file_data: pix = gtkgui_helpers.get_pixbuf_from_data(file_data.read()) pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip') self.avatar_image.set_from_pixbuf(pix) else: self.avatar_image.set_from_pixbuf(None) while properties: property_ = properties.pop(0) vcard_current_row += 1 label = Gtk.Label() if not properties: label.set_vexpand(True) label.set_alignment(0, 0) if property_[1]: label.set_markup(property_[0]) vcard_table.attach(label, 1, vcard_current_row, 1, 1) label = Gtk.Label() if not properties: label.set_vexpand(True) label.set_alignment(0, 0) label.set_markup(property_[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, vcard_current_row, 1, 1) else: label.set_markup(property_[0]) label.set_line_wrap(True) vcard_table.attach(label, 1, vcard_current_row, 2, 1) self.avatar_image.set_alignment(0, 0) vcard_table.attach(self.avatar_image, 3, 2, 1, vcard_current_row - 1) gajim.plugin_manager.gui_extension_point('gc_tooltip_populate', self, contact, vcard_table) self.win.add(vcard_table)
def fill_jabber_page(self): self.xml.get_object('nickname_label').set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + '</span></b>') self.xml.get_object('jid_label').set_text(self.contact.jid) subscription_label = self.xml.get_object('subscription_label') ask_label = self.xml.get_object('ask_label') if self.gc_contact: self.xml.get_object('subscription_title_label').set_markup( Q_("?Role in Group Chat:<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_object('ask_title_label').set_markup( _("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation( self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) eb = self.xml.get_object('subscription_label_eventbox') if self.contact.sub == 'from': tt_text = _( "This contact is interested in your presence information, but you are not interested in their presence" ) elif self.contact.sub == 'to': tt_text = _( "You are interested in the contact's presence information, but it is not mutual" ) elif self.contact.sub == 'both': tt_text = _( "The contact and you want to exchange presence information" ) else: # None tt_text = _( "You and the contact have a mutual disinterest in each-others presence information" ) eb.set_tooltip_text(tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) eb = self.xml.get_object('ask_label_eventbox') if self.contact.ask == 'subscribe': tt_text = _( "You are waiting contact's answer about your subscription request" ) else: tt_text = _("There is no pending subscription request.") eb.set_tooltip_text(tt_text) resources = '%s (%s)' % (self.contact.resource, str(self.contact.priority)) uf_resources = self.contact.resource + _(' resource with priority ')\ + str(self.contact.priority) if not self.contact.status: self.contact.status = '' # Request list time status only if contact is offline if self.contact.show == 'offline': if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gajim.connections[self.account].request_last_status_time( j, r, self.contact.jid) else: gajim.connections[self.account].request_last_status_time( self.contact.jid, '') # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: GLib.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].\ request_entity_time, j, r, self.contact.jid) else: GLib.idle_add(gajim.connections[self.account].\ request_entity_time, self.contact.jid, self.contact.resource) self.os_info = { 0: { 'resource': self.real_resource, 'client': '', 'os': '' } } self.time_info = {0: {'resource': self.real_resource, 'time': ''}} i = 1 contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += '\n%s (%s)' % (c.resource, str(c.priority)) uf_resources += '\n' + c.resource + \ _(' resource with priority ') + str(c.priority) if c.show not in ('offline', 'error'): GLib.idle_add(gajim.connections[self.account].\ request_os_info, c.jid, c.resource) GLib.idle_add(gajim.connections[self.account].\ request_entity_time, c.jid, c.resource) self.os_info[i] = { 'resource': c.resource, 'client': '', 'os': '' } self.time_info[i] = {'resource': c.resource, 'time': ''} i += 1 self.xml.get_object('resource_prio_label').set_text(resources) resource_prio_label_eventbox = self.xml.get_object( 'resource_prio_label_eventbox') resource_prio_label_eventbox.set_tooltip_text(uf_resources) self.fill_status_label() if self.gc_contact: # If we know the real jid, remove the resource from vcard request gajim.connections[self.account].request_vcard( self.real_jid_for_vcard, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)
def populate(self, contact): if not contact: return self.create_window() vcard_table = gtk.Table(3, 1) vcard_table.set_property('column-spacing', 2) vcard_table.set_homogeneous(False) vcard_current_row = 1 properties = [] nick_markup = '<b>' + \ gobject.markup_escape_text(contact.get_shown_name()) \ + '</b>' properties.append((nick_markup, None)) if contact.status: # status message status = contact.status.strip() if status != '': # escape markup entities status = helpers.reduce_chars_newlines(status, 300, 5) status = '<i>' +\ gobject.markup_escape_text(status) + '</i>' properties.append((status, None)) else: # no status message, show SHOW instead show = helpers.get_uf_show(contact.show) show = '<i>' + show + '</i>' properties.append((show, None)) if contact.jid.strip() != '': properties.append((_('Jabber ID: '), contact.jid)) if hasattr(contact, 'resource') and contact.resource.strip() != '': properties.append((_('Resource: '), gobject.markup_escape_text(contact.resource))) if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) affiliation_str = \ _('%(owner_or_admin_or_member)s of this group chat') %\ {'owner_or_admin_or_member': uf_affiliation} properties.append((affiliation_str, None)) # Add avatar puny_name = helpers.sanitize_filename(contact.name) puny_room = helpers.sanitize_filename(contact.room_jid) file = helpers.get_avatar_path( os.path.join(gajim.AVATAR_PATH, puny_room, puny_name)) if file: self.avatar_image.set_from_file(file) pix = self.avatar_image.get_pixbuf() pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip') self.avatar_image.set_from_pixbuf(pix) else: self.avatar_image.set_from_pixbuf(None) while properties: property = properties.pop(0) vcard_current_row += 1 vertical_fill = gtk.FILL if not properties: vertical_fill |= gtk.EXPAND label = gtk.Label() label.set_alignment(0, 0) if property[1]: label.set_markup(property[0]) vcard_table.attach(label, 1, 2, vcard_current_row, vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0) label = gtk.Label() label.set_alignment(0, 0) label.set_markup(property[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, 3, vcard_current_row, vcard_current_row + 1, gtk.EXPAND | gtk.FILL, vertical_fill, 0, 0) else: label.set_markup(property[0]) label.set_line_wrap(True) vcard_table.attach(label, 1, 3, vcard_current_row, vcard_current_row + 1, gtk.FILL, vertical_fill, 0) self.avatar_image.set_alignment(0, 0) vcard_table.attach(self.avatar_image, 3, 4, 2, vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3) self.win.add(vcard_table)
def fill_jabber_page(self): tooltips = gtk.Tooltips() self.xml.get_widget('nickname_label').set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + '</span></b>') self.xml.get_widget('jid_label').set_text(self.contact.jid) subscription_label = self.xml.get_widget('subscription_label') ask_label = self.xml.get_widget('ask_label') if self.gc_contact: self.xml.get_widget('subscription_title_label').set_markup( _("<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_widget('ask_title_label').set_markup( _("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation( self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) eb = self.xml.get_widget('subscription_label_eventbox') if self.contact.sub == 'from': tt_text = _( "This contact is interested in your presence information, but you are not interested in his/her presence" ) elif self.contact.sub == 'to': tt_text = _( "You are interested in the contact's presence information, but he/she is not interested in yours" ) elif self.contact.sub == 'both': tt_text = _( "You and the contact are interested in each other's presence information" ) else: # None tt_text = _( "You are not interested in the contact's presence, and neither he/she is interested in yours" ) tooltips.set_tip(eb, tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) eb = self.xml.get_widget('ask_label_eventbox') if self.contact.ask == 'subscribe': tt_text = _( "You are waiting contact's answer about your subscription request" ) else: tt_text = _("There is no pending subscription request.") tooltips.set_tip(eb, tt_text) resources = '%s (%s)' % (self.contact.resource, unicode(self.contact.priority)) uf_resources = self.contact.resource + _(' resource with priority ')\ + unicode(self.contact.priority) if not self.contact.status: self.contact.status = '' # Request list time status if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gajim.connections[self.account].request_last_status_time( j, r, self.contact.jid) else: gajim.connections[self.account].request_last_status_time( self.contact.jid, self.contact.resource) # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gobject.idle_add( gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: gobject.idle_add( gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) self.os_info = { 0: { 'resource': self.contact.resource, 'client': '', 'os': '' } } i = 1 contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += '\n%s (%s)' % (c.resource, unicode( c.priority)) uf_resources += '\n' + c.resource + \ _(' resource with priority ') + unicode(c.priority) if c.show not in ('offline', 'error'): gobject.idle_add( gajim.connections[self.account].request_os_info, c.jid, c.resource) gajim.connections[self.account].request_last_status_time( c.jid, c.resource) self.os_info[i] = { 'resource': c.resource, 'client': '', 'os': '' } i += 1 self.xml.get_widget('resource_prio_label').set_text(resources) resource_prio_label_eventbox = self.xml.get_widget( 'resource_prio_label_eventbox') tooltips.set_tip(resource_prio_label_eventbox, uf_resources) self.fill_status_label() if self.gc_contact: # If we know the real jid, remove the resource from vcard request if self.gc_contact.jid: jid = self.gc_contact.jid else: jid = self.real_jid gajim.connections[self.account].request_vcard( jid, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)