🔀 Merge pull request #319 from Schneegans/feature/fix-tutorial

This commit is contained in:
Simon Schneegans
2023-03-29 20:47:04 +02:00
committed by GitHub
3 changed files with 172 additions and 162 deletions
+5
View File
@@ -14,6 +14,11 @@ SPDX-License-Identifier: CC-BY-4.0
#### Other Enhancements #### Other Enhancements
* **New donation method: Ko-fi**. Follow me on Ko-fi to get the latest updates regarding my extensions: https://ko-fi.com/schneegans! * **New donation method: Ko-fi**. Follow me on Ko-fi to get the latest updates regarding my extensions: https://ko-fi.com/schneegans!
* It is now possible to create effects which do not have any settings at all.
#### Bug Fixes
* The tutorial on how to create new effects has been updated and should work again.
## [Burn My Windows 27](https://github.com/schneegans/Burn-My-Windows/releases/tag/v27) ## [Burn My Windows 27](https://github.com/schneegans/Burn-My-Windows/releases/tag/v27)
+154 -159
View File
@@ -49,7 +49,7 @@ You will have to ...
For enabling the new effect, the boolean settings keys `simple-fade-enable-effect` and `simple-fade-animation-time` are required. For enabling the new effect, the boolean settings keys `simple-fade-enable-effect` and `simple-fade-animation-time` are required.
In this example, we also add a floating point value for storing another property of the effect - we will use them later in the tutorial. In this example, we also add a floating point value for storing another property of the effect - we will use them later in the tutorial.
Just copy the XML code below to the file [`schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml`](../schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml). Just copy the XML code below to the file [`schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml`](../schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml).
Just remember to replace `simple-fade` with your custom name! Just remember to replace `simple-fade` with your custom name!
```xml ```xml
@@ -86,6 +86,20 @@ Please study this code carefully, all of it is explained with inline comments.
<summary>Expand this to show the GLSL code.</summary> <summary>Expand this to show the GLSL code.</summary>
```glsl ```glsl
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
//////////////////////////////////////////////////////////////////////////////////////////
// SPDX-FileCopyrightText: Your Name <your@email.com>
// SPDX-License-Identifier: GPL-3.0-or-later
// The content from common.glsl is automatically prepended to each shader effect. This // The content from common.glsl is automatically prepended to each shader effect. This
// provides the standard input: // provides the standard input:
@@ -214,7 +228,6 @@ var SimpleFade = class {
// binds all user interface elements to the respective settings keys of the profile. // binds all user interface elements to the respective settings keys of the profile.
bindPreferences(dialog) { bindPreferences(dialog) {
// Empty for now... Code is added here later in the tutorial! // Empty for now... Code is added here later in the tutorial!
return null;
} }
// ---------------------------------------------------------------- API for extension.js // ---------------------------------------------------------------- API for extension.js
@@ -265,7 +278,8 @@ 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 three `*.ui` files for this. If your effect supports GNOME Shell 3.3x _and_ GNOME Shell 40+, you will have to provide three `*.ui` files for this.
This is because starting with GNOME Shell 40, the preference dialog uses GTK4, before it used to use GTK3. This is because starting with GNOME Shell 40, the preference dialog uses GTK4, before it used to use GTK3.
Starting with GNOME Shell 42, it uses `libadwaita` which requires different UI files again. Starting with GNOME Shell 42, it uses `libadwaita` which requires different UI files again.
We will load the respective file in the `bindPreferences()` method of your new effect class.
_:information_source: If you do not have the means to test your effect on different versions of GNOME, feel free to submit a pull request for one GNOME version only, I may then port your effect to other GNOME versions!_
Just save the code below to `resources/ui/gtk3/simple-fade.ui`, `resources/ui/gtk4/simple-fade.ui`, and `resources/ui/adw/simple-fade.ui` respectively. Just save the code below to `resources/ui/gtk3/simple-fade.ui`, `resources/ui/gtk4/simple-fade.ui`, and `resources/ui/adw/simple-fade.ui` respectively.
Remember to replace any occurrence of `simple-fade` with your effect's nick-name! Remember to replace any occurrence of `simple-fade` with your effect's nick-name!
@@ -281,7 +295,7 @@ SPDX-FileCopyrightText: Your Name <your@email.com>
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
--> -->
<interface> <interface domain="burn-my-windows">
<object class="GtkAdjustment" id="simple-fade-animation-time"> <object class="GtkAdjustment" id="simple-fade-animation-time">
<property name="upper">5000</property> <property name="upper">5000</property>
@@ -297,106 +311,97 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="page-increment">0.1</property> <property name="page-increment">0.1</property>
</object> </object>
<object class="GtkBox" id="simple-fade-prefs"> <object class="GtkRevealer" id="simple-fade-prefs">
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkFrame"> <object class="GtkListBox">
<property name="selection-mode">none</property>
<child> <child>
<object class="GtkListBox"> <object class="GtkListBoxRow">
<property name="selection-mode">none</property> <property name="activatable">0</property>
<style>
<class name="rich-list" />
</style>
<child> <child>
<object class="GtkListBoxRow"> <object class="GtkBox">
<property name="activatable">0</property>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel">
<property name="label" translatable="yes">Animation Time [ms]</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">0</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">simple-fade-animation-time</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-simple-fade-animation-time">
<child> <child>
<object class="GtkLabel"> <object class="GtkImage">
<property name="label" translatable="yes">Animation Time [ms]</property> <property name="icon-name">edit-clear-symbolic</property>
<property name="xalign">0</property> <property name="icon-size">1</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">0</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">simple-fade-animation-time</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-simple-fade-animation-time">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object> </object>
</child> </child>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child> <child>
<object class="GtkListBoxRow"> <object class="GtkBox">
<property name="activatable">0</property>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel">
<property name="label" translatable="yes">Fade Width</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">2</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">simple-fade-width</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-simple-fade-width">
<child> <child>
<object class="GtkLabel"> <object class="GtkImage">
<property name="label" translatable="yes">Fade Width</property> <property name="icon-name">edit-clear-symbolic</property>
<property name="xalign">0</property> <property name="icon-size">1</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">2</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">simple-fade-width</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-simple-fade-width">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object> </object>
</child> </child>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
@@ -423,7 +428,7 @@ SPDX-FileCopyrightText: Your Name <your@email.com>
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
--> -->
<interface> <interface domain="burn-my-windows">
<object class="GtkAdjustment" id="simple-fade-animation-time"> <object class="GtkAdjustment" id="simple-fade-animation-time">
<property name="upper">5000</property> <property name="upper">5000</property>
@@ -439,97 +444,87 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="page-increment">0.1</property> <property name="page-increment">0.1</property>
</object> </object>
<object class="GtkBox" id="simple-fade-prefs"> <object class="GtkRevealer" id="simple-fade-prefs">
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkFrame"> <object class="GtkListBox">
<property name="selection-mode">none</property>
<child> <child>
<object class="GtkListBox"> <object class="GtkListBoxRow">
<property name="selection-mode">none</property> <property name="activatable">0</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child> <child>
<object class="GtkListBoxRow"> <object class="GtkBox">
<property name="activatable">0</property>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel">
<child> <property name="label" translatable="yes">Animation Time [ms]</property>
<object class="GtkLabel"> <property name="xalign">0</property>
<property name="label" translatable="yes">Animation Time [ms]</property> <property name="halign">start</property>
<property name="xalign">0</property> <property name="valign">center</property>
<property name="halign">start</property> <property name="hexpand">1</property>
<property name="valign">center</property> </object>
<property name="hexpand">1</property> </child>
</object> <child>
</child> <object class="GtkScale">
<child> <property name="halign">end</property>
<object class="GtkScale"> <property name="valign">center</property>
<property name="halign">end</property> <property name="draw-value">1</property>
<property name="valign">center</property> <property name="digits">0</property>
<property name="draw-value">1</property> <property name="value-pos">left</property>
<property name="digits">0</property> <property name="width-request">300</property>
<property name="value-pos">left</property> <property name="adjustment">simple-fade-animation-time</property>
<property name="width-request">300</property> </object>
<property name="adjustment">simple-fade-animation-time</property> </child>
</object> <child>
</child> <object class="GtkButton" id="reset-simple-fade-animation-time">
<child> <property name="icon-name">edit-clear-symbolic</property>
<object class="GtkButton" id="reset-simple-fade-animation-time"> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<property name="icon-name">edit-clear-symbolic</property> <style>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <class name="flat" />
<style> </style>
<class name="flat" />
</style>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child> <child>
<object class="GtkListBoxRow"> <object class="GtkBox">
<property name="activatable">0</property>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel">
<child> <property name="label" translatable="yes">Fade Width</property>
<object class="GtkLabel"> <property name="xalign">0</property>
<property name="label" translatable="yes">Fade Width</property> <property name="halign">start</property>
<property name="xalign">0</property> <property name="valign">center</property>
<property name="halign">start</property> <property name="hexpand">1</property>
<property name="valign">center</property> </object>
<property name="hexpand">1</property> </child>
</object> <child>
</child> <object class="GtkScale">
<child> <property name="halign">end</property>
<object class="GtkScale"> <property name="valign">center</property>
<property name="halign">end</property> <property name="draw-value">1</property>
<property name="valign">center</property> <property name="digits">2</property>
<property name="draw-value">1</property> <property name="value-pos">left</property>
<property name="digits">2</property> <property name="width-request">300</property>
<property name="value-pos">left</property> <property name="adjustment">simple-fade-width</property>
<property name="width-request">300</property> </object>
<property name="adjustment">simple-fade-width</property> </child>
</object> <child>
</child> <object class="GtkButton" id="reset-simple-fade-width">
<child> <property name="icon-name">edit-clear-symbolic</property>
<object class="GtkButton" id="reset-simple-fade-width"> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<property name="icon-name">edit-clear-symbolic</property> <style>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <class name="flat" />
<style> </style>
<class name="flat" />
</style>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
@@ -570,7 +565,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<property name="page-increment">0.1</property> <property name="page-increment">0.1</property>
</object> </object>
<object class="AdwActionRow" id="simple-fade-prefs"> <object class="AdwExpanderRow" id="simple-fade-prefs">
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
+13 -3
View File
@@ -227,8 +227,16 @@ var PreferencesDialog = class PreferencesDialog {
const [minMajor, minMinor] = effect.getMinShellVersion(); const [minMajor, minMinor] = effect.getMinShellVersion();
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`; const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`;
const [hasPrefs] = Gio.resources_get_info(uiFile, 0);
// Is there a better way to test for the existence of a resource file?
let hasPrefs = false;
try {
Gio.resources_get_info(uiFile, 0);
hasPrefs = true;
} catch (e) {
// Nothing todo, there
}
// Add the settings page to the builder. // Add the settings page to the builder.
if (hasPrefs) { if (hasPrefs) {
@@ -288,9 +296,11 @@ var PreferencesDialog = class PreferencesDialog {
} }
}); });
this._effectRows.push(row); this._effectRows.push(row);
row.add_action(previewButton);
} else {
row.add_suffix(previewButton);
} }
row.add_action(previewButton);
row.add_prefix(button); row.add_prefix(button);
group.add(row); group.add(row);