Commit 7743c11a authored by Sophie Herold's avatar Sophie Herold Committed by Philipp Hörist

Unify to use app.get_account_label()

parent dd8dda9b
......@@ -377,8 +377,7 @@ class Account(Gtk.Box):
self.options = AccountPage(account, parent)
self.parent = parent
account_label = app.config.get_per('accounts', account, 'account_label')
self.label = Gtk.Label(label=account_label or account)
self.label = Gtk.Label(app.get_account_label(account))
self.label.set_halign(Gtk.Align.START)
self.label.set_hexpand(True)
......@@ -402,9 +401,7 @@ class Account(Gtk.Box):
self.parent.set_page(self.options, 'account')
def update(self):
account_label = app.config.get_per(
'accounts', self.account, 'account_label')
self.label.set_text(account_label or self.account)
self.label.set_text(app.get_account_label(self.account))
self._update_image()
def _update_image(self):
......@@ -453,10 +450,9 @@ class GenericOptionPage(Gtk.Box):
row.get_child().on_row_activated()
def set_entry_text(self, toggle, update=False):
account_label = app.config.get_per(
'accounts', self.account, 'account_label')
account_label = app.get_account_label(self.account)
if update:
self.entry.set_text(account_label or self.account)
self.entry.set_text(account_label)
return
if toggle.get_active():
self.entry.set_sensitive(True)
......@@ -465,7 +461,7 @@ class GenericOptionPage(Gtk.Box):
self.entry.set_sensitive(False)
value = self.entry.get_text()
if not value:
value = account_label or self.account
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'):
......
......@@ -663,7 +663,8 @@ class ChatControl(ChatControlBase):
if other_contact_.get_shown_name() == \
self.contact.get_shown_name():
acct_info = i18n.direction_mark + ' (%s)' % \
GLib.markup_escape_text(self.account)
GLib.markup_escape_text(
app.get_account_label(self.account))
break
status = contact.status
......
......@@ -411,13 +411,14 @@ def get_enabled_accounts_with_labels(exclude_local=True, connected_only=False,
if private_storage_only and not account_supports_private_storage(acc):
continue
acc_label = config.get_per(
'accounts', acc, 'account_label') or acc
accounts.append([acc, acc_label])
accounts.append([acc, get_account_label(acc)])
accounts.sort(key=lambda xs: str.lower(xs[1]))
return accounts
def get_account_label(account):
return config.get_per('accounts', account, 'account_label') or account
def account_is_zeroconf(account):
return connections[account].is_zeroconf
......
......@@ -1121,10 +1121,9 @@ def get_accounts_info():
message = message.strip()
if message != '':
single_line += ': ' + message
account_label = app.config.get_per(
'accounts', account, 'account_label')
account_label = app.get_account_label(account)
accounts.append({'name': account,
'account_label': account_label or account,
'account_label': account_label,
'status_line': single_line,
'show': status,
'message': message})
......
......@@ -262,8 +262,7 @@ class ContactRow(Gtk.Grid):
self.set_column_spacing(12)
self.set_size_request(260, -1)
self.account = account
self.account_label = app.config.get_per(
'accounts', account, 'account_label') or account
self.account_label = app.get_account_label(account)
self.show_account = show_account
self.jid = jid
self.contact = contact
......
......@@ -799,10 +799,9 @@ def build_accounts_menu():
return
if len(accounts_list) > 1:
for acc in accounts_list:
label = escape_mnemonic(
app.config.get_per('accounts', acc, 'account_label'))
label = escape_mnemonic(app.get_account_label(acc))
acc_menu.append_submenu(
label or acc, get_account_menu(acc))
label, get_account_menu(acc))
else:
acc_menu = get_account_menu(accounts_list[0])
menubar.remove(menu_position)
......
......@@ -1075,8 +1075,7 @@ class RosterWindow:
account_name = _('Merged accounts')
accounts = []
else:
acclabel = app.config.get_per('accounts', account, 'account_label')
account_name = acclabel or account
account_name = app.get_account_label(account)
accounts = [account]
if account in self.collapsed_rows and \
......@@ -5075,9 +5074,8 @@ class RosterWindow:
accounts.append(account)
accounts.sort()
for account in accounts:
label = app.config.get_per('accounts', account,
'account_label')
item = Gtk.MenuItem.new_with_label(label or account)
label = app.get_account_label(account)
item = Gtk.MenuItem.new_with_label(label)
account_menu = self.build_account_menu(account)
item.set_submenu(account_menu)
menu.append(item)
......
......@@ -243,8 +243,7 @@ class StatusIcon:
self.popup_menus.append(account_menu_for_chat_with)
for account in accounts_list:
account_label = app.config.get_per(
'accounts', account, 'account_label') or account
account_label = app.get_account_label(account)
if app.account_is_connected(account):
# for chat_with
item = Gtk.MenuItem.new_with_label(
......@@ -287,8 +286,7 @@ class StatusIcon:
self.popup_menus.append(account_menu_for_single_message)
for account in accounts_list:
account_label = app.config.get_per(
'accounts', account, 'account_label') or account
account_label = app.get_account_label(account)
if app.connections[account].is_zeroconf or \
not app.account_is_connected(account):
continue
......
......@@ -150,12 +150,12 @@ class NotificationAreaTooltip(StatusTable):
show_lock = False
if message:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['account_label']) + ' - ' + message,
show_lock=show_lock, indent=False)
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
message, show_lock=show_lock, indent=False)
else:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['account_label']), show_lock=show_lock,
indent=False)
GLib.markup_escape_text(acct['account_label']),
show_lock=show_lock, indent=False)
for line in acct['event_lines']:
self.add_text_row(' ' + line, 1)
......@@ -333,12 +333,12 @@ class RosterTooltip(Gtk.Window, StatusTable):
show_lock = False
if message:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['name']) + ' - ' + message,
show_lock=show_lock, indent=False)
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
message, show_lock=show_lock, indent=False)
else:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['name']), show_lock=show_lock,
indent=False)
GLib.markup_escape_text(acct['account_label']),
show_lock=show_lock, indent=False)
for line in acct['event_lines']:
self.add_text_row(' ' + line, 1)
......@@ -371,7 +371,7 @@ class RosterTooltip(Gtk.Window, StatusTable):
nbr_on, nbr_total = app.\
contacts.get_nb_online_total_contacts(
accounts=[account])
account_name = account
account_name = app.get_account_label(account)
if app.account_is_connected(account):
account_name += ' (%s/%s)' % (repr(nbr_on),
repr(nbr_total))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment