Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
173f5a06
by Philipp Hörist at 2019-11-15T05:20:50Z
3 changed files:
Changes:
| ... | ... | @@ -236,6 +236,7 @@ class GajimApplication(Gtk.Application): |
| 236 | 236 |
self.interface = Interface()
|
| 237 | 237 |
self.interface.run(self)
|
| 238 | 238 |
self.add_actions()
|
| 239 |
+ self._set_shortcuts()
|
|
| 239 | 240 |
from gajim import gui_menu_builder
|
| 240 | 241 |
gui_menu_builder.build_accounts_menu()
|
| 241 | 242 |
|
| ... | ... | @@ -427,57 +428,44 @@ class GajimApplication(Gtk.Application): |
| 427 | 428 |
act.connect('change-state', app_actions.on_merge_accounts)
|
| 428 | 429 |
self.add_action(act)
|
| 429 | 430 |
|
| 430 |
- # General Actions
|
|
| 431 |
- |
|
| 432 |
- general_actions = [
|
|
| 433 |
- ('quit', app_actions.on_quit, ['<Primary>Q']),
|
|
| 434 |
- ('add-account', app_actions.on_add_account, None),
|
|
| 435 |
- ('manage-proxies', app_actions.on_manage_proxies, None),
|
|
| 436 |
- ('history-manager', app_actions.on_history_manager, None),
|
|
| 437 |
- ('preferences', app_actions.on_preferences, ['<Primary>P']),
|
|
| 438 |
- ('plugins', app_actions.on_plugins, ['<Primary>E']),
|
|
| 439 |
- ('xml-console', app_actions.on_xml_console, ['<Primary><Shift>X']),
|
|
| 440 |
- ('file-transfer', app_actions.on_file_transfers, ['<Primary>T']),
|
|
| 441 |
- ('history', app_actions.on_history, ['<Primary>H']),
|
|
| 442 |
- ('shortcuts', app_actions.on_keyboard_shortcuts, None),
|
|
| 443 |
- ('features', app_actions.on_features, None),
|
|
| 444 |
- ('content', app_actions.on_contents, None),
|
|
| 445 |
- ('about', app_actions.on_about, None),
|
|
| 446 |
- ('faq', app_actions.on_faq, None),
|
|
| 447 |
- ('ipython', app_actions.toggle_ipython, ['<Primary><Alt>I']),
|
|
| 448 |
- ('show-next-pending-event', app_actions.show_next_pending_event,
|
|
| 449 |
- None),
|
|
| 431 |
+ actions = [
|
|
| 432 |
+ ('quit', app_actions.on_quit),
|
|
| 433 |
+ ('add-account', app_actions.on_add_account),
|
|
| 434 |
+ ('manage-proxies', app_actions.on_manage_proxies),
|
|
| 435 |
+ ('history-manager', app_actions.on_history_manager),
|
|
| 436 |
+ ('preferences', app_actions.on_preferences),
|
|
| 437 |
+ ('plugins', app_actions.on_plugins),
|
|
| 438 |
+ ('xml-console', app_actions.on_xml_console),
|
|
| 439 |
+ ('file-transfer', app_actions.on_file_transfers),
|
|
| 440 |
+ ('history', app_actions.on_history),
|
|
| 441 |
+ ('shortcuts', app_actions.on_keyboard_shortcuts),
|
|
| 442 |
+ ('features', app_actions.on_features),
|
|
| 443 |
+ ('content', app_actions.on_contents),
|
|
| 444 |
+ ('about', app_actions.on_about),
|
|
| 445 |
+ ('faq', app_actions.on_faq),
|
|
| 446 |
+ ('ipython', app_actions.toggle_ipython),
|
|
| 447 |
+ ('show-next-pending-event', app_actions.show_next_pending_event),
|
|
| 448 |
+ ('start-chat', 's', app_actions.on_new_chat),
|
|
| 449 |
+ ('accounts', 's', app_actions.on_accounts),
|
|
| 450 |
+ ('add-contact', 's', app_actions.on_add_contact_jid),
|
|
| 451 |
+ ('copy-text', 's', app_actions.copy_text),
|
|
| 452 |
+ ('open-link', 'as', app_actions.open_link),
|
|
| 453 |
+ ('open-mail', 's', app_actions.open_mail),
|
|
| 454 |
+ ('create-groupchat', 's', app_actions.on_create_gc),
|
|
| 455 |
+ ('browse-history', 'a{sv}', app_actions.on_browse_history),
|
|
| 456 |
+ ('groupchat-join', 'as', app_actions.on_groupchat_join),
|
|
| 450 | 457 |
]
|
| 451 | 458 |
|
| 452 |
- additional_actions = [
|
|
| 453 |
- ('start-chat', 's', app_actions.on_new_chat, ['<Primary>N']),
|
|
| 454 |
- ('accounts', 's', app_actions.on_accounts, ['<Alt>A']),
|
|
| 455 |
- ('add-contact', 's', app_actions.on_add_contact_jid, None),
|
|
| 456 |
- ('copy-text', 's', app_actions.copy_text, None),
|
|
| 457 |
- ('open-link', 'as', app_actions.open_link, None),
|
|
| 458 |
- ('open-mail', 's', app_actions.open_mail, None),
|
|
| 459 |
- ('create-groupchat', 's', app_actions.on_create_gc, ['<Primary>G']),
|
|
| 460 |
- ('browse-history', 'a{sv}', app_actions.on_browse_history, None),
|
|
| 461 |
- ('groupchat-join', 'as', app_actions.on_groupchat_join, None),
|
|
| 462 |
- ]
|
|
| 463 |
- |
|
| 464 |
- for action in general_actions:
|
|
| 465 |
- action_name, func, accel = action
|
|
| 466 |
- act = Gio.SimpleAction.new(action_name, None)
|
|
| 467 |
- act.connect('activate', func)
|
|
| 468 |
- if accel:
|
|
| 469 |
- full_action_name = 'app.%s' % action_name
|
|
| 470 |
- self.set_accels_for_action(full_action_name, accel)
|
|
| 471 |
- self.add_action(act)
|
|
| 459 |
+ for action in actions:
|
|
| 460 |
+ if len(action) == 2:
|
|
| 461 |
+ action_name, func = action
|
|
| 462 |
+ variant = None
|
|
| 463 |
+ else:
|
|
| 464 |
+ action_name, variant, func = action
|
|
| 465 |
+ variant = GLib.VariantType.new(variant)
|
|
| 472 | 466 |
|
| 473 |
- for action in additional_actions:
|
|
| 474 |
- action_name, variant, func, accel = action
|
|
| 475 |
- act = Gio.SimpleAction.new(
|
|
| 476 |
- action_name, GLib.VariantType.new(variant))
|
|
| 467 |
+ act = Gio.SimpleAction.new(action_name, variant)
|
|
| 477 | 468 |
act.connect('activate', func)
|
| 478 |
- if accel:
|
|
| 479 |
- full_action_name = 'app.%s::' % action_name
|
|
| 480 |
- self.set_accels_for_action(full_action_name, accel)
|
|
| 481 | 469 |
self.add_action(act)
|
| 482 | 470 |
|
| 483 | 471 |
accounts_list = sorted(app.config.get_per('accounts'))
|
| ... | ... | @@ -545,6 +533,54 @@ class GajimApplication(Gtk.Application): |
| 545 | 533 |
# We go online
|
| 546 | 534 |
self.lookup_action(account + action_name).set_enabled(True)
|
| 547 | 535 |
|
| 536 |
+ def _set_shortcuts(self):
|
|
| 537 |
+ shortcuts = {
|
|
| 538 |
+ 'app.quit': ['<Primary>Q'],
|
|
| 539 |
+ 'app.preferences': ['<Primary>P'],
|
|
| 540 |
+ 'app.plugins': ['<Primary>E'],
|
|
| 541 |
+ 'app.xml-console': ['<Primary><Shift>X'],
|
|
| 542 |
+ 'app.file-transfer': ['<Primary>T'],
|
|
| 543 |
+ 'app.history': ['<Primary>H'],
|
|
| 544 |
+ 'app.ipython': ['<Primary><Alt>I'],
|
|
| 545 |
+ 'app.start-chat::': ['<Primary>N'],
|
|
| 546 |
+ 'app.accounts::': ['<Alt>A'],
|
|
| 547 |
+ 'app.create-groupchat::': ['<Primary>G'],
|
|
| 548 |
+ 'win.show-roster': ['<Primary>R'],
|
|
| 549 |
+ 'win.show-offline': ['<Primary>O'],
|
|
| 550 |
+ 'win.show-active': ['<Primary>Y'],
|
|
| 551 |
+ 'win.change-nickname': ['<Control><Shift>n'],
|
|
| 552 |
+ 'win.change-subject': ['<Alt>t'],
|
|
| 553 |
+ 'win.escape': ['Escape'],
|
|
| 554 |
+ 'win.browse-history': ['<Control>h'],
|
|
| 555 |
+ 'win.send-file': ['<Control>f'],
|
|
| 556 |
+ 'win.show-contact-info': ['<Control>i'],
|
|
| 557 |
+ 'win.show-emoji-chooser': ['<Alt>m'],
|
|
| 558 |
+ 'win.clear-chat': ['<Control>l'],
|
|
| 559 |
+ 'win.delete-line': ['<Control>u'],
|
|
| 560 |
+ 'win.close-tab': ['<Control>w'],
|
|
| 561 |
+ 'win.move-tab-up': ['<Control><Shift>Page_Up'],
|
|
| 562 |
+ 'win.move-tab-down': ['<Control><Shift>Page_Down'],
|
|
| 563 |
+ 'win.switch-next-tab': ['<Alt>Right'],
|
|
| 564 |
+ 'win.switch-prev-tab': ['<Alt>Left'],
|
|
| 565 |
+ 'win.switch-next-unread-tab-right': ['<Control>Tab',
|
|
| 566 |
+ '<Control>Page_Down'],
|
|
| 567 |
+ 'win.switch-next-unread-tab-left': ['<Control>ISO_Left_Tab',
|
|
| 568 |
+ '<Control>Page_Up'],
|
|
| 569 |
+ 'win.switch-tab-1': ['<Alt>1', '<Alt>KP_1'],
|
|
| 570 |
+ 'win.switch-tab-2': ['<Alt>2', '<Alt>KP_2'],
|
|
| 571 |
+ 'win.switch-tab-3': ['<Alt>3', '<Alt>KP_3'],
|
|
| 572 |
+ 'win.switch-tab-4': ['<Alt>4', '<Alt>KP_4'],
|
|
| 573 |
+ 'win.switch-tab-5': ['<Alt>5', '<Alt>KP_5'],
|
|
| 574 |
+ 'win.switch-tab-6': ['<Alt>6', '<Alt>KP_6'],
|
|
| 575 |
+ 'win.switch-tab-7': ['<Alt>7', '<Alt>KP_7'],
|
|
| 576 |
+ 'win.switch-tab-8': ['<Alt>8', '<Alt>KP_8'],
|
|
| 577 |
+ 'win.switch-tab-9': ['<Alt>9', '<Alt>KP_9'],
|
|
| 578 |
+ 'win.copy-text': ['<Control><Shift>c'],
|
|
| 579 |
+ }
|
|
| 580 |
+ |
|
| 581 |
+ for action, accels in shortcuts.items():
|
|
| 582 |
+ self.set_accels_for_action(action, accels)
|
|
| 583 |
+ |
|
| 548 | 584 |
def _on_feature_discovered(self, event):
|
| 549 | 585 |
if event.feature == nbxmpp.NS_VCARD:
|
| 550 | 586 |
action = '%s-profile' % event.account
|
| ... | ... | @@ -162,34 +162,32 @@ class MessageWindow(EventHelper): |
| 162 | 162 |
|
| 163 | 163 |
def _add_actions(self):
|
| 164 | 164 |
actions = [
|
| 165 |
- ('change-nickname', ['<Control><Shift>n']),
|
|
| 166 |
- ('change-subject', ['<Alt>t']),
|
|
| 167 |
- ('escape', ['Escape']),
|
|
| 168 |
- ('browse-history', ['<Control>h']),
|
|
| 169 |
- ('send-file', ['<Control>f']),
|
|
| 170 |
- ('show-contact-info', ['<Control>i']),
|
|
| 171 |
- ('show-emoji-chooser', ['<Alt>m']),
|
|
| 172 |
- ('clear-chat', ['<Control>l']),
|
|
| 173 |
- ('delete-line', ['<Control>u']),
|
|
| 174 |
- ('close-tab', ['<Control>w']),
|
|
| 175 |
- ('move-tab-up', ['<Control><Shift>Page_Up']),
|
|
| 176 |
- ('move-tab-down', ['<Control><Shift>Page_Down']),
|
|
| 177 |
- ('switch-next-tab', ['<Alt>Right']),
|
|
| 178 |
- ('switch-prev-tab', ['<Alt>Left']),
|
|
| 179 |
- ('switch-next-unread-tab-right', ['<Control>Tab',
|
|
| 180 |
- '<Control>Page_Down']),
|
|
| 181 |
- ('switch-next-unread-tab-left', ['<Control>ISO_Left_Tab',
|
|
| 182 |
- '<Control>Page_Up']),
|
|
| 183 |
- ('switch-tab-1', ['<Alt>1', '<Alt>KP_1']),
|
|
| 184 |
- ('switch-tab-2', ['<Alt>2', '<Alt>KP_2']),
|
|
| 185 |
- ('switch-tab-3', ['<Alt>3', '<Alt>KP_3']),
|
|
| 186 |
- ('switch-tab-4', ['<Alt>4', '<Alt>KP_4']),
|
|
| 187 |
- ('switch-tab-5', ['<Alt>5', '<Alt>KP_5']),
|
|
| 188 |
- ('switch-tab-6', ['<Alt>6', '<Alt>KP_6']),
|
|
| 189 |
- ('switch-tab-7', ['<Alt>7', '<Alt>KP_7']),
|
|
| 190 |
- ('switch-tab-8', ['<Alt>8', '<Alt>KP_8']),
|
|
| 191 |
- ('switch-tab-9', ['<Alt>9', '<Alt>KP_9']),
|
|
| 192 |
- ('copy-text', ['<Control><Shift>c']),
|
|
| 165 |
+ 'change-nickname',
|
|
| 166 |
+ 'change-subject',
|
|
| 167 |
+ 'escape',
|
|
| 168 |
+ 'browse-history',
|
|
| 169 |
+ 'send-file',
|
|
| 170 |
+ 'show-contact-info',
|
|
| 171 |
+ 'show-emoji-chooser',
|
|
| 172 |
+ 'clear-chat',
|
|
| 173 |
+ 'delete-line',
|
|
| 174 |
+ 'close-tab',
|
|
| 175 |
+ 'move-tab-up',
|
|
| 176 |
+ 'move-tab-down',
|
|
| 177 |
+ 'switch-next-tab',
|
|
| 178 |
+ 'switch-prev-tab',
|
|
| 179 |
+ 'switch-next-unread-tab-right'
|
|
| 180 |
+ 'switch-next-unread-tab-left',
|
|
| 181 |
+ 'switch-tab-1',
|
|
| 182 |
+ 'switch-tab-2',
|
|
| 183 |
+ 'switch-tab-3',
|
|
| 184 |
+ 'switch-tab-4',
|
|
| 185 |
+ 'switch-tab-5',
|
|
| 186 |
+ 'switch-tab-6',
|
|
| 187 |
+ 'switch-tab-7',
|
|
| 188 |
+ 'switch-tab-8',
|
|
| 189 |
+ 'switch-tab-9',
|
|
| 190 |
+ 'copy-text',
|
|
| 193 | 191 |
]
|
| 194 | 192 |
|
| 195 | 193 |
disabled_for_emacs = (
|
| ... | ... | @@ -201,13 +199,12 @@ class MessageWindow(EventHelper): |
| 201 | 199 |
key_theme = Gtk.Settings.get_default().get_property(
|
| 202 | 200 |
'gtk-key-theme-name')
|
| 203 | 201 |
|
| 204 |
- for action, keys in actions:
|
|
| 202 |
+ for action in actions:
|
|
| 205 | 203 |
if key_theme == 'Emacs' and action in disabled_for_emacs:
|
| 206 | 204 |
continue
|
| 207 | 205 |
act = Gio.SimpleAction.new(action, None)
|
| 208 | 206 |
act.connect('activate', self._on_action)
|
| 209 | 207 |
self.window.add_action(act)
|
| 210 |
- app.app.set_accels_for_action('win.%s' % action, keys)
|
|
| 211 | 208 |
|
| 212 | 209 |
def _on_action(self, action, _param):
|
| 213 | 210 |
control = self.get_active_control()
|
| ... | ... | @@ -5370,33 +5370,26 @@ class RosterWindow: |
| 5370 | 5370 |
actions = [
|
| 5371 | 5371 |
('show-roster',
|
| 5372 | 5372 |
not self.xml.get_object('roster_vbox2').get_no_show_all(),
|
| 5373 |
- self.on_show_roster_action,
|
|
| 5374 |
- ['<Primary>R']),
|
|
| 5373 |
+ self.on_show_roster_action),
|
|
| 5375 | 5374 |
|
| 5376 | 5375 |
('show-offline',
|
| 5377 | 5376 |
app.config.get('showoffline'),
|
| 5378 |
- self.on_show_offline_contacts_action,
|
|
| 5379 |
- ['<Primary>O']),
|
|
| 5377 |
+ self.on_show_offline_contacts_action),
|
|
| 5380 | 5378 |
|
| 5381 | 5379 |
('show-active',
|
| 5382 | 5380 |
app.config.get('show_only_chat_and_online'),
|
| 5383 |
- self.on_show_active_contacts_action,
|
|
| 5384 |
- ['<Primary>Y']),
|
|
| 5381 |
+ self.on_show_active_contacts_action),
|
|
| 5385 | 5382 |
|
| 5386 | 5383 |
('show-transports',
|
| 5387 | 5384 |
app.config.get('show_transports_group'),
|
| 5388 |
- self.on_show_transports_action,
|
|
| 5389 |
- None),
|
|
| 5385 |
+ self.on_show_transports_action),
|
|
| 5390 | 5386 |
]
|
| 5391 | 5387 |
|
| 5392 | 5388 |
for action in actions:
|
| 5393 |
- action_name, variant, func, accel = action
|
|
| 5389 |
+ action_name, variant, func = action
|
|
| 5394 | 5390 |
act = Gio.SimpleAction.new_stateful(
|
| 5395 | 5391 |
action_name, None, GLib.Variant.new_boolean(variant))
|
| 5396 | 5392 |
act.connect('change-state', func)
|
| 5397 |
- if accel:
|
|
| 5398 |
- full_action_name = 'win.%s' % action_name
|
|
| 5399 |
- app.app.set_accels_for_action(full_action_name, accel)
|
|
| 5400 | 5393 |
self.window.add_action(act)
|
| 5401 | 5394 |
|
| 5402 | 5395 |
################################################################################
|