From a5f7769e58abe7d899322f0af521ca95dddd4de1 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 22 Jan 2022 20:24:38 +0100 Subject: [PATCH 1/9] :recycle: Refactor how preferences pages are set up --- docs/how-to-create-new-effects.md | 18 ++++++++---------- prefs.js | 6 +++++- src/BrokenGlass.js | 9 +++------ src/EnergizeA.js | 9 +++------ src/EnergizeB.js | 9 +++------ src/Fire.js | 8 +++----- src/Matrix.js | 9 +++------ src/TRexAttack.js | 9 +++------ src/TVEffect.js | 9 +++------ src/Wisps.js | 8 +++----- 10 files changed, 37 insertions(+), 57 deletions(-) diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md index a2a1f30..ede378a 100644 --- a/docs/how-to-create-new-effects.md +++ b/docs/how-to-create-new-effects.md @@ -138,8 +138,9 @@ var SimpleFade = class SimpleFade { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Empty for now... Code is added here later in the tutorial! + return null; } // ---------------------------------------------------------------- API for extension.js @@ -248,7 +249,7 @@ There should be two sliders in this example: The animation duration and the widt If your effect supports GNOME Shell 3.3x _and_ GNOME Shell 40+, you will have to provide two `*.ui` files for this. This is because starting with GNOME Shell 40, the preference dialog uses GTK4, before it used to use GTK3. Usually, there are only a few minor differences between the two files. -We will load the respective file in the `initPreferences()` method of your new effect class. +We will load the respective file in the `getPreferences()` method of your new effect class. Just save the code below to `resources/ui/gtk3/SimpleFade.ui` and `resources/ui/gtk4/SimpleFade.ui` respectively. Remember to replace any occurrence of `simple-fade` with your effect's nick-name! @@ -528,10 +529,10 @@ Remember to replace any occurrence of `simple-fade` with your effect's nick-name ### Loading the Preferences Page -In order to load the above `*.ui` files, add the following code to your effect's `initPreferences()` method. +In order to load the above `*.ui` files, add the following code to your effect's `getPreferences()` method. ```javascript -static initPreferences(dialog) { +static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/SimpleFade.ui`); @@ -541,12 +542,9 @@ static initPreferences(dialog) { dialog.bindAdjustment('simple-fade-animation-time'); dialog.bindAdjustment('simple-fade-width'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object(SimpleFade.getNick() + '-prefs'), - SimpleFade.getNick(), SimpleFade.getLabel()); - } + // Finally, return the new settings page. + return dialog.getBuilder().get_object('simple-fade-prefs'); +} ``` Once this is in place, you can kill the extension-preferences process and re-open the settings. diff --git a/prefs.js b/prefs.js index 19f5dda..02108a2 100644 --- a/prefs.js +++ b/prefs.js @@ -65,10 +65,14 @@ var PreferencesDialog = class PreferencesDialog { this.bindSwitch('destroy-dialogs'); // Add all other effect pages. + const stack = this._builder.get_object('main-stack'); ALL_EFFECTS.forEach(Effect => { const [minMajor, minMinor] = Effect.getMinShellVersion(); if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { - Effect.initPreferences(this); + const page = Effect.getPreferences(this); + if (page) { + stack.add_titled(page, Effect.getNick(), Effect.getLabel()); + } } }); diff --git a/src/BrokenGlass.js b/src/BrokenGlass.js index 48b6c22..aa77df0 100644 --- a/src/BrokenGlass.js +++ b/src/BrokenGlass.js @@ -60,7 +60,7 @@ var BrokenGlass = class BrokenGlass { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource('/ui/gtk4/BrokenGlass.ui'); @@ -72,11 +72,8 @@ var BrokenGlass = class BrokenGlass { dialog.bindAdjustment('broken-glass-blow-force'); dialog.bindSwitch('broken-glass-use-pointer'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('broken-glass-prefs'), BrokenGlass.getNick(), - BrokenGlass.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('broken-glass-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/EnergizeA.js b/src/EnergizeA.js index c1c0913..cbceeb7 100644 --- a/src/EnergizeA.js +++ b/src/EnergizeA.js @@ -57,7 +57,7 @@ var EnergizeA = class EnergizeA { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/EnergizeA.ui`); @@ -67,11 +67,8 @@ var EnergizeA = class EnergizeA { dialog.bindAdjustment('energize-a-scale'); dialog.bindColorButton('energize-a-color'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('energize-a-prefs'), EnergizeA.getNick(), - EnergizeA.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('energize-a-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/EnergizeB.js b/src/EnergizeB.js index afb6365..4592679 100644 --- a/src/EnergizeB.js +++ b/src/EnergizeB.js @@ -57,7 +57,7 @@ var EnergizeB = class EnergizeB { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/EnergizeB.ui`); @@ -67,11 +67,8 @@ var EnergizeB = class EnergizeB { dialog.bindAdjustment('energize-b-scale'); dialog.bindColorButton('energize-b-color'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('energize-b-prefs'), EnergizeB.getNick(), - EnergizeB.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('energize-b-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/Fire.js b/src/Fire.js index 2cf1b44..a04310c 100644 --- a/src/Fire.js +++ b/src/Fire.js @@ -61,7 +61,7 @@ var Fire = class Fire { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/Fire.ui`); @@ -89,10 +89,8 @@ var Fire = class Fire { // Initialize the fire-preset dropdown. Fire._createFirePresets(dialog); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('fire-prefs'), Fire.getNick(), Fire.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('fire-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/Matrix.js b/src/Matrix.js index 9ae7dad..df2bd46 100644 --- a/src/Matrix.js +++ b/src/Matrix.js @@ -61,7 +61,7 @@ var Matrix = class Matrix { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource('/ui/gtk4/Matrix.ui'); @@ -73,11 +73,8 @@ var Matrix = class Matrix { dialog.bindColorButton('matrix-trail-color'); dialog.bindColorButton('matrix-tip-color'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('matrix-prefs'), Matrix.getNick(), - Matrix.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('matrix-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/TRexAttack.js b/src/TRexAttack.js index 5c8a478..380c675 100644 --- a/src/TRexAttack.js +++ b/src/TRexAttack.js @@ -59,7 +59,7 @@ var TRexAttack = class TRexAttack { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource('/ui/gtk4/TRexAttack.ui'); @@ -71,11 +71,8 @@ var TRexAttack = class TRexAttack { dialog.bindAdjustment('claw-scratch-count'); dialog.bindAdjustment('claw-scratch-warp'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('trex-prefs'), TRexAttack.getNick(), - TRexAttack.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('trex-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/TVEffect.js b/src/TVEffect.js index 12bd8e9..b171caf 100644 --- a/src/TVEffect.js +++ b/src/TVEffect.js @@ -59,7 +59,7 @@ var TVEffect = class TVEffect { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/TVEffect.ui`); @@ -68,11 +68,8 @@ var TVEffect = class TVEffect { dialog.bindAdjustment('tv-animation-time'); dialog.bindColorButton('tv-effect-color'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('tv-prefs'), TVEffect.getNick(), - TVEffect.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('tv-prefs'); } // ---------------------------------------------------------------- API for extension.js diff --git a/src/Wisps.js b/src/Wisps.js index 87d6e2a..030339f 100644 --- a/src/Wisps.js +++ b/src/Wisps.js @@ -58,7 +58,7 @@ var Wisps = class Wisps { // This is called by the preferences dialog. It loads the settings page for this effect, // binds all properties to the settings and appends the page to the main stack of the // preferences dialog. - static initPreferences(dialog) { + static getPreferences(dialog) { // Add the settings page to the builder. dialog.getBuilder().add_from_resource(`/ui/${utils.getGTKString()}/Wisps.ui`); @@ -68,10 +68,8 @@ var Wisps = class Wisps { dialog.bindAdjustment('wisps-scale'); dialog.bindColorButton('wisps-color'); - // Finally, append the settings page to the main stack. - const stack = dialog.getBuilder().get_object('main-stack'); - stack.add_titled( - dialog.getBuilder().get_object('wisps-prefs'), Wisps.getNick(), Wisps.getLabel()); + // Finally, return the new settings page. + return dialog.getBuilder().get_object('wisps-prefs'); } // ---------------------------------------------------------------- API for extension.js From fd5871b924291221018befb2004c402c12805cb1 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 23 Jan 2022 06:33:39 +0100 Subject: [PATCH 2/9] :lipstick: Add new menu entry --- docs/changelog.md | 4 ++++ prefs.js | 1 + resources/ui/common/main-menu.ui | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 5224d8e..2bf23c6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -8,6 +8,10 @@ * **New Effect: Broken Glass.** Shatter your windows into a shower sharp shards! This effect can be configured so that the shards fly away from your mouse pointer position! +#### Other Enhancements + +* Added a menu entry with a link to the guide for creating new effect types. + ## [Burn My Window 9](https://github.com/schneegans/Burn-My-Windows/releases/tag/v9) **Release Date:** 2022-01-18 diff --git a/prefs.js b/prefs.js index 02108a2..0a25473 100644 --- a/prefs.js +++ b/prefs.js @@ -107,6 +107,7 @@ var PreferencesDialog = class PreferencesDialog { addAction('homepage', 'https://github.com/Schneegans/Burn-My-Windows'); addAction('changelog', 'https://github.com/Schneegans/Burn-My-Windows/blob/main/docs/changelog.md'); addAction('bugs', 'https://github.com/Schneegans/Burn-My-Windows/issues'); + addAction('new-effect', 'https://github.com/Schneegans/Burn-My-Windows/blob/main/docs/how-to-create-new-effects.md'); addAction('donate-paypal', 'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE'); addAction('donate-github', 'https://github.com/sponsors/Schneegans'); // clang-format on diff --git a/resources/ui/common/main-menu.ui b/resources/ui/common/main-menu.ui index 4ba062b..0d8a0b8 100644 --- a/resources/ui/common/main-menu.ui +++ b/resources/ui/common/main-menu.ui @@ -10,12 +10,16 @@ View Changelog prefs.changelog + +
Report a Bug prefs.bugs -
-
+ + Create a Custom Effect + prefs.new-effect + Donate From b2f11f494d9d9608c35f3e1622a24558f679902a Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 23 Jan 2022 06:34:37 +0100 Subject: [PATCH 3/9] :wrench: Add custom gtk style sheet --- prefs.js | 13 +++++++++++++ resources/css/gtk.css | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 resources/css/gtk.css diff --git a/prefs.js b/prefs.js index 0a25473..c8a3c7a 100644 --- a/prefs.js +++ b/prefs.js @@ -46,6 +46,19 @@ var PreferencesDialog = class PreferencesDialog { this._resources = Gio.Resource.load(Me.path + '/resources/burn-my-windows.gresource'); Gio.resources_register(this._resources); + // Load the CSS file for the settings dialog. + const styleProvider = Gtk.CssProvider.new(); + styleProvider.load_from_resource('/css/gtk.css'); + if (utils.isGTK4()) { + Gtk.StyleContext.add_provider_for_display( + Gdk.Display.get_default(), styleProvider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } else { + Gtk.StyleContext.add_provider_for_screen( + Gdk.Screen.get_default(), styleProvider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + // Make sure custom icons are found. if (utils.isGTK4()) { Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_resource_path('/img'); diff --git a/resources/css/gtk.css b/resources/css/gtk.css new file mode 100644 index 0000000..3acf2ee --- /dev/null +++ b/resources/css/gtk.css @@ -0,0 +1,3 @@ +.pill-button { + border-radius: 9999px; +} \ No newline at end of file From 242625ee9faaae486ca2500e2d2f2c723b6a8e63 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 23 Jan 2022 06:44:28 +0100 Subject: [PATCH 4/9] :tada: Add a preview button to each effect page --- docs/how-to-create-new-effects.md | 8 --- prefs.js | 116 ++++++++++++++++++++++++++++-- resources/ui/gtk3/EnergizeA.ui | 4 -- resources/ui/gtk3/EnergizeB.ui | 4 -- resources/ui/gtk3/Fire.ui | 17 ----- resources/ui/gtk3/TVEffect.ui | 4 -- resources/ui/gtk3/Wisps.ui | 4 -- resources/ui/gtk3/effectPage.ui | 57 +++++++++++++++ resources/ui/gtk4/BrokenGlass.ui | 4 -- resources/ui/gtk4/EnergizeA.ui | 4 -- resources/ui/gtk4/EnergizeB.ui | 4 -- resources/ui/gtk4/Fire.ui | 18 ----- resources/ui/gtk4/Matrix.ui | 4 -- resources/ui/gtk4/TRexAttack.ui | 4 -- resources/ui/gtk4/TVEffect.ui | 4 -- resources/ui/gtk4/Wisps.ui | 4 -- resources/ui/gtk4/effectPage.ui | 57 +++++++++++++++ 17 files changed, 226 insertions(+), 91 deletions(-) create mode 100644 resources/ui/gtk3/effectPage.ui create mode 100644 resources/ui/gtk4/effectPage.ui diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md index ede378a..c1a14f5 100644 --- a/docs/how-to-create-new-effects.md +++ b/docs/how-to-create-new-effects.md @@ -277,10 +277,6 @@ Remember to replace any occurrence of `simple-fade` with your effect's nick-name vertical - 60 - 60 - 60 - 60 @@ -422,10 +418,6 @@ Remember to replace any occurrence of `simple-fade` with your effect's nick-name vertical - 60 - 60 - 60 - 60 diff --git a/prefs.js b/prefs.js index c8a3c7a..78d2b3a 100644 --- a/prefs.js +++ b/prefs.js @@ -13,7 +13,7 @@ 'use strict'; -const {Gio, Gtk, Gdk} = imports.gi; +const {Gio, Gtk, Gdk, GLib, GObject} = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; const Me = imports.misc.extensionUtils.getCurrentExtension(); @@ -31,6 +31,9 @@ const ALL_EFFECTS = [ Me.imports.src.Wisps.Wisps, ]; +// This template widget class is defined at the bottom of this file. +var BurnMyWindowsEffectPage = null; + ////////////////////////////////////////////////////////////////////////////////////////// // The preferences dialog is organized in pages, each of which is loaded from a // // separate ui file. There's one page with general options, all other paged are loaded // @@ -66,6 +69,9 @@ var PreferencesDialog = class PreferencesDialog { Gtk.IconTheme.get_default().add_resource_path('/img'); } + // Register the template widgets used in the settings dialog. + this._registerCustomClasses(); + // Store a reference to the settings object. this._settings = ExtensionUtils.getSettings(); @@ -82,10 +88,16 @@ var PreferencesDialog = class PreferencesDialog { ALL_EFFECTS.forEach(Effect => { const [minMajor, minMinor] = Effect.getMinShellVersion(); if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { - const page = Effect.getPreferences(this); - if (page) { - stack.add_titled(page, Effect.getNick(), Effect.getLabel()); + + const page = new BurnMyWindowsEffectPage(Effect, this); + + // Add the Effect's preferences (if any). + const preferences = Effect.getPreferences(this); + if (preferences) { + this.gtkBoxAppend(page, preferences); } + + stack.add_titled(page, Effect.getNick(), Effect.getLabel()); } }); @@ -228,6 +240,17 @@ var PreferencesDialog = class PreferencesDialog { this._bindResetButton(settingsKey); } + // ----------------------------------------------------------------- GTK3 / GTK4 helpers + + // Appends the given child widget to the given Gtk.Box. + gtkBoxAppend(box, child) { + if (utils.isGTK4()) { + box.append(child); + } else { + box.pack_start(child, false, false, 0); + } + } + // ----------------------------------------------------------------------- private stuff // Searches for a reset button for the given settings key and make it reset the settings @@ -252,6 +275,91 @@ var PreferencesDialog = class PreferencesDialog { this._bindResetButton(settingsKey); } + + // Initializes template widgets used by the preferences dialog. + _registerCustomClasses() { + + // Each effect page is based on a template widget. This template contains the title + // and the preview button. + // clang-format off + BurnMyWindowsEffectPage = + GObject.registerClass({ + GTypeName: 'BurnMyWindowsEffectPage', + Template: `resource:///ui/${utils.getGTKString()}/effectPage.ui`, + InternalChildren: ['label', 'button'], + }, + class BurnMyWindowsEffectPage extends Gtk.Box { + _init(Effect, dialog) { + super._init(); + + // Set the effect's name as label. + this._label.label = Effect.getLabel(); + + // Open the preview window once the preview button is clicked. + this._button.connect('clicked', () => { + // Create a list of all currently enabled effects. + const enabledEffects = ALL_EFFECTS.filter(Effect => { + return dialog.getSettings().get_boolean(`${Effect.getNick()}-close-effect`); + }); + + // Disable all enabled effects temporarily. + enabledEffects.forEach(Effect => { + dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, false); + }); + + // Enable the to-be-previewed effect. + dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, true); + + // Create the preview-window. + const window = new Gtk.Window({ + title: `Preview for ${Effect.getLabel()}`, + default_width: 800, + default_height: 450, + modal: true, + transient_for: utils.isGTK4() ? this._button.get_root() : + this._button.get_toplevel() + }); + + const box = new Gtk.Box({ + orientation: Gtk.Orientation.VERTICAL, + valign: Gtk.Align.CENTER, + spacing: 10, + }); + + const label = Gtk.Label.new('Close this Window to Preview the Effect!'); + label.get_style_context().add_class('large-title'); + + const image = new Gtk.Image({ + icon_name: 'burn-my-windows-symbolic', + pixel_size: 128, + }); + + dialog.gtkBoxAppend(box, image); + dialog.gtkBoxAppend(box, label); + + if (utils.isGTK4()) { + window.set_child(box); + } else { + window.add(box); + } + + window.show(); + + // Restore settings when the window gets closed. + window.connect('unrealize', () => { + // Disable the to-be-previewed effect again. + dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, false); + + // Enable all previously enabled effects again. + enabledEffects.forEach(Effect => { + dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, true); + }); + }); + }); + } + }); + // clang-format on + } } // Nothing to do for now... diff --git a/resources/ui/gtk3/EnergizeA.ui b/resources/ui/gtk3/EnergizeA.ui index b292863..79afebc 100644 --- a/resources/ui/gtk3/EnergizeA.ui +++ b/resources/ui/gtk3/EnergizeA.ui @@ -17,10 +17,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk3/EnergizeB.ui b/resources/ui/gtk3/EnergizeB.ui index 080d2b6..051821d 100644 --- a/resources/ui/gtk3/EnergizeB.ui +++ b/resources/ui/gtk3/EnergizeB.ui @@ -17,10 +17,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk3/Fire.ui b/resources/ui/gtk3/Fire.ui index 688285c..4b43025 100644 --- a/resources/ui/gtk3/Fire.ui +++ b/resources/ui/gtk3/Fire.ui @@ -24,10 +24,6 @@ vertical - 60 - 60 - 60 - 60 @@ -81,19 +77,6 @@ - - - - - - - - - - none - diff --git a/resources/ui/gtk3/TVEffect.ui b/resources/ui/gtk3/TVEffect.ui index b992120..adebe01 100644 --- a/resources/ui/gtk3/TVEffect.ui +++ b/resources/ui/gtk3/TVEffect.ui @@ -10,10 +10,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk3/Wisps.ui b/resources/ui/gtk3/Wisps.ui index c14f1ff..ff096ae 100644 --- a/resources/ui/gtk3/Wisps.ui +++ b/resources/ui/gtk3/Wisps.ui @@ -17,10 +17,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk3/effectPage.ui b/resources/ui/gtk3/effectPage.ui new file mode 100644 index 0000000..5022669 --- /dev/null +++ b/resources/ui/gtk3/effectPage.ui @@ -0,0 +1,57 @@ + + + + + + + \ No newline at end of file diff --git a/resources/ui/gtk4/BrokenGlass.ui b/resources/ui/gtk4/BrokenGlass.ui index 7b77ca2..55c30eb 100644 --- a/resources/ui/gtk4/BrokenGlass.ui +++ b/resources/ui/gtk4/BrokenGlass.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/EnergizeA.ui b/resources/ui/gtk4/EnergizeA.ui index 92911d9..5236da0 100644 --- a/resources/ui/gtk4/EnergizeA.ui +++ b/resources/ui/gtk4/EnergizeA.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/EnergizeB.ui b/resources/ui/gtk4/EnergizeB.ui index 77f1e4d..786afcb 100644 --- a/resources/ui/gtk4/EnergizeB.ui +++ b/resources/ui/gtk4/EnergizeB.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/Fire.ui b/resources/ui/gtk4/Fire.ui index 346b2ee..52c503a 100644 --- a/resources/ui/gtk4/Fire.ui +++ b/resources/ui/gtk4/Fire.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 @@ -42,20 +38,6 @@ - - - - - - - - - - none - 1 - diff --git a/resources/ui/gtk4/Matrix.ui b/resources/ui/gtk4/Matrix.ui index 7f5a570..c6c7720 100644 --- a/resources/ui/gtk4/Matrix.ui +++ b/resources/ui/gtk4/Matrix.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/TRexAttack.ui b/resources/ui/gtk4/TRexAttack.ui index 2bfe567..b77e7f6 100644 --- a/resources/ui/gtk4/TRexAttack.ui +++ b/resources/ui/gtk4/TRexAttack.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/TVEffect.ui b/resources/ui/gtk4/TVEffect.ui index c64ecef..f49f0bc 100644 --- a/resources/ui/gtk4/TVEffect.ui +++ b/resources/ui/gtk4/TVEffect.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/Wisps.ui b/resources/ui/gtk4/Wisps.ui index fc89c31..8e5bcb2 100644 --- a/resources/ui/gtk4/Wisps.ui +++ b/resources/ui/gtk4/Wisps.ui @@ -3,10 +3,6 @@ vertical - 60 - 60 - 60 - 60 diff --git a/resources/ui/gtk4/effectPage.ui b/resources/ui/gtk4/effectPage.ui new file mode 100644 index 0000000..5022669 --- /dev/null +++ b/resources/ui/gtk4/effectPage.ui @@ -0,0 +1,57 @@ + + + + + + + \ No newline at end of file From 8475ae29ba521148355a08faf34ad8e8f024959c Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 23 Jan 2022 13:13:55 +0100 Subject: [PATCH 5/9] :wrench: Use more robust preview logic --- extension.js | 37 ++++++++++++++----- prefs.js | 24 +----------- ...ell.extensions.burn-my-windows.gschema.xml | 6 +++ 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/extension.js b/extension.js index 128251d..4e28932 100644 --- a/extension.js +++ b/extension.js @@ -215,18 +215,37 @@ class Extension { return; } - // Create a list of all currently enabled effects. - const enabledEffects = ALL_EFFECTS.filter(Effect => { - return this._settings.get_boolean(`${Effect.getNick()}-close-effect`); - }); + // Now we have to choose an effect. + this._effect = null; - // Nothing is enabled... - if (enabledEffects.length == 0) { - return; + // First we check if an effect is to be previewd. + const previewNick = this._settings.get_string('close-preview-effect'); + if (previewNick != '') { + this._effect = ALL_EFFECTS.find(Effect => { + return Effect.getNick() == previewNick; + }); + + // Only preview the effect once. + this._settings.set_string('close-preview-effect', ''); + + } else { + + // Else we choose a random effect from all enabled effects. Therefore, we first + // create a list of all currently enabled effects. + const enabled = ALL_EFFECTS.filter(Effect => { + return this._settings.get_boolean(`${Effect.getNick()}-close-effect`); + }); + + // And then choose a random effect. + if (enabled.length > 0) { + this._effect = enabled[Math.floor(Math.random() * enabled.length)]; + } } - // Choose a random effect. - this._effect = enabledEffects[Math.floor(Math.random() * enabledEffects.length)]; + // If nothing was enabled, we have to do nothing :) + if (this._effect == null) { + return; + } // The effect usually will choose to override the present transitions on the actor. const transitionConfig = this._effect.getCloseTransition(actor, this._settings); diff --git a/prefs.js b/prefs.js index 78d2b3a..2182911 100644 --- a/prefs.js +++ b/prefs.js @@ -297,18 +297,9 @@ var PreferencesDialog = class PreferencesDialog { // Open the preview window once the preview button is clicked. this._button.connect('clicked', () => { - // Create a list of all currently enabled effects. - const enabledEffects = ALL_EFFECTS.filter(Effect => { - return dialog.getSettings().get_boolean(`${Effect.getNick()}-close-effect`); - }); - // Disable all enabled effects temporarily. - enabledEffects.forEach(Effect => { - dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, false); - }); - - // Enable the to-be-previewed effect. - dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, true); + // Set the to-be-previewed effect. + dialog.getSettings().set_string('close-preview-effect', Effect.getNick()); // Create the preview-window. const window = new Gtk.Window({ @@ -344,17 +335,6 @@ var PreferencesDialog = class PreferencesDialog { } window.show(); - - // Restore settings when the window gets closed. - window.connect('unrealize', () => { - // Disable the to-be-previewed effect again. - dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, false); - - // Enable all previously enabled effects again. - enabledEffects.forEach(Effect => { - dialog.getSettings().set_boolean(`${Effect.getNick()}-close-effect`, true); - }); - }); }); } }); 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 d5e9a29..ee796fc 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 @@ Set to true to burn dialogs as well. + + "" + Close Preview Effect + The effect with this nick will be used for the next window-close animation. + + From 783f5c695d9a7fa8eebc838eb1d7a568e4cea37b Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 23 Jan 2022 13:19:18 +0100 Subject: [PATCH 6/9] :wrench: GTK3 fixes --- resources/ui/gtk3/effectPage.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/ui/gtk3/effectPage.ui b/resources/ui/gtk3/effectPage.ui index 5022669..6d823f6 100644 --- a/resources/ui/gtk3/effectPage.ui +++ b/resources/ui/gtk3/effectPage.ui @@ -1,6 +1,6 @@ - +