Commit 175fb3d2 authored by Daniel Brötzmann's avatar Daniel Brötzmann

Move accelerators from Glade file into code

parent 0de8c8ac
Pipeline #4134 passed with stages
in 2 minutes and 22 seconds
......@@ -425,62 +425,69 @@ class GajimApplication(Gtk.Application):
# General Actions
general_actions = [
('quit', app_actions.on_quit),
('add-account', app_actions.on_add_account),
('manage-proxies', app_actions.on_manage_proxies),
('history-manager', app_actions.on_history_manager),
('preferences', app_actions.on_preferences),
('plugins', app_actions.on_plugins),
('file-transfer', app_actions.on_file_transfers),
('history', app_actions.on_history),
('shortcuts', app_actions.on_keyboard_shortcuts),
('features', app_actions.on_features),
('content', app_actions.on_contents),
('about', app_actions.on_about),
('faq', app_actions.on_faq),
('ipython', app_actions.toggle_ipython),
('show-next-pending-event', app_actions.show_next_pending_event),
('quit', app_actions.on_quit, ['<Primary>Q']),
('add-account', app_actions.on_add_account, None),
('manage-proxies', app_actions.on_manage_proxies, None),
('history-manager', app_actions.on_history_manager, None),
('preferences', app_actions.on_preferences, ['<Primary>P']),
('plugins', app_actions.on_plugins, ['<Primary>E']),
('file-transfer', app_actions.on_file_transfers, ['<Primary>T']),
('history', app_actions.on_history, ['<Primary>H']),
('shortcuts', app_actions.on_keyboard_shortcuts, None),
('features', app_actions.on_features, None),
('content', app_actions.on_contents, None),
('about', app_actions.on_about, None),
('faq', app_actions.on_faq, None),
('ipython', app_actions.toggle_ipython, ['<Primary><Alt>I']),
('show-next-pending-event', app_actions.show_next_pending_event,
None),
]
act = Gio.SimpleAction.new('start-chat', GLib.VariantType.new('s'))
act.connect("activate", app_actions.on_new_chat)
act.connect('activate', app_actions.on_new_chat)
self.add_action(act)
self.set_accels_for_action('app.start-chat::', ['<Primary>N'])
act = Gio.SimpleAction.new('accounts', GLib.VariantType.new('s'))
act.connect("activate", app_actions.on_accounts)
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)
act.connect('activate', app_actions.on_add_contact_jid)
self.add_action(act)
act = Gio.SimpleAction.new('copy-text', GLib.VariantType.new('s'))
act.connect("activate", app_actions.copy_text)
act.connect('activate', app_actions.copy_text)
self.add_action(act)
act = Gio.SimpleAction.new('open-link', GLib.VariantType.new('s'))
act.connect("activate", app_actions.open_link)
act.connect('activate', app_actions.open_link)
self.add_action(act)
act = Gio.SimpleAction.new('create-groupchat', GLib.VariantType.new('s'))
act.connect("activate", app_actions.on_create_gc)
act = Gio.SimpleAction.new('create-groupchat',
GLib.VariantType.new('s'))
act.connect('activate', app_actions.on_create_gc)
self.add_action(act)
self.set_accels_for_action('app.create-groupchat::', ['<Primary>G'])
act = Gio.SimpleAction.new('browse-history',
GLib.VariantType.new('a{sv}'))
act.connect("activate", app_actions.on_browse_history)
act.connect('activate', app_actions.on_browse_history)
self.add_action(act)
act = Gio.SimpleAction.new('groupchat-join',
GLib.VariantType.new('as'))
act.connect("activate", app_actions.on_groupchat_join)
act.connect('activate', app_actions.on_groupchat_join)
self.add_action(act)
for action in general_actions:
action_name, func = action
action_name, func, accel = action
act = Gio.SimpleAction.new(action_name, None)
act.connect("activate", func)
act.connect('activate', func)
if accel:
full_action_name = 'app.%s' % action_name
self.set_accels_for_action(full_action_name, accel)
self.add_action(act)
accounts_list = sorted(app.config.get_per('accounts'))
......@@ -531,7 +538,7 @@ class GajimApplication(Gtk.Application):
continue
act = Gio.SimpleAction.new(
action_name, GLib.VariantType.new(type_))
act.connect("activate", func)
act.connect('activate', func)
if state != 'always':
act.set_enabled(False)
self.add_action(act)
......
......@@ -10,17 +10,14 @@
<item>
<attribute name="label" translatable="yes">Show Contact List</attribute>
<attribute name="action">win.show-roster</attribute>
<attribute name="accel">&lt;Primary&gt;R</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Offline Contacts</attribute>
<attribute name="action">win.show-offline</attribute>
<attribute name="accel">&lt;Primary&gt;O</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Active Contacts</attribute>
<attribute name="action">win.show-active</attribute>
<attribute name="accel">&lt;Primary&gt;Y</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Show Transports</attribute>
......@@ -31,7 +28,6 @@
<item>
<attribute name="label" translatable="yes">File Transfer</attribute>
<attribute name="action">app.file-transfer</attribute>
<attribute name="accel">&lt;Primary&gt;T</attribute>
</item>
<item>
<attribute name="label" translatable="yes">History</attribute>
......@@ -70,13 +66,11 @@
<item>
<attribute name="label" translatable="yes">Start Chat</attribute>
<attribute name="action">app.start-chat</attribute>
<attribute name="accel">&lt;Primary&gt;N</attribute>
<attribute name="target"></attribute>
</item>
<item>
<attribute name="label" translatable="yes">Create Group Chat</attribute>
<attribute name="action">app.create-groupchat</attribute>
<attribute name="accel">&lt;Primary&gt;G</attribute>
<attribute name="target"></attribute>
</item>
<item>
......@@ -90,12 +84,10 @@
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
<attribute name="accel">&lt;Primary&gt;P</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;Q</attribute>
</item>
</section>
</menu>
......
......@@ -5378,32 +5378,35 @@ class RosterWindow:
def add_actions(self):
action = Gio.SimpleAction.new_stateful(
"show-roster", None,
'show-roster', None,
GLib.Variant.new_boolean(
not self.xml.get_object('roster_vbox2').get_no_show_all()))
action.connect("change-state",
action.connect('change-state',
self.on_show_roster_action)
app.app.set_accels_for_action('win.show-roster', ['<Primary>R'])
self.window.add_action(action)
action = Gio.SimpleAction.new_stateful(
"show-offline", None,
'show-offline', None,
GLib.Variant.new_boolean(app.config.get('showoffline')))
action.connect("change-state",
action.connect('change-state',
self.on_show_offline_contacts_action)
app.app.set_accels_for_action('win.show-offline', ['<Primary>O'])
self.window.add_action(action)
action = Gio.SimpleAction.new_stateful(
"show-active", None,
'show-active', None,
GLib.Variant.new_boolean(
app.config.get('show_only_chat_and_online')))
action.connect("change-state",
action.connect('change-state',
self.on_show_active_contacts_action)
app.app.set_accels_for_action('win.show-active', ['<Primary>Y'])
self.window.add_action(action)
action = Gio.SimpleAction.new_stateful(
"show-transports", None,
'show-transports', None,
GLib.Variant.new_boolean(app.config.get('show_transports_group')))
action.connect("change-state", self.on_show_transports_action)
action.connect('change-state', self.on_show_transports_action)
self.window.add_action(action)
################################################################################
......
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