Commit 7fa0b97b authored by Philipp Hörist's avatar Philipp Hörist

Move Accounts menu

Fixes #8955
parent f94f3b06
Pipeline #3884 failed with stages
in 2 minutes and 22 seconds
......@@ -73,10 +73,14 @@ def on_plugins(action, param):
def on_accounts(action, param):
window = app.get_app_window(AccountsWindow)
if window is None:
AccountsWindow()
window = AccountsWindow()
else:
window.present()
account = param.get_string()
if account:
window.select_account(account)
def on_history_manager(action, param):
from gajim.history_manager import HistoryManager
......
......@@ -392,7 +392,6 @@ class GajimApplication(Gtk.Application):
general_actions = [
('quit', app_actions.on_quit),
('accounts', app_actions.on_accounts),
('add-account', app_actions.on_add_account),
('join-groupchat', app_actions.on_join_gc),
('manage-proxies', app_actions.on_manage_proxies),
......@@ -412,6 +411,11 @@ class GajimApplication(Gtk.Application):
('show-next-pending-event', app_actions.show_next_pending_event),
]
act = Gio.SimpleAction.new('accounts', GLib.VariantType.new('s'))
act.connect("activate", app_actions.on_accounts)
self.add_action(act)
self.set_accels_for_action('app.accounts::', ['<Alt>A'])
act = Gio.SimpleAction.new('add-contact', GLib.VariantType.new('s'))
act.connect("activate", app_actions.on_add_contact_jid)
self.add_action(act)
......
......@@ -84,7 +84,7 @@
<object class="GtkMenuItem" id="edit_account_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Modify Account...</property>
<property name="label" translatable="yes">_Modify Account</property>
<property name="use_underline">True</property>
</object>
</child>
......
......@@ -67,11 +67,6 @@
</menu>
<menu id="appmenu">
<section>
<item>
<attribute name="label" translatable="yes">Accounts</attribute>
<attribute name="action">app.accounts</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;A</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Start Chat</attribute>
<attribute name="action">app.start-chat</attribute>
......
......@@ -23,7 +23,7 @@
<object class="GtkMenuItem" id="zeroconf_properties_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Modify Account...</property>
<property name="label" translatable="yes">_Modify Account</property>
<property name="use_underline">True</property>
</object>
</child>
......
......@@ -807,18 +807,27 @@ def build_accounts_menu():
acc_menu = menubar.get_item_link(menu_position, 'submenu')
acc_menu.remove_all()
accounts_list = sorted(app.contacts.get_accounts())
if not accounts_list:
no_accounts = _('No Accounts available')
acc_menu.append_item(Gio.MenuItem.new(no_accounts, None))
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)
......@@ -837,19 +846,21 @@ def build_bookmark_menu(account):
acc_menu = menubar.get_item_link(menu_position, 'submenu')
# We have more than one Account active
if acc_menu.get_item_link(0, 'submenu'):
if acc_menu.get_item_link(1, 'submenu'):
for i in range(acc_menu.get_n_items()):
label = acc_menu.get_item_attribute_value(i, 'label')
account_label = escape_mnemonic(
app.config.get_per('accounts', account, 'account_label'))
if label.get_string() in (account_label, account):
menu = acc_menu.get_item_link(i, 'submenu')
bookmark_position = 1
else:
# We have only one Account active
menu = acc_menu
bookmark_position = 2
label = menu.get_item_attribute_value(1, 'label').get_string()
menu.remove(1)
menu.insert_submenu(1, label, bookmark_menu)
menu.remove(bookmark_position)
menu.insert_submenu(bookmark_position, label, bookmark_menu)
def get_encryption_menu(control_id, type_id, zeroconf=False):
......
......@@ -3076,14 +3076,6 @@ class RosterWindow:
mw.set_active_tab(ctrl)
self.remove_groupchat(jid, account, maximize=True)
def on_edit_account(self, widget, account):
window = app.get_app_window(AccountsWindow)
if window is None:
window = AccountsWindow()
else:
window.present()
window.select_account(account)
def on_change_status_message_activate(self, widget, account):
show = app.SHOW_LIST[app.connections[account].connected]
def on_response(message, pep_dict):
......@@ -4892,8 +4884,8 @@ class RosterWindow:
else:
pep_menuitem.set_sensitive(False)
edit_account_menuitem.connect('activate', self.on_edit_account,
account)
edit_account_menuitem.set_detailed_action_name(
'app.accounts::%s' % account)
if app.connections[account].roster_supported:
add_contact_menuitem.connect('activate',
self.on_add_new_contact, account)
......@@ -4950,8 +4942,8 @@ class RosterWindow:
sub_menu.append(item)
item.connect('activate', self.change_status, account, 'offline')
zeroconf_properties_menuitem.connect('activate',
self.on_edit_account, account)
zeroconf_properties_menuitem.set_detailed_action_name(
'app.accounts::%s' % account)
return account_context_menu
......
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