🔧 Bind profile combo rows to settings

This commit is contained in:
Simon Schneegans
2023-01-17 20:01:41 +01:00
parent a0d134f629
commit ae0c1309a2
4 changed files with 89 additions and 60 deletions
+19 -13
View File
@@ -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
+26 -26
View File
@@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<child>
<object class="GtkMenuButton">
<property name="label">Default Profile</property>
<property name="menu-model">effect-profile-menu</property>
<property name="menu-model">profile-menu</property>
</object>
</child>
<child>
@@ -66,10 +66,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="description" translatable="yes">Here you can specify under which circumstances the current effect settings should be applied.</property>
<child>
<object class="AdwEntryRow">
<object class="AdwEntryRow" id="profile-app">
<property name="title" translatable="yes">Choose an Application</property>
<child>
<object class="GtkButton" id="reset-doom-animation-time">
<object class="GtkButton" id="profile-choose-app-button">
<property name="icon-name">bmw-select-app-symbolic</property>
<property name="valign">center</property>
</object>
@@ -78,14 +78,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<object class="AdwComboRow">
<object class="AdwComboRow" id="profile-animation-type">
<property name="title" translatable="yes">Animation Type</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Any</item>
<item>Open Windows</item>
<item>Close Windows</item>
<item translatable="yes">Any</item>
<item translatable="yes">Open Windows</item>
<item translatable="yes">Close Windows</item>
</items>
</object>
</property>
@@ -93,14 +93,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<object class="AdwComboRow">
<object class="AdwComboRow" id="profile-window-type">
<property name="title" translatable="yes">Window Type</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Any</item>
<item>Normal Windows</item>
<item>Dialogs</item>
<item translatable="yes">Any</item>
<item translatable="yes">Normal Windows</item>
<item translatable="yes">Dialogs</item>
</items>
</object>
</property>
@@ -108,14 +108,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<object class="AdwComboRow">
<object class="AdwComboRow" id="profile-desktop-style">
<property name="title" translatable="yes">Desktop Style</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Any</item>
<item>Default Mode</item>
<item>Dark Mode</item>
<item translatable="yes">Any</item>
<item translatable="yes">Default Mode</item>
<item translatable="yes">Dark Mode</item>
</items>
</object>
</property>
@@ -123,14 +123,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<object class="AdwComboRow">
<object class="AdwComboRow" id="profile-power-mode">
<property name="title" translatable="yes">Power Mode</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Any</item>
<item>On Battery</item>
<item>Plugged In</item>
<item translatable="yes">Any</item>
<item translatable="yes">On Battery</item>
<item translatable="yes">Plugged In</item>
</items>
</object>
</property>
@@ -138,17 +138,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child>
<child>
<object class="AdwComboRow">
<object class="AdwComboRow" id="profile-power-profile">
<property name="title" translatable="yes">Power Profile</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Any</item>
<item>Power-Saver Mode</item>
<item>Balanced Mode</item>
<item>Performance Mode</item>
<item>Power Saver or Balanced</item>
<item>Balanced or Performance</item>
<item translatable="yes">Any</item>
<item translatable="yes">Power-Saver Mode</item>
<item translatable="yes">Balanced Mode</item>
<item translatable="yes">Performance Mode</item>
<item translatable="yes">Power Saver or Balanced</item>
<item translatable="yes">Balanced or Performance</item>
</items>
</object>
</property>
@@ -6,6 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
-->
<interface domain="burn-my-windows">
<menu id="main-menu">
<section>
<item>
@@ -50,18 +51,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
</section>
</menu>
<menu id="effect-profile-menu">
<menu id="profile-menu">
<section>
<item>
<attribute name="label" translatable="yes">Default Profile</attribute>
<attribute name="action">profile.default</attribute>
<attribute name="action">prefs.profile-default</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Add New...</attribute>
<attribute name="action">profile.new</attribute>
<attribute name="action">prefs.profile-new</attribute>
</item>
</section>
</menu>
</interface>
@@ -13,24 +13,6 @@ SPDX-License-Identifier: CC0-1.0
<!-- General Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="destroy-dialogs" type="b">
<default>false</default>
<summary>Destroy Dialogs</summary>
<description>Set to true to burn dialogs as well.</description>
</key>
<key name="disable-on-battery" type="b">
<default>false</default>
<summary>Disable on Battery</summary>
<description>Enable effects only if plugged in.</description>
</key>
<key name="disable-on-power-save" type="b">
<default>false</default>
<summary>Disable on Power Save</summary>
<description>Enable effects only if power saver is disabled.</description>
</key>
<key name="preview-effect" type="s">
<default>""</default>
<summary>Preview Effect</summary>
@@ -43,6 +25,45 @@ SPDX-License-Identifier: CC0-1.0
<description>If set to true, all animations will show only one still frame to allow for continuous integration tests.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Profile Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="profile-animation-type" type="i">
<default>0</default>
<range min="0" max="2" />
<summary>Profile Animation Type</summary>
<description>The animation types for which the current effect settings should be used.</description>
</key>
<key name="profile-window-type" type="i">
<default>0</default>
<range min="0" max="2" />
<summary>Profile Window Type</summary>
<description>The window types for which the current effect settings should be used.</description>
</key>
<key name="profile-desktop-style" type="i">
<default>0</default>
<range min="0" max="2" />
<summary>Profile Desktop Style</summary>
<description>The desktop styles for which the current effect settings should be used.</description>
</key>
<key name="profile-power-mode" type="i">
<default>0</default>
<range min="0" max="2" />
<summary>Profile Power Mode</summary>
<description>The power mode for which the current effect settings should be used.</description>
</key>
<key name="profile-power-profile" type="i">
<default>0</default>
<range min="0" max="5" />
<summary>Profile Power Profile</summary>
<description>The power profiles in which the current effect settings should be used.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Apparition Effect Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->