From ae0c1309a2ba56d1d789f418c9c6f4c43355e0e3 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 17 Jan 2023 20:01:41 +0100 Subject: [PATCH] :wrench: Bind profile combo rows to settings --- prefs.js | 32 ++++++----- resources/ui/adw/prefs.ui | 52 ++++++++--------- .../ui/common/{main-menu.ui => menus.ui} | 8 ++- ...ell.extensions.burn-my-windows.gschema.xml | 57 +++++++++++++------ 4 files changed, 89 insertions(+), 60 deletions(-) rename resources/ui/common/{main-menu.ui => menus.ui} (92%) diff --git a/prefs.js b/prefs.js index 9792544..22265ad 100644 --- a/prefs.js +++ b/prefs.js @@ -98,7 +98,7 @@ var PreferencesDialog = class PreferencesDialog { // Load the general user interface files. this._builder = new Gtk.Builder(); - this._builder.add_from_resource(`/ui/common/main-menu.ui`); + this._builder.add_from_resource(`/ui/common/menus.ui`); this._builder.add_from_resource(`/ui/${utils.getUIDir()}/prefs.ui`); // Check whether the power profiles daemon is available - if not, we hide the @@ -169,7 +169,7 @@ var PreferencesDialog = class PreferencesDialog { // Now add the two toggle buttons for enabling and disabling the effect. const button = Gtk.Switch.new(); - button.set_action_name(`enabled-effects.${effect.getNick()}-enable-effect`); + button.set_action_name(`prefs.${effect.getNick()}-enable-effect`); button.set_tooltip_text(_('Use this effect')); button.set_valign(Gtk.Align.CENTER); @@ -232,6 +232,10 @@ var PreferencesDialog = class PreferencesDialog { // Show the version number in the title bar. window.set_title(`Burn-My-Windows ${Me.metadata.version}`); + // Populate the menu with actions. + const group = Gio.SimpleActionGroup.new(); + window.insert_action_group('prefs', group); + // Add the main menu to the title bar. { // Add the menu button to the title bar. @@ -262,10 +266,6 @@ var PreferencesDialog = class PreferencesDialog { window.get_titlebar().pack_start(menu); } - // Populate the menu with actions. - const group = Gio.SimpleActionGroup.new(); - window.insert_action_group('prefs', group); - const addURIAction = (name, uri) => { const action = Gio.SimpleAction.new(name, null); action.connect('activate', () => Gtk.show_uri(null, uri, Gdk.CURRENT_TIME)); @@ -379,11 +379,17 @@ var PreferencesDialog = class PreferencesDialog { group.add_action(aboutAction); } + // Bind all the profile-related actions. + { + this.bindComboRow('profile-animation-type'); + this.bindComboRow('profile-window-type'); + this.bindComboRow('profile-desktop-style'); + this.bindComboRow('profile-power-mode'); + this.bindComboRow('profile-power-profile'); + } + // Populate the enabled-effects drop-down menu. { - const group = Gio.SimpleActionGroup.new(); - window.insert_action_group('enabled-effects', group); - this._ALL_EFFECTS.forEach(effect => { const [minMajor, minMinor] = effect.getMinShellVersion(); if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { @@ -396,7 +402,7 @@ var PreferencesDialog = class PreferencesDialog { if (!utils.isADW()) { const menu = this._builder.get_object('enabled-effects-menu'); const label = effect.getLabel(); - menu.append_item(Gio.MenuItem.new(label, 'enabled-effects.' + actionName)); + menu.append_item(Gio.MenuItem.new(label, 'prefs.' + actionName)); } } }); @@ -434,10 +440,10 @@ var PreferencesDialog = class PreferencesDialog { return this._widget; } - // Connects a Gtk.ComboBox (or anything else which has an 'active-id' property) to a + // Connects a Gtk.ComboBox (or anything else which has an 'selected' property) to a // settings key. It also binds the corresponding reset button. - bindCombobox(settingsKey) { - this._bind(settingsKey, 'active-id'); + bindComboRow(settingsKey) { + this._bind(settingsKey, 'selected'); } // Connects a Gtk.Adjustment (or anything else which has a 'value' property) to a diff --git a/resources/ui/adw/prefs.ui b/resources/ui/adw/prefs.ui index d2eb6da..98da513 100644 --- a/resources/ui/adw/prefs.ui +++ b/resources/ui/adw/prefs.ui @@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-3.0-or-later Default Profile - effect-profile-menu + profile-menu @@ -66,10 +66,10 @@ SPDX-License-Identifier: GPL-3.0-or-later Here you can specify under which circumstances the current effect settings should be applied. - + Choose an Application - + bmw-select-app-symbolic center @@ -78,14 +78,14 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Animation Type - Any - Open Windows - Close Windows + Any + Open Windows + Close Windows @@ -93,14 +93,14 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Window Type - Any - Normal Windows - Dialogs + Any + Normal Windows + Dialogs @@ -108,14 +108,14 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Desktop Style - Any - Default Mode - Dark Mode + Any + Default Mode + Dark Mode @@ -123,14 +123,14 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Power Mode - Any - On Battery - Plugged In + Any + On Battery + Plugged In @@ -138,17 +138,17 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Power Profile - Any - Power-Saver Mode - Balanced Mode - Performance Mode - Power Saver or Balanced - Balanced or Performance + Any + Power-Saver Mode + Balanced Mode + Performance Mode + Power Saver or Balanced + Balanced or Performance diff --git a/resources/ui/common/main-menu.ui b/resources/ui/common/menus.ui similarity index 92% rename from resources/ui/common/main-menu.ui rename to resources/ui/common/menus.ui index 1a4f833..cc1248a 100644 --- a/resources/ui/common/main-menu.ui +++ b/resources/ui/common/menus.ui @@ -6,6 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later --> +
@@ -50,18 +51,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
- +
Default Profile - profile.default + prefs.profile-default
Add New... - profile.new + prefs.profile-new
+ \ No newline at end of file diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml index edac16e..4c03baa 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -13,24 +13,6 @@ SPDX-License-Identifier: CC0-1.0 - - false - Destroy Dialogs - Set to true to burn dialogs as well. - - - - false - Disable on Battery - Enable effects only if plugged in. - - - - false - Disable on Power Save - Enable effects only if power saver is disabled. - - "" Preview Effect @@ -43,6 +25,45 @@ SPDX-License-Identifier: CC0-1.0 If set to true, all animations will show only one still frame to allow for continuous integration tests. + + + + + + 0 + + Profile Animation Type + The animation types for which the current effect settings should be used. + + + + 0 + + Profile Window Type + The window types for which the current effect settings should be used. + + + + 0 + + Profile Desktop Style + The desktop styles for which the current effect settings should be used. + + + + 0 + + Profile Power Mode + The power mode for which the current effect settings should be used. + + + + 0 + + Profile Power Profile + The power profiles in which the current effect settings should be used. + +