Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowManager: Add keybindings to launch dock items #1938

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,51 @@
<summary>The shortcut to enable picture-in-picture window</summary>
<description>The shortcut to show the selection area to choose a window.</description>
</key>
<key type="as" name="launch-dock-1">
<default><![CDATA[['<Super>1']]]></default>
<summary>Launch the first dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-2">
<default><![CDATA[['<Super>2']]]></default>
<summary>Launch the second dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-3">
<default><![CDATA[['<Super>3']]]></default>
<summary>Launch the third dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-4">
<default><![CDATA[['<Super>4']]]></default>
<summary>Launch the fourth dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-5">
<default><![CDATA[['<Super>5']]]></default>
<summary>Launch the fith dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-6">
<default><![CDATA[['<Super>6']]]></default>
<summary>Launch the sixth dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-7">
<default><![CDATA[['<Super>7']]]></default>
<summary>Launch the seventh dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-8">
<default><![CDATA[['<Super>8']]]></default>
<summary>Launch the eigth dock item</summary>
<description></description>
</key>
<key type="as" name="launch-dock-9">
<default><![CDATA[['<Super>9']]]></default>
<summary>Launch the nineth dock item</summary>
<description></description>
</key>
</schema>

<schema path="/org/pantheon/desktop/gala/appearance/" id="org.pantheon.desktop.gala.appearance">
Expand Down
23 changes: 23 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ namespace Gala {
display.add_keybinding ("window-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("area-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot);

display.add_keybinding ("launch-dock-1", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-2", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-3", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-4", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-5", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-6", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-7", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-8", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);
display.add_keybinding ("launch-dock-9", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock);

display.overlay_key.connect (() => {
launch_action ("overlay-action");
});
Expand Down Expand Up @@ -506,6 +516,19 @@ namespace Gala {
}
}

[CCode (instance_pos = -1)]
private void handle_launch_dock (Meta.Display display, Meta.Window? window,
Clutter.KeyEvent event, Meta.KeyBinding binding) {
var name = binding.get_name ();
int index = name[name.length - 1] - '0';

try {
Process.spawn_command_line_async ("io.elementary.dock -i %u".printf (index));
} catch (Error e) {
warning ("Failed to launch dock item: %s", e.message);
}
}

private void on_gesture_detected (Gesture gesture) {
if (workspace_view.is_opened ()) {
return;
Expand Down
Loading