mirror of
https://github.com/elementary/gala.git
synced 2024-08-16 18:40:27 +03:00
Add keybindings for switching input source (#1600)
This commit is contained in:
parent
1a4c1e8f95
commit
cd75c04428
@ -192,14 +192,14 @@
|
||||
<summary>Copy a screenshot of an area to clipboard</summary>
|
||||
</key>
|
||||
<key type="as" name="switch-input-source">
|
||||
<default><![CDATA[['<Alt>space']]]></default>
|
||||
<default><![CDATA[['']]]></default>
|
||||
<summary>Cycle to next keyboard layout</summary>
|
||||
<description>DEPRECATED: This key is deprecated and ignored.</description>
|
||||
<description></description>
|
||||
</key>
|
||||
<key type="as" name="switch-input-source-backward">
|
||||
<default><![CDATA[['']]]></default>
|
||||
<summary>Cycle to previous keyboard layout</summary>
|
||||
<description>DEPRECATED: This key is deprecated and ignored.</description>
|
||||
<description></description>
|
||||
</key>
|
||||
<key type="as" name="pip">
|
||||
<default><![CDATA[['<Super>f']]]></default>
|
||||
|
@ -16,7 +16,7 @@ public class Gala.KeyboardManager : Object {
|
||||
|
||||
instance = new KeyboardManager ();
|
||||
|
||||
display.modifiers_accelerator_activated.connect (instance.handle_modifiers_accelerator_activated);
|
||||
display.modifiers_accelerator_activated.connect ((display) => KeyboardManager.handle_modifiers_accelerator_activated (display, false));
|
||||
}
|
||||
|
||||
static construct {
|
||||
@ -37,7 +37,7 @@ public class Gala.KeyboardManager : Object {
|
||||
}
|
||||
|
||||
[CCode (instance_pos = -1)]
|
||||
private bool handle_modifiers_accelerator_activated (Meta.Display display) {
|
||||
public static bool handle_modifiers_accelerator_activated (Meta.Display display, bool backward) {
|
||||
display.ungrab_keyboard (display.get_current_time ());
|
||||
|
||||
var sources = settings.get_value ("sources");
|
||||
@ -51,7 +51,12 @@ public class Gala.KeyboardManager : Object {
|
||||
}
|
||||
|
||||
var current = settings.get_uint ("current");
|
||||
settings.set_uint ("current", (current + 1) % n_sources);
|
||||
|
||||
if (!backward) {
|
||||
settings.set_uint ("current", (current + 1) % n_sources);
|
||||
} else {
|
||||
settings.set_uint ("current", (current - 1) % n_sources);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -250,6 +250,8 @@ namespace Gala {
|
||||
display.add_keybinding ("cycle-workspaces-next", keybinding_settings, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) handle_cycle_workspaces);
|
||||
display.add_keybinding ("cycle-workspaces-previous", keybinding_settings, Meta.KeyBindingFlags.NONE, (Meta.KeyHandlerFunc) handle_cycle_workspaces);
|
||||
display.add_keybinding ("panel-main-menu", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_applications_menu);
|
||||
display.add_keybinding ("switch-input-source", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_input_source);
|
||||
display.add_keybinding ("switch-input-source-backward", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_switch_input_source);
|
||||
|
||||
display.add_keybinding ("screenshot", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);
|
||||
display.add_keybinding ("window-screenshot", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);
|
||||
@ -473,6 +475,12 @@ namespace Gala {
|
||||
launch_action ("panel-main-menu-action");
|
||||
}
|
||||
|
||||
[CCode (instance_pos = -1)]
|
||||
private void handle_switch_input_source (Meta.Display display, Meta.Window? window,
|
||||
Clutter.KeyEvent event, Meta.KeyBinding binding) {
|
||||
KeyboardManager.handle_modifiers_accelerator_activated (display, binding.get_name ().has_suffix ("-backward"));
|
||||
}
|
||||
|
||||
[CCode (instance_pos = -1)]
|
||||
private void handle_screenshot (Meta.Display display, Meta.Window? window,
|
||||
Clutter.KeyEvent event, Meta.KeyBinding binding) {
|
||||
|
Loading…
Reference in New Issue
Block a user