def __init__(self, plugin, parent): Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_show_menubar(False) self.set_title(_('PGP Configuration')) self.set_transient_for(parent) self.set_resizable(True) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.set_destroy_with_parent(True) ui_path = Path(__file__).parent self._ui = get_builder(ui_path.resolve() / 'config.ui') self.add(self._ui.config_box) self._ui.connect_signals(self) self._plugin = plugin for account in app.connections.keys(): page = Page(plugin, account) self._ui.stack.add_titled(page, account, app.get_account_label(account)) self.show_all()
def build_accounts_menu(): menubar = app.app.get_menubar() # Accounts Submenu menu_position = 1 if app.prefers_app_menu(): menu_position = 0 acc_menu = menubar.get_item_link(menu_position, 'submenu') acc_menu.remove_all() accounts_list = sorted(app.contacts.get_accounts()) if not accounts_list: modify_account_item = Gio.MenuItem.new(_('_Add Account…'), 'app.accounts::') acc_menu.append_item(modify_account_item) return if len(accounts_list) > 1: modify_account_item = Gio.MenuItem.new(_('_Modify Accounts…'), 'app.accounts::') acc_menu.append_item(modify_account_item) for acc in accounts_list: label = escape_mnemonic(app.get_account_label(acc)) acc_menu.append_submenu( label, get_account_menu(acc)) else: acc_menu = get_account_menu(accounts_list[0]) modify_account_item = Gio.MenuItem.new(_('_Modify Account…'), 'app.accounts::') acc_menu.insert_item(0, modify_account_item) menubar.remove(menu_position) menubar.insert_submenu(menu_position, _('Accounts'), acc_menu)
def __init__(self, account): Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_title(_('Bookmarks for %s' % app.get_account_label(account))) self.set_default_size(700, 500) self.account = account self._ui = get_builder('bookmarks.ui') self.add(self._ui.bookmarks_grid) con = app.connections[account] for bookmark in con.get_module('Bookmarks').bookmarks: self._ui.bookmarks_store.append([str(bookmark.jid), bookmark.name, bookmark.nick, bookmark.password, bookmark.autojoin]) self._ui.bookmarks_view.set_search_equal_func(self._search_func) self._ui.connect_signals(self) self.connect('key-press-event', self._on_key_press) self.show_all()
def _get_accounts(): accounts = app.get_accounts_sorted() combo_accounts = [] for account in accounts: label = app.get_account_label(account) combo_accounts.append((account, label)) return combo_accounts
def generate_account_badge(account): account_label = app.get_account_label(account) badge = Gtk.Label(label=account_label) badge.set_ellipsize(Pango.EllipsizeMode.END) badge.set_max_width_chars(12) badge.set_size_request(50, -1) account_class = app.css_config.get_dynamic_class(account) badge_context = badge.get_style_context() badge_context.add_class(account_class) badge_context.add_class('badge') return badge
def __init__(self, account): Gtk.ListBoxRow.__init__(self) self.set_selectable(False) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) self._account = account self._label = Gtk.Label(label=app.get_account_label(account)) self._label.set_halign(Gtk.Align.START) self._label.set_hexpand(True) self._label.set_ellipsize(Pango.EllipsizeMode.END) self._label.set_xalign(0) self._label.set_width_chars(18) next_icon = Gtk.Image.new_from_icon_name('go-next-symbolic', Gtk.IconSize.MENU) next_icon.get_style_context().add_class('insensitive-fg-color') account_enabled = app.settings.get_account_setting( self._account, 'active') self._switch = Gtk.Switch() self._switch.set_active(account_enabled) self._switch.set_vexpand(False) self._switch_state_label = Gtk.Label() self._switch_state_label.set_xalign(1) self._switch_state_label.set_valign(Gtk.Align.CENTER) self._set_label(account_enabled) if (self._account == app.ZEROCONF_ACC_NAME and not app.is_installed('ZEROCONF')): self._switch.set_active(False) self.set_activatable(False) self.set_sensitive(False) if sys.platform in ('win32', 'darwin'): tooltip = _('Please check if Bonjour is installed.') else: tooltip = _('Please check if Avahi is installed.') self.set_tooltip_text(tooltip) self._switch.connect('state-set', self._on_enable_switch, self._account) box.add(self._switch) box.add(self._switch_state_label) box.add(Gtk.Separator()) box.add(self._label) box.add(next_icon) self.add(box)
def set_entry_text(self, toggle, update=False): account_label = app.get_account_label(self.account) if update: self.entry.set_text(account_label) return if toggle.get_active(): self.entry.set_sensitive(True) self.entry.grab_focus() else: self.entry.set_sensitive(False) value = self.entry.get_text() if not value: value = account_label app.config.set_per('accounts', self.account, 'account_label', value or self.account) if app.config.get_per('accounts', self.account, 'active'): app.interface.roster.draw_account(self.account) gui_menu_builder.build_accounts_menu()
def _print_stanza(self, event, kind): if event.account == 'AccountWizard': account_label = 'Account Wizard' else: account_label = app.get_account_label(event.account) stanza = event.stanza if not isinstance(stanza, str): stanza = stanza.__str__(fancy=True) if not stanza: return at_the_end = util.at_the_end(self._ui.scrolled) buffer_ = self._ui.textview.get_buffer() end_iter = buffer_.get_end_iter() type_ = kind if stanza.startswith('<presence'): type_ = 'presence' elif stanza.startswith('<message'): type_ = 'message' elif stanza.startswith('<iq'): type_ = 'iq' elif stanza.startswith('<r') or stanza.startswith('<a'): type_ = 'stream' stanza = '<!-- {kind} {time} ({account}) -->\n{stanza}\n\n'.format( kind=kind.capitalize(), time=time.strftime('%c'), account=account_label, stanza=stanza) buffer_.insert_with_tags_by_name(end_iter, stanza, type_, kind) if at_the_end: GLib.idle_add(util.scroll_to_end, self._ui.scrolled)
def get_accounts_info(): """ Helper for notification icon tooltip """ accounts = [] accounts_list = sorted(app.contacts.get_accounts()) for account in accounts_list: status = get_connection_status(account) message = app.connections[account].status_message single_line = get_uf_show(status) if message is None: message = '' else: message = message.strip() if message != '': single_line += ': ' + message account_label = app.get_account_label(account) accounts.append({'name': account, 'account_label': account_label, 'status_line': single_line, 'show': status, 'message': message}) return accounts
def update_account_label(self): self._label.set_text(app.get_account_label(self._account))
def _populate_grid(self, contacts, account, typ): """ Populate the Tooltip Grid with data of from the contact """ self.current_row = 0 self.account = account if self.last_widget: self.last_widget.set_vexpand(False) self.clear_tooltip() if account == 'all': # Tooltip for merged accounts row self._show_merged_account_tooltip() return if typ == 'account': jid = app.get_jid_from_account(account) contacts = [] connection = app.connections[account] # get our current contact info nbr_on, nbr_total = app.\ contacts.get_nb_online_total_contacts(accounts=[account]) account_name = app.get_account_label(account) if app.account_is_available(account): account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) contact = app.contacts.create_self_contact( jid=jid, account=account, name=account_name, show=get_connection_status(account), status=connection.status_message, resource=connection.get_own_jid().resource, priority=connection.priority) contacts.append(contact) # Username/Account/Groupchat self.prim_contact = app.contacts.get_highest_prio_contact_from_contacts( contacts) if self.prim_contact is None: log.error('No contact for Roster tooltip found') log.error('contacts: %s, typ: %s, account: %s', contacts, typ, account) return self.contact_jid = self.prim_contact.jid name = GLib.markup_escape_text(self.prim_contact.get_shown_name()) if app.settings.get('mergeaccounts'): name = GLib.markup_escape_text(self.prim_contact.account.name) self._ui.name.set_markup(name) self._ui.name.show() self.num_resources = 0 # put contacts in dict, where key is priority contacts_dict = {} for contact in contacts: if contact.resource: self.num_resources += 1 priority = int(contact.priority) if priority in contacts_dict: contacts_dict[priority].append(contact) else: contacts_dict[priority] = [contact] if self.num_resources > 1: transport = app.get_transport_name_from_jid(self.prim_contact.jid) if transport == 'jabber': transport = None contact_keys = sorted(contacts_dict.keys()) contact_keys.reverse() for priority in contact_keys: for acontact in contacts_dict[priority]: show = self._get_icon_name_for_tooltip(acontact) status = acontact.status resource_line = '%s (%s)' % (acontact.resource, str(acontact.priority)) self.add_status_row(show, resource_line, transport=transport) if status: self.add_text_row(status, 2) self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1) self.table.show_all() else: # only one resource if contact.is_groupchat: disco_info = app.storage.cache.get_last_disco_info(contact.jid) if disco_info is not None: description = disco_info.muc_description if description: self._ui.status.set_text(description) self._ui.status.show() elif contact.show and contact.status: status = contact.status.strip() if status: self._ui.status.set_text(status) self._ui.status.show() # PEP Info self._append_pep_info(contact) # JID self._ui.jid.set_text(self.prim_contact.jid) self._ui.jid.show() # contact has only one resource if self.num_resources == 1 and contact.resource: res = GLib.markup_escape_text(contact.resource) prio = str(contact.priority) self._ui.resource.set_text("{} ({})".format(res, prio)) self._ui.resource.show() self._ui.resource_label.show() if self.prim_contact.jid not in app.gc_connected[account]: if (account and self.prim_contact.sub and self.prim_contact.sub != 'both'): # ('both' is the normal sub so we don't show it) self._ui.sub.set_text(helpers.get_uf_sub( self.prim_contact.sub)) self._ui.sub.show() self._ui.sub_label.show() self._set_idle_time(contact) # Avatar scale = self._ui.tooltip_grid.get_scale_factor() surface = app.contacts.get_avatar(account, self.prim_contact.jid, AvatarSize.TOOLTIP, scale) self._ui.avatar.set_from_surface(surface) self._ui.avatar.show() app.plugin_manager.gui_extension_point('roster_tooltip_populate', self, contacts, self._ui.tooltip_grid) # Sets the Widget that is at the bottom to expand. # This is needed in case the Picture takes more Space than the Labels i = 1 while i < 15: if self._ui.tooltip_grid.get_child_at(1, i): if self._ui.tooltip_grid.get_child_at(1, i).get_visible(): self.last_widget = self._ui.tooltip_grid.get_child_at(1, i) i += 1 self.last_widget.set_vexpand(True)
def _make_menu(self, _event_button, event_time): """ Create chat with and new message (sub) menus/menuitems """ for menu in self.popup_menus: menu.destroy() start_chat_menuitem = self._ui.start_chat_menuitem single_message_menuitem = self._ui.single_message_menuitem status_menuitem = self._ui.status_menu sounds_mute_menuitem = self._ui.sounds_mute_menuitem show_roster_menuitem = self._ui.show_roster_menuitem if self._single_message_handler_id: single_message_menuitem.handler_disconnect( self._single_message_handler_id) self._single_message_handler_id = None sub_menu = Gtk.Menu() self.popup_menus.append(sub_menu) status_menuitem.set_submenu(sub_menu) for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show, use_mnemonic=True) item = Gtk.MenuItem.new_with_mnemonic(uf_show) sub_menu.append(item) item.connect('activate', self._on_show, show) item = Gtk.SeparatorMenuItem.new() sub_menu.append(item) item = Gtk.MenuItem.new_with_mnemonic(_('_Change Status Message…')) sub_menu.append(item) item.connect('activate', self._on_change_status) connected_accounts = app.get_number_of_connected_accounts() if connected_accounts < 1: item.set_sensitive(False) item = Gtk.SeparatorMenuItem.new() sub_menu.append(item) uf_show = helpers.get_uf_show('offline', use_mnemonic=True) item = Gtk.MenuItem.new_with_mnemonic(uf_show) sub_menu.append(item) item.connect('activate', self._on_show, 'offline') is_zeroconf = connected_accounts == 1 and app.zeroconf_is_connected() iskey = connected_accounts > 0 and not is_zeroconf start_chat_menuitem.set_sensitive(iskey) single_message_menuitem.set_sensitive(iskey) accounts_list = sorted(app.contacts.get_accounts()) # menu items that don't apply to zeroconf connections if connected_accounts == 1 or (connected_accounts == 2 and \ app.zeroconf_is_connected()): # only one 'real' (non-zeroconf) account is connected, don't need # submenus for account in app.connections: if app.account_is_connected(account) and \ not app.config.get_per('accounts', account, 'is_zeroconf'): # for single message single_message_menuitem.set_submenu(None) self._single_message_handler_id = single_message_menuitem.\ connect('activate', self._on_single_message, account) break # No other account connected else: # 2 or more 'real' accounts are connected, make submenus account_menu_for_single_message = Gtk.Menu() single_message_menuitem.set_submenu( account_menu_for_single_message) self.popup_menus.append(account_menu_for_single_message) for account in accounts_list: account_label = app.get_account_label(account) if app.connections[account].is_zeroconf or \ not app.account_is_connected(account): continue # for single message item = Gtk.MenuItem.new_with_label( _('using account %s') % account_label) item.connect('activate', self._on_single_message, account) account_menu_for_single_message.append(item) sounds_mute_menuitem.set_active(not app.config.get('sounds_on')) win = app.interface.roster.window if self._show_roster_handler_id: show_roster_menuitem.handler_disconnect( self._show_roster_handler_id) if win.get_property('has-toplevel-focus'): show_roster_menuitem.get_children()[0].set_label( _('Hide _Contact List')) self._show_roster_handler_id = show_roster_menuitem.connect( 'activate', self._on_hide_roster) else: show_roster_menuitem.get_children()[0].set_label( _('Show _Contact List')) self._show_roster_handler_id = show_roster_menuitem.connect( 'activate', self._on_show_roster) if os.name == 'nt': if self.added_hide_menuitem is False: self.systray_context_menu.prepend(Gtk.SeparatorMenuItem.new()) item = Gtk.MenuItem.new_with_label(_('Hide this menu')) self.systray_context_menu.prepend(item) self.added_hide_menuitem = True self.systray_context_menu.show_all() self.systray_context_menu.popup(None, None, None, None, 0, event_time)
def _populate_grid(self, contacts, account, typ): """ Populate the Tooltip Grid with data of from the contact """ self.current_row = 0 self.account = account if self.last_widget: self.last_widget.set_vexpand(False) self.clear_tooltip() if account == 'all': # Tooltip for merged accounts row accounts = helpers.get_notification_icon_tooltip_dict() self.spacer_label = '' self.fill_table_with_accounts(accounts) self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1) self.table.show_all() return if typ == 'account': jid = app.get_jid_from_account(account) contacts = [] connection = app.connections[account] # get our current contact info nbr_on, nbr_total = app.\ contacts.get_nb_online_total_contacts(accounts=[account]) account_name = app.get_account_label(account) if app.account_is_connected(account): account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) contact = app.contacts.create_self_contact( jid=jid, account=account, name=account_name, show=connection.get_status(), status=connection.status, resource=connection.server_resource, priority=connection.priority) contacts.append(contact) # Username/Account/Groupchat self.prim_contact = app.contacts.get_highest_prio_contact_from_contacts( contacts) if self.prim_contact is None: log.error('No contact for Roster tooltip found') log.error('contacts: %s, typ: %s, account: %s', contacts, typ, account) return self.contact_jid = self.prim_contact.jid name = GLib.markup_escape_text(self.prim_contact.get_shown_name()) name_markup = '<b>{}</b>'.format(name) if app.config.get('mergeaccounts'): color = app.config.get('tooltip_account_name_color') account_name = GLib.markup_escape_text(self.prim_contact.account.name) name_markup += " <span foreground='{}'>({})</span>".format( color, account_name) if account and helpers.jid_is_blocked(account, self.prim_contact.jid): name_markup += _(' [blocked]') try: if self.prim_contact.jid in app.interface.minimized_controls[account]: name_markup += _(' [minimized]') except KeyError: pass self._ui.name.set_markup(name_markup) self._ui.name.show() self.num_resources = 0 # put contacts in dict, where key is priority contacts_dict = {} for contact in contacts: if contact.resource: self.num_resources += 1 priority = int(contact.priority) if priority in contacts_dict: contacts_dict[priority].append(contact) else: contacts_dict[priority] = [contact] if self.num_resources > 1: transport = app.get_transport_name_from_jid(self.prim_contact.jid) if transport == 'jabber': transport = None contact_keys = sorted(contacts_dict.keys()) contact_keys.reverse() for priority in contact_keys: for acontact in contacts_dict[priority]: show = self._get_icon_name_for_tooltip(acontact) if acontact.status and len(acontact.status) > 25: status = '' add_text = True else: status = acontact.status add_text = False status_line = self.get_status_info( acontact.resource, acontact.priority, acontact.show, status) self.add_status_row(show, status_line, transport=transport) if add_text: self.add_text_row(acontact.status, 2) self._ui.tooltip_grid.attach(self.table, 1, 3, 2, 1) self.table.show_all() else: # only one resource if contact.show and contact.status: status = contact.status.strip() if status: self._ui.status.set_text(status) self._ui.status.show() # PEP Info self._append_pep_info(contact) # JID self._ui.jid.set_text(self.prim_contact.jid) self._ui.jid.show() # contact has only one resource if self.num_resources == 1 and contact.resource: res = GLib.markup_escape_text(contact.resource) prio = str(contact.priority) self._ui.resource.set_text("{} ({})".format(res, prio)) self._ui.resource.show() self._ui.resource_label.show() if self.prim_contact.jid not in app.gc_connected[account]: if (account and self.prim_contact.sub and self.prim_contact.sub != 'both'): # ('both' is the normal sub so we don't show it) self._ui.sub.set_text(helpers.get_uf_sub(self.prim_contact.sub)) self._ui.sub.show() self._ui.sub_label.show() self._set_idle_time(contact) # Avatar scale = self._ui.tooltip_grid.get_scale_factor() surface = app.contacts.get_avatar( account, self.prim_contact.jid, AvatarSize.TOOLTIP, scale) self._ui.avatar.set_from_surface(surface) self._ui.avatar.show() app.plugin_manager.gui_extension_point( 'roster_tooltip_populate', self, contacts, self._ui.tooltip_grid) # Sets the Widget that is at the bottom to expand. # This is needed in case the Picture takes more Space than the Labels i = 1 while i < 15: if self._ui.tooltip_grid.get_child_at(1, i): if self._ui.tooltip_grid.get_child_at(1, i).get_visible(): self.last_widget = self._ui.tooltip_grid.get_child_at(1, i) i += 1 self.last_widget.set_vexpand(True)
def __init__(self, account, event): Gtk.ApplicationWindow.__init__(self) self.set_name('GroupChatInvitation') self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_title(_('Group Chat Invitation')) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.account = account self._room_jid = str(event.muc) self._from = str(event.from_) self._password = event.password main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12) main_box.set_valign(Gtk.Align.FILL) main_box.get_style_context().add_class('padding-18') muc_info_box = GroupChatInfoScrolled(account, {'minimal': True}) muc_info_box.set_from_disco_info(event.info) main_box.add(muc_info_box) separator = Gtk.Separator() contact_label = Gtk.Label(label=event.get_inviter_name()) contact_label.get_style_context().add_class('bold16') contact_label.set_line_wrap(True) contact_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) contact_box.set_halign(Gtk.Align.CENTER) contact_box.add(contact_label) enabled_accounts = app.get_enabled_accounts_with_labels() if len(enabled_accounts) > 1: account_badge = generate_account_badge(account) account_badge.set_tooltip_text( _('Account: %s') % app.get_account_label(account)) contact_box.add(account_badge) invitation_label = Gtk.Label( label=_('has invited you to a group chat.\nDo you want to join?')) invitation_label.set_halign(Gtk.Align.CENTER) invitation_label.set_justify(Gtk.Justification.CENTER) invitation_label.set_max_width_chars(50) invitation_label.set_line_wrap(True) main_box.add(separator) main_box.add(contact_box) main_box.add(invitation_label) decline_button = Gtk.Button.new_with_mnemonic(_('_Decline')) decline_button.set_halign(Gtk.Align.START) decline_button.connect('clicked', self._on_decline) self._nick_chooser = NickChooser() self._nick_chooser.set_text( get_group_chat_nick(self.account, event.info.jid)) join_button = Gtk.Button.new_with_mnemonic(_('_Join')) join_button.set_halign(Gtk.Align.END) join_button.get_style_context().add_class('suggested-action') join_button.connect('clicked', self._on_join) join_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) join_box.get_style_context().add_class('linked') join_box.set_halign(Gtk.Align.END) join_box.add(self._nick_chooser) join_box.add(join_button) button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) button_box.set_margin_top(6) button_box.pack_start(decline_button, False, False, 0) button_box.pack_end(join_box, False, False, 0) main_box.add(button_box) self.connect('key-press-event', self._on_key_press_event) self.add(main_box) join_button.set_can_default(True) join_button.grab_focus() self.show_all()
def __init__(self, account, contact, jid, name, show_account, groupchat=False): Gtk.ListBoxRow.__init__(self) self.get_style_context().add_class('start-chat-row') self.account = account self.account_label = app.get_account_label(account) self.show_account = show_account self.jid = jid self.contact = contact self.name = name self.groupchat = groupchat self.new = jid == '' grid = Gtk.Grid() grid.set_column_spacing(12) grid.set_size_request(260, -1) if self.groupchat: muc_icon = get_icon_name( 'muc-inactive' if self.new else 'muc-active') image = Gtk.Image.new_from_icon_name(muc_icon, Gtk.IconSize.DND) else: scale = self.get_scale_factor() avatar = app.contacts.get_avatar(account, jid, AvatarSize.CHAT, scale) if avatar is None: image = Gtk.Image.new_from_icon_name('avatar-default', Gtk.IconSize.DND) else: image = Gtk.Image.new_from_surface(avatar) image.set_size_request(AvatarSize.CHAT, AvatarSize.CHAT) grid.add(image) middle_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) middle_box.set_hexpand(True) if self.name is None: if self.groupchat: self.name = _('Join Group Chat') else: self.name = _('Add Contact') self.name_label = Gtk.Label(label=self.name) self.name_label.set_ellipsize(Pango.EllipsizeMode.END) self.name_label.set_xalign(0) self.name_label.set_width_chars(25) self.name_label.set_halign(Gtk.Align.START) self.name_label.get_style_context().add_class('bold16') status = contact.show if contact else 'offline' css_class = helpers.get_css_show_color(status) if css_class is not None: self.name_label.get_style_context().add_class(css_class) middle_box.add(self.name_label) self.jid_label = Gtk.Label(label=jid) self.jid_label.set_ellipsize(Pango.EllipsizeMode.END) self.jid_label.set_xalign(0) self.jid_label.set_width_chars(25) self.jid_label.set_halign(Gtk.Align.START) self.jid_label.get_style_context().add_class('dim-label') middle_box.add(self.jid_label) grid.add(middle_box) if show_account: account_label = Gtk.Label(label=self.account_label) account_label.set_halign(Gtk.Align.START) account_label.set_valign(Gtk.Align.START) right_box = Gtk.Box() right_box.set_vexpand(True) right_box.add(account_label) grid.add(right_box) self.add(grid) self.show_all()
def __init__(self, account, contact, jid, name, show_account, groupchat=False): Gtk.ListBoxRow.__init__(self) self.get_style_context().add_class('start-chat-row') self.account = account self.account_label = app.get_account_label(account) self.show_account = show_account self.jid = jid self.contact = contact self.name = name self.groupchat = groupchat self.new = jid == '' show = contact.show if contact else 'offline' grid = Gtk.Grid() grid.set_column_spacing(12) grid.set_size_request(260, -1) image = self._get_avatar_image(account, jid, show) image.set_size_request(AvatarSize.CHAT, AvatarSize.CHAT) grid.add(image) middle_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) middle_box.set_hexpand(True) if self.name is None: if self.groupchat: self.name = _('Join Group Chat') else: self.name = _('Add Contact') self.name_label = Gtk.Label(label=self.name) self.name_label.set_ellipsize(Pango.EllipsizeMode.END) self.name_label.set_xalign(0) self.name_label.set_width_chars(25) self.name_label.set_halign(Gtk.Align.START) self.name_label.get_style_context().add_class('bold16') middle_box.add(self.name_label) self.jid_label = Gtk.Label(label=jid) self.jid_label.set_ellipsize(Pango.EllipsizeMode.END) self.jid_label.set_xalign(0) self.jid_label.set_width_chars(25) self.jid_label.set_halign(Gtk.Align.START) self.jid_label.get_style_context().add_class('dim-label') middle_box.add(self.jid_label) grid.add(middle_box) if show_account: account_label = Gtk.Label(label=self.account_label) account_label.set_halign(Gtk.Align.START) account_label.set_valign(Gtk.Align.START) right_box = Gtk.Box() right_box.set_vexpand(True) right_box.add(account_label) grid.add(right_box) self.add(grid) self.show_all()
def _update_account_label(self, _listbox, account): account_label = app.get_account_label(account) self._label.set_text(account_label)