🎉 Add support for older GNOME versions

This commit is contained in:
Simon Schneegans
2021-12-20 20:11:39 +01:00
parent 570a0146b6
commit 42ccf20704
5 changed files with 360 additions and 2 deletions
+2
View File
@@ -5,6 +5,8 @@
"gettext-domain": "burn-my-windows",
"settings-schema": "org.gnome.shell.extensions.burn-my-windows",
"shell-version": [
"3.36",
"3.38",
"40",
"41"
],
+9 -2
View File
@@ -34,7 +34,7 @@ var PreferencesDialog = class PreferencesDialog {
// Load the user interface file.
this._builder = new Gtk.Builder();
this._builder.add_from_resource(`/ui/settings.ui`);
this._builder.add_from_resource(`/ui/${utils.gtk4() ? "gtk4" : "gtk3"}.ui`);
// This is our top-level widget which we will return later.
this._widget = this._builder.get_object('settings-widget');
@@ -70,6 +70,11 @@ var PreferencesDialog = class PreferencesDialog {
// Unregister our resources.
Gio.resources_unregister(this._resources);
});
// Show the widgets on GTK3.
if (!utils.gtk4()) {
this._widget.show_all();
}
}
// -------------------------------------------------------------------- public interface
@@ -210,7 +215,9 @@ var PreferencesDialog = class PreferencesDialog {
});
this._builder.get_object('fire-preset-button').set_menu_model(menu);
widget.get_root().insert_action_group(groupName, group);
const root = utils.gtk4() ? widget.get_root() : widget.get_toplevel();
root.insert_action_group(groupName, group);
});
}
}
+342
View File
@@ -0,0 +1,342 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="desktop-cube">
<requires lib="gtk" version="3.0" />
<object class="GtkAdjustment" id="destroy-animation-time">
<property name="upper">10000</property>
<property name="lower">500</property>
<property name="step-increment">10</property>
<property name="page-increment">100</property>
</object>
<object class="GtkAdjustment" id="flame-scale">
<property name="upper">3</property>
<property name="lower">0.1</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.1</property>
</object>
<object class="GtkAdjustment" id="flame-movement-speed">
<property name="upper">2.0</property>
<property name="lower">-2.0</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.1</property>
</object>
<object class="GtkScrolledWindow" id="settings-widget">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">200</property>
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<child>
<object class="GtkViewport">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-start">60</property>
<property name="margin-end">60</property>
<property name="margin-top">30</property>
<property name="margin-bottom">30</property>
<child>
<object class="GtkLabel">
<property name="margin-top">30</property>
<property name="margin-bottom">10</property>
<property name="label">General Options</property>
<property name="xalign">0</property>
<style>
<class name="title-4" />
</style>
</object>
</child>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<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">destroy-animation-time</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-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">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="margin-top">30</property>
<property name="margin-bottom">10</property>
<child>
<object class="GtkLabel">
<property name="label">Fire Options</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
<style>
<class name="title-4" />
</style>
</object>
</child>
<child>
<object class="GtkMenuButton" id="fire-preset-button">
<property name="relief">none</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Choose a Preset</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">pan-down-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Flame Scale</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">flame-scale</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-scale">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Flame Movement Speed</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">flame-movement-speed</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-movement-speed">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Fire Gradient</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="GtkColorButton" id="fire-color-1">
<property name="use_alpha">1</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="fire-color-2">
<property name="use_alpha">1</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="fire-color-3">
<property name="use_alpha">1</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="fire-color-4">
<property name="use_alpha">1</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="fire-color-5">
<property name="use_alpha">1</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-fire-colors">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
+7
View File
@@ -13,6 +13,8 @@
'use strict';
const {Gtk} = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
@@ -35,3 +37,8 @@ function debug(message) {
log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
// This method simply returns true if we are currently using GTK4.
function gtk4() {
return Gtk.get_major_version() == 4;
}