From 018a8c36b371a950a802739e202e12c9543d0595 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 24 May 2023 05:58:39 +0900 Subject: [PATCH] Add link to custom shortcuts (#443) --- src/Plug.vala | 5 +++++ src/Views/Shortcuts.vala | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Plug.vala b/src/Plug.vala index a8a26b8d4..0a949912d 100644 --- a/src/Plug.vala +++ b/src/Plug.vala @@ -33,6 +33,7 @@ public class Pantheon.Keyboard.Plug : Switchboard.Plug { settings.set ("input/keyboard/behavior", "Behavior"); settings.set ("input/keyboard/inputmethod", "Input Method"); settings.set ("input/keyboard/shortcuts", "Shortcuts"); + settings.set ("input/keyboard/shortcuts/custom", "Custom Shortcuts"); Object (category: Category.HARDWARE, code_name: "io.elementary.switchboard.keyboard", display_name: _("Keyboard"), @@ -82,6 +83,10 @@ public class Pantheon.Keyboard.Plug : Switchboard.Plug { public override void search_callback (string location) { switch (location) { default: + case "Custom Shortcuts": + stack.visible_child_name = "shortcuts"; + ((Keyboard.Shortcuts.Page) stack.get_child_by_name ("shortcuts")).open_custom_shortcuts (); + break; case "Shortcuts": stack.visible_child_name = "shortcuts"; break; diff --git a/src/Views/Shortcuts.vala b/src/Views/Shortcuts.vala index 8d5c8e2d0..20eca00a9 100644 --- a/src/Views/Shortcuts.vala +++ b/src/Views/Shortcuts.vala @@ -61,13 +61,16 @@ namespace Pantheon.Keyboard.Shortcuts { } class Page : Gtk.Grid { + private Gtk.ListBox section_switcher; + private SwitcherRow custom_shortcuts_row; + construct { CustomShortcutSettings.init (); list = new List (); settings = new Shortcuts.Settings (); - var section_switcher = new Gtk.ListBox (); + section_switcher = new Gtk.ListBox (); section_switcher.add (new SwitcherRow (list.windows_group)); section_switcher.add (new SwitcherRow (list.workspaces_group)); section_switcher.add (new SwitcherRow (list.screenshot_group)); @@ -75,7 +78,9 @@ namespace Pantheon.Keyboard.Shortcuts { section_switcher.add (new SwitcherRow (list.media_group)); section_switcher.add (new SwitcherRow (list.a11y_group)); section_switcher.add (new SwitcherRow (list.system_group)); - section_switcher.add (new SwitcherRow (list.custom_group)); + + custom_shortcuts_row = new SwitcherRow (list.custom_group); + section_switcher.add (custom_shortcuts_row); section_switcher.select_row (section_switcher.get_row_at_index (0)); @@ -144,6 +149,10 @@ namespace Pantheon.Keyboard.Shortcuts { }); } + public void open_custom_shortcuts () { + section_switcher.select_row (custom_shortcuts_row); + } + public bool system_shortcut_conflicts (Shortcut shortcut, out string name, out string group) { name = ""; group = "";