Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

feat: add keyboard shortcuts (#776) #777

Merged
merged 3 commits into from
May 28, 2023
Merged
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
2 changes: 2 additions & 0 deletions data/gradience.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<file preprocess="xml-stripblanks">ui/theming_empty_group.ui</file>
<file preprocess="xml-stripblanks">ui/welcome_window.ui</file>
<file preprocess="xml-stripblanks">ui/window.ui</file>
<file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/help_overlay.ui</file>

<file>images/welcome.svg</file>
<file>style.css</file>
</gresource>
Expand Down
59 changes: 59 additions & 0 deletions data/ui/help_overlay.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Gtk 4.0;

ShortcutsWindow help_overlay {
modal: true;

ShortcutsSection {
section-name: "shortcuts";
max-height: 10;

ShortcutsGroup {
title: C_("shortcut window", "General");

ShortcutsShortcut {
title: C_("shortcut window", "Show Shortcuts");
action-name: "win.show-help-overlay";
}

ShortcutsShortcut {
title: C_("shortcut window", "Show Apply Dialog");
action-name: "app.apply_color_scheme";
}

ShortcutsShortcut {
title: C_("shortcut window", "Manage Presets");
action-name: "app.manage_presets";
}

ShortcutsShortcut {
title: C_("shortcut window", "Save Preset");
action-name: "app.save_preset";
}

ShortcutsShortcut {
title: C_("shortcut window", "Go to the Colors Section");
action-name: "app.switch_to_colors_page";
}

ShortcutsShortcut {
title: C_("shortcut window", "Go to the Theming Section");
action-name: "app.switch_to_theming_page";
}

ShortcutsShortcut {
title: C_("shortcut window", "Go to the Advanced Section");
action-name: "app.switch_to_advanced_page";
}

ShortcutsShortcut {
title: C_("shortcut window", "Preferences");
action-name: "app.preferences";
}

ShortcutsShortcut {
title: C_("shortcut window", "Quit");
action-name: "app.quit";
}
}
}
}
1 change: 1 addition & 0 deletions data/ui/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ blueprints = custom_target('blueprints',
'preset_row.blp',
'builtin_preset_row.blp',
'explore_preset_row.blp',
'help_overlay.blp',
'save_dialog.blp',
'shell_prefs_window.blp',
'shell_theming_group.blp',
Expand Down
5 changes: 5 additions & 0 deletions data/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ menu main-menu {
action: "app.preferences";
}

item {
label: _("Keyboard Shortcuts");
action: "win.show-help-overlay";
}

item {
label: _("About Gradience");
action: "app.about";
Expand Down
20 changes: 16 additions & 4 deletions gradience/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,28 @@ def do_activate(self):
self.open_preset_directory)

self.actions.create_action("apply_color_scheme",
self.show_apply_color_scheme_dialog)
self.show_apply_color_scheme_dialog, ["<primary>Return"])

self.actions.create_action("manage_presets",
self.show_presets_manager)
self.show_presets_manager, ["<primary>m"])

self.actions.create_action("preferences",
self.show_preferences)
self.show_preferences, ["<primary>comma"])

self.actions.create_action("save_preset",
self.show_save_preset_dialog)
self.show_save_preset_dialog, ["<primary>s"])

self.actions.create_action("quit",
self.win.on_close_request, ["<primary>q"])

self.actions.create_action("switch_to_colors_page",
self.win.switch_to_colors_page, ["<alt>1"])

self.actions.create_action("switch_to_theming_page",
self.win.switch_to_theming_page, ["<alt>2"])

self.actions.create_action("switch_to_advanced_page",
self.win.switch_to_advanced_page, ["<alt>3"])

self.actions.create_action("about",
self.show_about_window)
Expand Down
12 changes: 12 additions & 0 deletions gradience/frontend/views/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class GradienceMainWindow(Adw.ApplicationWindow):
content_theming = Gtk.Template.Child("content-theming")
content_plugins = Gtk.Template.Child("content-plugins")

view_stack = Gtk.Template.Child()

toast_overlay = Gtk.Template.Child()

save_preset_button = Gtk.Template.Child("save-preset-button")
Expand Down Expand Up @@ -79,6 +81,16 @@ def setup_signals(self):
self.connect("unrealize",
self.save_window_props)

def switch_to_colors_page(self, *args):
self.view_stack.set_visible_child_name("colors")

def switch_to_theming_page(self, *args):
self.view_stack.set_visible_child_name("theming")

def switch_to_advanced_page(self, *args):
self.view_stack.set_visible_child_name("plugins")


def setup(self):
# Set devel style
if build_type == "debug":
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ data/ui/app_type_dialog.blp
data/ui/builtin_preset_row.blp
data/ui/custom_css_group.blp
data/ui/explore_preset_row.blp
data/ui/help_overlay.blp
data/ui/monet_theming_group.blp
data/ui/log_out_dialog.blp
data/ui/no_plugin_window.blp
Expand Down