diff --git a/extension.js b/extension.js index 41dfe4b..b604384 100644 --- a/extension.js +++ b/extension.js @@ -378,28 +378,21 @@ class Extension { return; } - // We do nothing if a dialog got closed and we should not burn them. - const shouldDestroyDialogs = this._settings.get_boolean('destroy-dialogs'); - - // If an effect is to be previewed, we have to affect dialogs es well. This is - // because the preview window is a dialog window... const previewNick = this._settings.get_string('preview-effect'); - if (isDialogWindow && !shouldDestroyDialogs && previewNick == '') { - this._fixAnimationTimes(isDialogWindow, forOpening, null); - return; - } - + // TODO!. // We may have to do nothing if running on battery power or if in power-save mode. - let disableOnBattery = - this._settings.get_boolean('disable-on-battery') && this._upowerProxy.OnBattery; - let disableOnPowerSave = this._settings.get_boolean('disable-on-power-save') && - this._powerProfilesProxy && this._powerProfilesProxy.ActiveProfile == 'power-saver'; + // let disableOnBattery = + // this._settings.get_boolean('disable-on-battery') && this._upowerProxy.OnBattery; + // let disableOnPowerSave = this._settings.get_boolean('disable-on-power-save') && + // this._powerProfilesProxy && this._powerProfilesProxy.ActiveProfile == + // 'power-saver'; + + // if (!skip! && previewNick == '') { + // this._fixAnimationTimes(isDialogWindow, forOpening, null); + // return; + // } - if ((disableOnBattery || disableOnPowerSave) && previewNick == '') { - this._fixAnimationTimes(isDialogWindow, forOpening, null); - return; - } // There is the weird case where an animation is already ongoing. This happens when a // window is closed which has been created before the session was started (e.g. when diff --git a/prefs.js b/prefs.js index a00e998..af2f693 100644 --- a/prefs.js +++ b/prefs.js @@ -96,6 +96,13 @@ var PreferencesDialog = class PreferencesDialog { // Store a reference to the settings object. this._settings = ExtensionUtils.getSettings(); + let profiles = utils.listProfiles(); + if (profiles.length == 0) { + profiles = [utils.createProfile()]; + } + + this._profileSettings = utils.getProfileSettings(profiles[0]); + // Load the general user interface files. this._builder = new Gtk.Builder(); this._builder.add_from_resource(`/ui/common/menus.ui`); @@ -115,7 +122,7 @@ var PreferencesDialog = class PreferencesDialog { // Maybe the service is masked... } - this._builder.get_object('disable-on-power-save-row').set_visible(hasPowerProfiles); + this._builder.get_object('profile-power-profile').set_visible(hasPowerProfiles); // Starting with GNOME Shell 42, the settings dialog uses libadwaita (at least most of // the time - it seems that pop!_OS does not support libadwaita even on GNOME 42). We @@ -386,11 +393,55 @@ var PreferencesDialog = class PreferencesDialog { // 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'); + const updateProfileName = () => { + let items = []; + + const addItems = (settingsKey, options) => { + const option = this._profileSettings.get_int(settingsKey); + if (option > 0) { + items.push(options[option - 1]); + } + }; + + // clang-format off + addItems('profile-animation-type', [_('Opening Windows'), + _('Closing Windows')]); + addItems('profile-window-type', [_('Normal Windows'), + _('Dialog Windows')]); + addItems('profile-desktop-style', [_('Bright Mode'), + _('Dark Mode')]); + addItems('profile-power-mode', [_('On Battery'), + _('Plugged In')]); + addItems('profile-power-profile', [_('Power-Saver Mode'), + _('Balanced Mode'), + _('Performance Mode'), + _('Power Saver or Balanced'), + _('Balanced or Performance')]); + // clang-format on + + let label = ''; + + if (items.length == 0) { + label = _('Default Profile'); + } else { + label = items.join(' ยท '); + } + + this._builder.get_object('choose-profile-button').label = label; + }; + + const setupProfileOption = (settingsKey) => { + this.bindComboRow(settingsKey); + this._profileSettings.connect('changed::' + settingsKey, updateProfileName); + }; + + setupProfileOption('profile-animation-type'); + setupProfileOption('profile-window-type'); + setupProfileOption('profile-desktop-style'); + setupProfileOption('profile-power-mode'); + setupProfileOption('profile-power-profile'); + + updateProfileName(); } // Populate the enabled-effects drop-down menu. @@ -399,7 +450,7 @@ var PreferencesDialog = class PreferencesDialog { const [minMajor, minMinor] = effect.getMinShellVersion(); if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { const actionName = effect.getNick() + '-enable-effect'; - const action = this._settings.create_action(actionName); + const action = this._profileSettings.create_action(actionName); group.add_action(action); // The menu only exists if not using libadwaita. With libadwaita, individual @@ -435,9 +486,9 @@ var PreferencesDialog = class PreferencesDialog { return this._builder; } - // Returns a Gio.Settings object for this extension. - getSettings() { - return this._settings; + // Returns a Gio.Settings object for the current effect profile. + getProfileSettings() { + return this._profileSettings; } // Returns the widget used for the settings of this extension. @@ -474,17 +525,17 @@ var PreferencesDialog = class PreferencesDialog { // Update the settings when the color is modified. button.connect('color-set', () => { - this._settings.set_string(settingsKey, button.get_rgba().to_string()); + this._profileSettings.set_string(settingsKey, button.get_rgba().to_string()); }); // Update the button state when the settings change. const settingSignalHandler = () => { const rgba = new Gdk.RGBA(); - rgba.parse(this._settings.get_string(settingsKey)); + rgba.parse(this._profileSettings.get_string(settingsKey)); button.rgba = rgba; }; - this._settings.connect('changed::' + settingsKey, settingSignalHandler); + this._profileSettings.connect('changed::' + settingsKey, settingSignalHandler); // Initialize the button with the state in the settings. settingSignalHandler(); @@ -512,7 +563,7 @@ var PreferencesDialog = class PreferencesDialog { const resetButton = this._builder.get_object('reset-' + settingsKey); if (resetButton) { resetButton.connect('clicked', () => { - this._settings.reset(settingsKey); + this._profileSettings.reset(settingsKey); }); } } @@ -523,7 +574,8 @@ var PreferencesDialog = class PreferencesDialog { const object = this._builder.get_object(settingsKey); if (object) { - this._settings.bind(settingsKey, object, property, Gio.SettingsBindFlags.DEFAULT); + this._profileSettings.bind(settingsKey, object, property, + Gio.SettingsBindFlags.DEFAULT); } this._bindResetButton(settingsKey); @@ -552,7 +604,7 @@ var PreferencesDialog = class PreferencesDialog { _previewEffect(effect) { // Set the to-be-previewed effect. - this.getSettings().set_string('preview-effect', effect.getNick()); + this._settings.set_string('preview-effect', effect.getNick()); // Make sure that the window.show() firther below "sees" this change. Gio.Settings.sync(); diff --git a/resources/ui/adw/prefs.ui b/resources/ui/adw/prefs.ui index 98da513..91cb354 100644 --- a/resources/ui/adw/prefs.ui +++ b/resources/ui/adw/prefs.ui @@ -11,8 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later center - - Default Profile + profile-menu @@ -26,12 +25,6 @@ SPDX-License-Identifier: GPL-3.0-or-later - - - user-trash-symbolic - center - - @@ -57,7 +50,7 @@ SPDX-License-Identifier: GPL-3.0-or-later 20 20 20 - 20 + 20 20 @@ -84,8 +77,8 @@ SPDX-License-Identifier: GPL-3.0-or-later Any - Open Windows - Close Windows + Opening Windows + Closing Windows @@ -100,7 +93,7 @@ SPDX-License-Identifier: GPL-3.0-or-later Any Normal Windows - Dialogs + Dialog Windows @@ -114,7 +107,7 @@ SPDX-License-Identifier: GPL-3.0-or-later Any - Default Mode + Bright Mode Dark Mode @@ -158,6 +151,14 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + user-trash-symbolic + Delete this Profile... + start + + + @@ -181,14 +182,13 @@ SPDX-License-Identifier: GPL-3.0-or-later + center - - edit-paste-symbolic diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml new file mode 100644 index 0000000..a8d86cf --- /dev/null +++ b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml @@ -0,0 +1,738 @@ + + + + + + + + + + + + + + 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. + + + + + + + + false + Apparition Enable Effect + Use the apparition effect. + + + + 300 + Apparition Animation Time + The time the apparition effect takes. + + + + 0.5 + Apparition Randomness + The amount of randomness of the apparition effect. + + + + 5.0 + Apparition Twirl Intensity + The amount of twirling of the apparition effect. + + + + 3.0 + Apparition Shake Intensity + The amount of shaking of the apparition effect. + + + + 0.75 + Apparition Suction Intensity + The amount of suction of the apparition effect. + + + + + + + + + false + Pixelate Enable Effect + Use the Pixelate effect. + + + + 500 + Pixelate Animation Time + The time the Pixelate effect takes. + + + + 40 + Pixelate Noise + The noise of the effect. + + + + 10 + Pixelate Pixel Size + The size of the maximum pixelation. + + + + + + + + + false + Pixel Wipe Enable Effect + Use the Pixel Wipe effect. + + + + 1000 + Pixel Wipe Animation Time + The time the Pixel Wipe effect takes. + + + + 10 + Pixel Wipe Pixel Size + The size of the maximum pixelation. + + + + + + + + false + Pixel Wheel Enable Effect + Use the Pixel Wheel effect. + + + + 300 + Pixel Wheel Animation Time + The time the Pixel Wheel effect takes. + + + + 12 + Pixel Wheel Spoke Count + The number of sections in the wheel. + + + + 10 + Pixel Wheel Pixel Size + The size of the maximum pixelation. + + + + + + + + false + Doom Enable Effect + Use the Doom effect. + + + + 1000 + Doom Animation Time + The time the Doom effect takes. + + + + 10.0 + Doom Horizontal Scale + The X scale of the effect. + + + + 10.0 + Doom Vertical Scale + The Y scale of the effect. + + + + 10 + Doom Pixel Size + The size of the maximum pixelation. + + + + + + + + true + Fire Enable Effect + Use the fire effect. + + + + 1500 + Fire Animation Time + The time the fire effect takes. + + + + 0.5 + Fire Movement Speed + The speed at which the fire moves. + + + + 1.0 + Fire Scale + The size of the fire. + + + + false + Fire 3D Noise + Use a 3D noise for the fire. + + + + "rgba(76, 51, 25, 0.0)" + Fire Color 1 + The first color of the fire gradient. + + + + "rgba(180, 55, 30, 0.7)" + Fire Color 2 + The second color of the fire gradient. + + + + "rgba(255, 76, 38, 0.9)" + Fire Color 3 + The third color of the fire gradient. + + + + "rgba(255, 166, 25, 1)" + Fire Color 4 + The fourth color of the fire gradient. + + + + "rgba(255, 255, 255, 1)" + Fire Color 5 + The fifth color of the fire gradient. + + + + + + + + false + Glide Enable Effect + Use the glide effect. + + + + 250 + Glide Animation Time + The time the glide effect takes. + + + + 0.95 + Glide Scale + The scale of the window. + + + + 0.15 + Glide Squish + The amount of squishing. + + + + -0.3 + Glide Tilt + The amount of tilting. + + + + -0.05 + Glide Shift + The amount of shifting. + + + + + + + + false + Matrix Enable Effect + Use the matrix effect. + + + + 1500 + Matrix Animation Time + The time the matrix effect takes. + + + + 20 + Matrix Scale + The size of the matrix letters. + + + + 1.0 + Matrix Randomness + The randomness of the matrix effect. + + + + "rgb(255, 255, 255)" + Matrix Tip Color + The color of the matrix trail tips. + + + + "rgb(25, 255, 89)" + Matrix Trail Color + The color matrix trails. + + + + 0.25 + Matrix Overshoot + The vertical overshooting of the matrix effect. + + + + + + + + false + TV Enable Effect + Use the tv effect. + + + + 400 + TV Animation Time + The time the tv effect takes. + + + + "rgb(255, 255, 255)" + TV Effect Color + The color of the TV effect. + + + + + + + + false + T-Rex Enable Effect + Use the trex effect. + + + + 1000 + T-Rex Animation Time + The time the trex effect takes. + + + + "rgb(170, 0, 0)" + Claw Scratch Color + The color of the claw scratches. + + + + 1.0 + Claw Scratch Scale + Size of the claw scratches. + + + + 0.15 + Claw Scratch Warp + Intensity of the claw scratch warp effect. + + + + 5 + Claw Scratch Count + Number of claw scratches drawn on top of each other. + + + + + + + + false + Hexagon Enable Effect + Use the Hexagon effect. + + + + 1500 + Hexagon Animation Time + The time the Hexagon effect takes. + + + + 3.0 + Hexagon Scale + The size of the effect. + + + + 2.0 + Hexagon Line Width + The width of the lines. + + + + "rgba(200, 255, 255, 0.5)" + Hexagon Line Color + The color of the lines. + + + + "rgba(20, 80, 255, 0.5)" + Hexagon Glow Color + The color of the glow effect. + + + + true + Hexagon Additive Blending + Use additive blending for the line and the glow. + + + + + + + + false + Incinerate Enable Effect + Use the Incinerate effect. + + + + 2000 + Incinerate Animation Time + The time the Incinerate effect takes. + + + + 1.0 + Incinerate Scale + The scale of the effect. + + + + 0.3 + Incinerate Turbulence + The turbulence of the effect. + + + + "rgb(255, 180, 127)" + Incinerate Color + The color of the effect. + + + + true + Incinerate Use Pointer + Use the pointer location for the incinerate effect. + + + + + + + + false + Energize A Enable Effect + Use the Energize A effect. + + + + 2000 + Energize A Animation Time + The time the Energize A effect takes. + + + + 1.0 + Energize A Scale + The size of the effect. + + + + "rgb(255, 200, 50)" + Energize A Color + The color of the effect. + + + + + + + + false + Energize B Enable Effect + Use the Energize B effect. + + + + 1000 + Energize B Animation Time + The time the Energize B effect takes. + + + + 1.0 + Energize B Scale + The size of the effect. + + + + "rgb(160, 180, 255)" + Energize B Color + The color of the effect. + + + + + + + + + false + Glitch Enable Effect + Use the Glitch effect. + + + + 750 + Glitch Animation Time + The time the Glitch effect takes. + + + + 1.0 + Glitch Scale + The size of the effect. + + + + 2.0 + Glitch Strength + The intensity of the effect. + + + + 2.0 + Glitch Speed + The speed of the effect. + + + + "rgb(100, 160, 255)" + Glitch Color + The color of the effect. + + + + + + + + false + Wisps Enable Effect + Use the wisps effect. + + + + 1500 + Wisps Animation Time + The time the wisps effect takes. + + + + 1.0 + Wisps Scale + The size of the wisps. + + + + "rgb(255, 100, 200)" + Wisps Effect Color + The color of the wisps effect. + + + + + + + + false + Broken Glass Enable Effect + Use the broken glass effect. + + + + 1000 + Broken Glass Animation Time + The time the broken glass effect takes. + + + + 1.0 + Broken Glass Scale + The size of the broken glass effect. + + + + -1.0 + Broken Glass Gravity + The gravity of the broken glass effect. + + + + 0.5 + Broken Glass Blow Force + The blow force of the broken glass effect. + + + + false + Broken Glass Use Pointer + Use the pointer location for the broken glass effect. + + + + + + + + false + Portal Enable Effect + Use the Portal effect. + + + + 1250 + Portal Animation Time + The time the Portal effect takes. + + + + "rgb(121, 233, 24)" + Portal Color + The color of the effect. + + + + 0.3 + Portal Rotation Speed + The angular speed of the portal. + + + + 1.0 + Portal Whirling + The amount of distortion. + + + + 15.0 + Portal Details + The amount of details in the portal. + + + + + + + + false + Snap Enable Effect + Use the snap effect. + + + + 1500 + Snap Animation Time + The time the snap effect takes. + + + + 3.0 + Snap Scale + The size of the snap effect. + + + + "rgb(50, 40, 35)" + Snap Effect Color + The color of the dust. + + + + + \ 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 4c03baa..c8a7593 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -13,6 +13,12 @@ SPDX-License-Identifier: CC0-1.0 + + "" + Active Profile + The currently active effect profile. + + "" Preview Effect @@ -25,730 +31,6 @@ 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. - - - - - - - - false - Apparition Enable Effect - Use the apparition effect. - - - - 300 - Apparition Animation Time - The time the apparition effect takes. - - - - 0.5 - Apparition Randomness - The amount of randomness of the apparition effect. - - - - 5.0 - Apparition Twirl Intensity - The amount of twirling of the apparition effect. - - - - 3.0 - Apparition Shake Intensity - The amount of shaking of the apparition effect. - - - - 0.75 - Apparition Suction Intensity - The amount of suction of the apparition effect. - - - - - - - - - false - Pixelate Enable Effect - Use the Pixelate effect. - - - - 500 - Pixelate Animation Time - The time the Pixelate effect takes. - - - - 40 - Pixelate Noise - The noise of the effect. - - - - 10 - Pixelate Pixel Size - The size of the maximum pixelation. - - - - - - - - - false - Pixel Wipe Enable Effect - Use the Pixel Wipe effect. - - - - 1000 - Pixel Wipe Animation Time - The time the Pixel Wipe effect takes. - - - - 10 - Pixel Wipe Pixel Size - The size of the maximum pixelation. - - - - - - - - false - Pixel Wheel Enable Effect - Use the Pixel Wheel effect. - - - - 300 - Pixel Wheel Animation Time - The time the Pixel Wheel effect takes. - - - - 12 - Pixel Wheel Spoke Count - The number of sections in the wheel. - - - - 10 - Pixel Wheel Pixel Size - The size of the maximum pixelation. - - - - - - - - false - Doom Enable Effect - Use the Doom effect. - - - - 1000 - Doom Animation Time - The time the Doom effect takes. - - - - 10.0 - Doom Horizontal Scale - The X scale of the effect. - - - - 10.0 - Doom Vertical Scale - The Y scale of the effect. - - - - 10 - Doom Pixel Size - The size of the maximum pixelation. - - - - - - - - true - Fire Enable Effect - Use the fire effect. - - - - 1500 - Fire Animation Time - The time the fire effect takes. - - - - 0.5 - Fire Movement Speed - The speed at which the fire moves. - - - - 1.0 - Fire Scale - The size of the fire. - - - - false - Fire 3D Noise - Use a 3D noise for the fire. - - - - "rgba(76, 51, 25, 0.0)" - Fire Color 1 - The first color of the fire gradient. - - - - "rgba(180, 55, 30, 0.7)" - Fire Color 2 - The second color of the fire gradient. - - - - "rgba(255, 76, 38, 0.9)" - Fire Color 3 - The third color of the fire gradient. - - - - "rgba(255, 166, 25, 1)" - Fire Color 4 - The fourth color of the fire gradient. - - - - "rgba(255, 255, 255, 1)" - Fire Color 5 - The fifth color of the fire gradient. - - - - - - - - false - Glide Enable Effect - Use the glide effect. - - - - 250 - Glide Animation Time - The time the glide effect takes. - - - - 0.95 - Glide Scale - The scale of the window. - - - - 0.15 - Glide Squish - The amount of squishing. - - - - -0.3 - Glide Tilt - The amount of tilting. - - - - -0.05 - Glide Shift - The amount of shifting. - - - - - - - - false - Matrix Enable Effect - Use the matrix effect. - - - - 1500 - Matrix Animation Time - The time the matrix effect takes. - - - - 20 - Matrix Scale - The size of the matrix letters. - - - - 1.0 - Matrix Randomness - The randomness of the matrix effect. - - - - "rgb(255, 255, 255)" - Matrix Tip Color - The color of the matrix trail tips. - - - - "rgb(25, 255, 89)" - Matrix Trail Color - The color matrix trails. - - - - 0.25 - Matrix Overshoot - The vertical overshooting of the matrix effect. - - - - - - - - false - TV Enable Effect - Use the tv effect. - - - - 400 - TV Animation Time - The time the tv effect takes. - - - - "rgb(255, 255, 255)" - TV Effect Color - The color of the TV effect. - - - - - - - - false - T-Rex Enable Effect - Use the trex effect. - - - - 1000 - T-Rex Animation Time - The time the trex effect takes. - - - - "rgb(170, 0, 0)" - Claw Scratch Color - The color of the claw scratches. - - - - 1.0 - Claw Scratch Scale - Size of the claw scratches. - - - - 0.15 - Claw Scratch Warp - Intensity of the claw scratch warp effect. - - - - 5 - Claw Scratch Count - Number of claw scratches drawn on top of each other. - - - - - - - - false - Hexagon Enable Effect - Use the Hexagon effect. - - - - 1500 - Hexagon Animation Time - The time the Hexagon effect takes. - - - - 3.0 - Hexagon Scale - The size of the effect. - - - - 2.0 - Hexagon Line Width - The width of the lines. - - - - "rgba(200, 255, 255, 0.5)" - Hexagon Line Color - The color of the lines. - - - - "rgba(20, 80, 255, 0.5)" - Hexagon Glow Color - The color of the glow effect. - - - - true - Hexagon Additive Blending - Use additive blending for the line and the glow. - - - - - - - - false - Incinerate Enable Effect - Use the Incinerate effect. - - - - 2000 - Incinerate Animation Time - The time the Incinerate effect takes. - - - - 1.0 - Incinerate Scale - The scale of the effect. - - - - 0.3 - Incinerate Turbulence - The turbulence of the effect. - - - - "rgb(255, 180, 127)" - Incinerate Color - The color of the effect. - - - - true - Incinerate Use Pointer - Use the pointer location for the incinerate effect. - - - - - - - - false - Energize A Enable Effect - Use the Energize A effect. - - - - 2000 - Energize A Animation Time - The time the Energize A effect takes. - - - - 1.0 - Energize A Scale - The size of the effect. - - - - "rgb(255, 200, 50)" - Energize A Color - The color of the effect. - - - - - - - - false - Energize B Enable Effect - Use the Energize B effect. - - - - 1000 - Energize B Animation Time - The time the Energize B effect takes. - - - - 1.0 - Energize B Scale - The size of the effect. - - - - "rgb(160, 180, 255)" - Energize B Color - The color of the effect. - - - - - - - - - false - Glitch Enable Effect - Use the Glitch effect. - - - - 750 - Glitch Animation Time - The time the Glitch effect takes. - - - - 1.0 - Glitch Scale - The size of the effect. - - - - 2.0 - Glitch Strength - The intensity of the effect. - - - - 2.0 - Glitch Speed - The speed of the effect. - - - - "rgb(100, 160, 255)" - Glitch Color - The color of the effect. - - - - - - - - false - Wisps Enable Effect - Use the wisps effect. - - - - 1500 - Wisps Animation Time - The time the wisps effect takes. - - - - 1.0 - Wisps Scale - The size of the wisps. - - - - "rgb(255, 100, 200)" - Wisps Effect Color - The color of the wisps effect. - - - - - - - - false - Broken Glass Enable Effect - Use the broken glass effect. - - - - 1000 - Broken Glass Animation Time - The time the broken glass effect takes. - - - - 1.0 - Broken Glass Scale - The size of the broken glass effect. - - - - -1.0 - Broken Glass Gravity - The gravity of the broken glass effect. - - - - 0.5 - Broken Glass Blow Force - The blow force of the broken glass effect. - - - - false - Broken Glass Use Pointer - Use the pointer location for the broken glass effect. - - - - - - - - false - Portal Enable Effect - Use the Portal effect. - - - - 1250 - Portal Animation Time - The time the Portal effect takes. - - - - "rgb(121, 233, 24)" - Portal Color - The color of the effect. - - - - 0.3 - Portal Rotation Speed - The angular speed of the portal. - - - - 1.0 - Portal Whirling - The amount of distortion. - - - - 15.0 - Portal Details - The amount of details in the portal. - - - - - - - - false - Snap Enable Effect - Use the snap effect. - - - - 1500 - Snap Animation Time - The time the snap effect takes. - - - - 3.0 - Snap Scale - The size of the snap effect. - - - - "rgb(50, 40, 35)" - Snap Effect Color - The color of the dust. - - \ No newline at end of file diff --git a/src/Fire.js b/src/Fire.js index 8a2366e..523189c 100644 --- a/src/Fire.js +++ b/src/Fire.js @@ -122,11 +122,11 @@ var Fire = class { // The fire-gradient-reset button needs to be bound explicitly. dialog.getBuilder().get_object('reset-fire-colors').connect('clicked', () => { - dialog.getSettings().reset('fire-color-1'); - dialog.getSettings().reset('fire-color-2'); - dialog.getSettings().reset('fire-color-3'); - dialog.getSettings().reset('fire-color-4'); - dialog.getSettings().reset('fire-color-5'); + dialog.getProfileSettings().reset('fire-color-1'); + dialog.getProfileSettings().reset('fire-color-2'); + dialog.getProfileSettings().reset('fire-color-3'); + dialog.getProfileSettings().reset('fire-color-4'); + dialog.getProfileSettings().reset('fire-color-5'); }); // Initialize the fire-preset dropdown. @@ -215,13 +215,13 @@ var Fire = class { // Load the preset on activation. action.connect('activate', () => { - dialog.getSettings().set_double('flame-movement-speed', preset.speed); - dialog.getSettings().set_double('flame-scale', preset.scale); - dialog.getSettings().set_string('fire-color-1', preset.color1); - dialog.getSettings().set_string('fire-color-2', preset.color2); - dialog.getSettings().set_string('fire-color-3', preset.color3); - dialog.getSettings().set_string('fire-color-4', preset.color4); - dialog.getSettings().set_string('fire-color-5', preset.color5); + dialog.getProfileSettings().set_double('flame-movement-speed', preset.speed); + dialog.getProfileSettings().set_double('flame-scale', preset.scale); + dialog.getProfileSettings().set_string('fire-color-1', preset.color1); + dialog.getProfileSettings().set_string('fire-color-2', preset.color2); + dialog.getProfileSettings().set_string('fire-color-3', preset.color3); + dialog.getProfileSettings().set_string('fire-color-4', preset.color4); + dialog.getProfileSettings().set_string('fire-color-5', preset.color5); }); group.add_action(action); diff --git a/src/utils.js b/src/utils.js index 8e5024f..13eddc9 100644 --- a/src/utils.js +++ b/src/utils.js @@ -14,8 +14,8 @@ 'use strict'; -const {Gtk, Gio} = imports.gi; -const ByteArray = imports.byteArray; +const {Gtk, Gio, GLib} = imports.gi; +const ByteArray = imports.byteArray; // libadwaita is available starting with GNOME Shell 42. let Adw = null; @@ -107,4 +107,75 @@ function shellVersionIsAtLeast(major, minor) { function getStringResource(path) { const data = Gio.resources_lookup_data(path, 0); return ByteArray.toString(ByteArray.fromGBytes(data)); +} + +function createProfile() { + const path = + GLib.get_user_config_dir() + `/burn-my-windows/profiles/${GLib.get_real_time()}.conf`; + const file = Gio.File.new_for_path(path); + + if (!file.get_parent().query_exists(null)) { + file.get_parent().make_directory_with_parents(null); + } + + file.create(Gio.FileCreateFlags.NONE, null); + + return path; +} + + +function listProfiles() { + + const profileDir = + Gio.File.new_for_path(GLib.get_user_config_dir() + '/burn-my-windows/profiles'); + + if (!profileDir.query_exists(null)) { + return []; + } + + const files = + profileDir.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NONE, null); + + let profiles = []; + + while (true) { + const presetInfo = files.next_file(null); + + if (presetInfo == null) { + break; + } + + if (presetInfo.get_file_type() == Gio.FileType.REGULAR) { + const suffixPos = presetInfo.get_display_name().indexOf('.conf'); + if (suffixPos > 0) { + profiles.push(profileDir.get_child(presetInfo.get_name()).get_path()); + } + } + } + + return profiles; +} + +// Based on +// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/misc/extensionUtils.js#L213 +function getProfileSettings(profilePath) { + + // Expect USER extensions to have a schemas/ subfolder, otherwise assume a + // SYSTEM extension that has been installed in the same prefix as the shell + const schemaDir = Me.dir.get_child('schemas'); + let source; + if (schemaDir.query_exists(null)) { + source = Gio.SettingsSchemaSource.new_from_directory( + schemaDir.get_path(), Gio.SettingsSchemaSource.get_default(), false); + } else { + source = Gio.SettingsSchemaSource.get_default(); + } + + const schema = + source.lookup('org.gnome.shell.extensions.burn-my-windows-profile', true); + + const backend = + Gio.keyfile_settings_backend_new(profilePath, '/org/gnome/shell/extensions/', null); + + return new Gio.Settings({settings_schema: schema, backend: backend}); } \ No newline at end of file