🔨 Split prefs in separate classes

This commit is contained in:
Simon Schneegans
2022-01-08 21:30:12 +01:00
parent d6fed235c2
commit c81316bfe9
19 changed files with 1187 additions and 692 deletions
+19 -212
View File
@@ -19,12 +19,19 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.common.utils;
const FirePage = Me.imports.src.prefs.FirePage.FirePage;
const MatrixPage = Me.imports.src.prefs.MatrixPage.MatrixPage;
const TVEffectPage = Me.imports.src.prefs.TVEffectPage.TVEffectPage;
const TRexPage = Me.imports.src.prefs.TRexPage.TRexPage;
const GeneralPage = Me.imports.src.prefs.GeneralPage.GeneralPage;
//////////////////////////////////////////////////////////////////////////////////////////
// For now, the preferences dialog of this extension is very simple. In the future, if //
// we might consider to improve its layout... //
//////////////////////////////////////////////////////////////////////////////////////////
var PreferencesDialog = class PreferencesDialog {
// ------------------------------------------------------------ constructor / destructor
constructor() {
@@ -39,54 +46,16 @@ var PreferencesDialog = class PreferencesDialog {
this._builder = new Gtk.Builder();
this._builder.add_from_resource(`/ui/common/main-menu.ui`);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/prefs.ui`);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/fire.ui`);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/matrix.ui`);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/tv.ui`);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/trex.ui`);
this._generalPage = new GeneralPage(this._settings, this._builder);
this._firePage = new FirePage(this._settings, this._builder);
this._matrixPage = new MatrixPage(this._settings, this._builder);
this._tvEffectPage = new TVEffectPage(this._settings, this._builder);
this._trexPage = new TRexPage(this._settings, this._builder);
// This is our top-level widget which we will return later.
this._widget = this._builder.get_object('settings-widget');
const stack = this._builder.get_object('main-stack');
stack.add_titled(this._builder.get_object('fire-prefs'), 'fire', 'Fire');
stack.add_titled(this._builder.get_object('matrix-prefs'), 'matrix', 'Matrix');
stack.add_titled(this._builder.get_object('trex-prefs'), 'trex', 'T-Rex Attack');
stack.add_titled(this._builder.get_object('tv-prefs'), 'tv', 'TV Effect');
// Bind all properties.
this._bindCombobox('close-animation');
this._bindAdjustment('destroy-animation-time');
this._bindSwitch('destroy-dialogs');
this._bindAdjustment('flame-movement-speed');
this._bindAdjustment('flame-scale');
this._bindSwitch('flame-3d-noise');
this._bindColorButton('fire-color-1');
this._bindColorButton('fire-color-2');
this._bindColorButton('fire-color-3');
this._bindColorButton('fire-color-4');
this._bindColorButton('fire-color-5');
this._bindAdjustment('matrix-scale');
this._bindAdjustment('matrix-randomness');
this._bindColorButton('matrix-trail-color');
this._bindColorButton('matrix-tip-color');
this._bindColorButton('tv-effect-color');
this._bindColorButton('claw-scratch-color');
this._bindAdjustment('claw-scratch-scale');
this._bindAdjustment('claw-scratch-count');
this._bindAdjustment('claw-scratch-warp');
// The fire-gradient-reset button needs to be bound explicitly.
this._builder.get_object('reset-fire-colors').connect('clicked', () => {
this._settings.reset('fire-color-1');
this._settings.reset('fire-color-2');
this._settings.reset('fire-color-3');
this._settings.reset('fire-color-4');
this._settings.reset('fire-color-5');
});
// Initialize the fire-preset dropdown.
this._createFirePresets();
// Add a menu to the title bar of the preferences dialog.
this._widget.connect('realize', (widget) => {
const window = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
@@ -107,15 +76,13 @@ var PreferencesDialog = class PreferencesDialog {
group.add_action(action);
};
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(
'donate-paypal',
'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
// clang-format off
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('donate-paypal', 'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
addAction('donate-github', 'https://github.com/sponsors/Schneegans');
// clang-format on
window.insert_action_group('prefs', group);
});
@@ -139,166 +106,6 @@ var PreferencesDialog = class PreferencesDialog {
getWidget() {
return this._widget;
}
// ----------------------------------------------------------------------- private stuff
// Connects a Gtk.ComboBox (or anything else which has an 'active-id' property) to a
// settings key. It also binds the corresponding reset button.
_bindCombobox(settingsKey) {
this._bind(settingsKey, 'active-id');
}
// Connects a Gtk.Adjustment (or anything else which has a 'value' property) to a
// settings key. It also binds the corresponding reset button.
_bindAdjustment(settingsKey) {
this._bind(settingsKey, 'value');
}
// Connects a Gtk.Switch (or anything else which has an 'active' property) to a settings
// key. It also binds the corresponding reset button.
_bindSwitch(settingsKey) {
this._bind(settingsKey, 'active');
}
// Colors are stored as strings like 'rgb(1, 0.5, 0)'. As Gio.Settings.bind_with_mapping
// is not available yet, we need to do the color conversion manually. It also binds the
// corresponding reset button.
_bindColorButton(settingsKey) {
const button = this._builder.get_object(settingsKey);
if (button) {
// Update the settings when the color is modified.
button.connect('color-set', () => {
this._settings.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));
button.rgba = rgba;
};
this._settings.connect('changed::' + settingsKey, settingSignalHandler);
// Initialize the button with the state in the settings.
settingSignalHandler();
}
this._bindResetButton(settingsKey);
}
// Connects any widget's property to a settings key. The widget must have the same ID as
// the settings key. It also binds the corresponding reset button.
_bind(settingsKey, property) {
const object = this._builder.get_object(settingsKey);
if (object) {
this._settings.bind(settingsKey, object, property, Gio.SettingsBindFlags.DEFAULT);
}
this._bindResetButton(settingsKey);
}
// Searches for a reset button for the given settings key and make it reset the settings
// key when clicked.
_bindResetButton(settingsKey) {
const resetButton = this._builder.get_object('reset-' + settingsKey);
if (resetButton) {
resetButton.connect('clicked', () => {
this._settings.reset(settingsKey);
});
}
}
// This populates the preset dropdown menu for the fire options.
_createFirePresets() {
this._widget.connect('realize', (widget) => {
const presets = [
{
name: 'Default Fire',
scale: 1.0,
speed: 0.5,
color1: 'rgba(76, 51, 25, 0.0)',
color2: 'rgba(180, 55, 30, 0.7)',
color3: 'rgba(255, 76, 38, 0.9)',
color4: 'rgba(255, 166, 25, 1)',
color5: 'rgba(255, 255, 255, 1)'
},
{
name: 'Hell Fire',
scale: 1.5,
speed: 0.2,
color1: 'rgba(0,0,0,0)',
color2: 'rgba(103,7,80,0.5)',
color3: 'rgba(150,0,24,0.9)',
color4: 'rgb(255,200,0)',
color5: 'rgba(255, 255, 255, 1)'
},
{
name: 'Dark and Smutty',
scale: 1.0,
speed: 0.5,
color1: 'rgba(0,0,0,0)',
color2: 'rgba(36,3,0,0.5)',
color3: 'rgba(150,0,24,0.9)',
color4: 'rgb(255,177,21)',
color5: 'rgb(255,238,166)'
},
{
name: 'Cold Breeze',
scale: 1.5,
speed: -0.1,
color1: 'rgba(0,110,255,0)',
color2: 'rgba(30,111,180,0.24)',
color3: 'rgba(38,181,255,0.54)',
color4: 'rgba(34,162,255,0.84)',
color5: 'rgb(97,189,255)'
},
{
name: 'Santa is Coming',
scale: 0.4,
speed: -0.5,
color1: 'rgba(0,110,255,0)',
color2: 'rgba(208,233,255,0.24)',
color3: 'rgba(207,235,255,0.84)',
color4: 'rgb(208,243,255)',
color5: 'rgb(255,255,255)'
}
];
const menu = Gio.Menu.new();
const group = Gio.SimpleActionGroup.new();
const groupName = 'presets';
// Add all presets.
presets.forEach((preset, i) => {
const actionName = 'fire' + i;
menu.append(preset.name, groupName + '.' + actionName);
let action = Gio.SimpleAction.new(actionName, null);
// Load the preset on activation.
action.connect('activate', () => {
this._settings.set_double('flame-movement-speed', preset.speed);
this._settings.set_double('flame-scale', preset.scale);
this._settings.set_string('fire-color-1', preset.color1);
this._settings.set_string('fire-color-2', preset.color2);
this._settings.set_string('fire-color-3', preset.color3);
this._settings.set_string('fire-color-4', preset.color4);
this._settings.set_string('fire-color-5', preset.color5);
});
group.add_action(action);
});
this._builder.get_object('fire-preset-button').set_menu_model(menu);
const root = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
root.insert_action_group(groupName, group);
});
}
}
// Nothing to do for now...
@@ -1,14 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="flame-scale">
<object class="GtkAdjustment" id="fire-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="fire-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">
<object class="GtkAdjustment" id="fire-movement-speed">
<property name="upper">2.0</property>
<property name="lower">-2.0</property>
<property name="step-increment">0.01</property>
@@ -89,6 +96,55 @@
<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">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">fire-animation-time</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-fire-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>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
@@ -115,11 +171,11 @@
<property name="digits">2</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">flame-scale</property>
<property name="adjustment">fire-scale</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-scale">
<object class="GtkButton" id="reset-fire-scale">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
@@ -163,11 +219,11 @@
<property name="digits">2</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">flame-movement-speed</property>
<property name="adjustment">fire-movement-speed</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-movement-speed">
<object class="GtkButton" id="reset-fire-movement-speed">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
@@ -223,13 +279,13 @@
</object>
</child>
<child>
<object class="GtkSwitch" id="flame-3d-noise">
<object class="GtkSwitch" id="fire-3d-noise">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-3d-noise">
<object class="GtkButton" id="reset-fire-3d-noise">
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-symbolic</property>
+129
View File
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="general-prefs">
<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="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="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Close Window Animation</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="GtkLabel">
<property name="label" translatable="yes">If multiple are selected, one is chosen randomly.</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
<style>
<class name="dim-label" />
<class name="caption" />
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuButton" id="close-effect-button">
<property name="label">Effects</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-close-animation">
<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">Also Burn Dialogs</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="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<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>
</interface>
+1 -194
View File
@@ -2,23 +2,6 @@
<interface>
<requires lib="gtk" version="3.0" />
<object class="GtkListStore" id="animation-mode-list">
<columns>
<column type="gchararray" />
<column type="gchararray" />
</columns>
<data>
<row>
<col id="0">Fire</col>
<col id="1">fire</col>
</row>
<row>
<col id="0">TV Effect</col>
<col id="1">tv</col>
</row>
</data>
</object>
<object class="GtkMenuButton" id="menu-button">
<property name="menu-model">main-menu</property>
<property name="visible">1</property>
@@ -31,13 +14,6 @@
</child>
</object>
<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="GtkBox" id="settings-widget">
<child>
<object class="GtkStackSidebar">
@@ -49,177 +25,8 @@
<property name="transition-type">slide-up-down</property>
<property name="hexpand">1</property>
<child>
<!-- Stack pages are inserted here -->
<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="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">Close Window Animation</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="GtkComboBox" id="close-animation">
<property name="valign">center</property>
<property name="model">animation-mode-list</property>
<property name="id_column">1</property>
<property name="active_id">fire</property>
<child>
<object class="GtkCellRendererText" />
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="reset-close-animation">
<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">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>
<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">Also Burn Dialogs</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="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<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>
<packing>
<property name="title">General Options</property>
</packing>
</child>
</object>
</child>
</object>
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="tv-animation-time">
<property name="upper">5000</property>
<property name="lower">100</property>
<property name="step-increment">10</property>
<property name="page-increment">100</property>
</object>
<object class="GtkBox" id="tv-prefs">
<property name="orientation">vertical</property>
<property name="margin-start">60</property>
@@ -17,6 +24,55 @@
<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">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">tv-animation-time</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-tv-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>
<child>
<object class="GtkListBoxRow">
<property name="margin-start">10</property>
@@ -58,6 +58,52 @@
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<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">
<object class="GtkAdjustment" id="fire-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>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-fire-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
@@ -81,7 +127,7 @@
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">
<object class="GtkAdjustment" id="flame-scale">
<object class="GtkAdjustment" id="fire-scale">
<property name="upper">3</property>
<property name="lower">0.1</property>
<property name="step-increment">0.01</property>
@@ -91,7 +137,7 @@
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-scale">
<object class="GtkButton" id="reset-fire-scale">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
@@ -127,7 +173,7 @@
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">
<object class="GtkAdjustment" id="flame-movement-speed">
<object class="GtkAdjustment" id="fire-movement-speed">
<property name="upper">2.0</property>
<property name="lower">-2.0</property>
<property name="step-increment">0.01</property>
@@ -137,7 +183,7 @@
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-movement-speed">
<object class="GtkButton" id="reset-fire-movement-speed">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
@@ -184,13 +230,13 @@
</object>
</child>
<child>
<object class="GtkSwitch" id="flame-3d-noise">
<object class="GtkSwitch" id="fire-3d-noise">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-flame-3d-noise">
<object class="GtkButton" id="reset-fire-3d-noise">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
+115
View File
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="general-prefs">
<property name="orientation">vertical</property>
<property name="margin-start">60</property>
<property name="margin-end">60</property>
<property name="margin-top">60</property>
<property name="margin-bottom">60</property>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Close Window Animation</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="GtkLabel">
<property name="label" translatable="yes">If multiple are selected, one is chosen randomly.</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
<style>
<class name="dim-label" />
<class name="caption" />
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuButton" id="close-effect-button">
<property name="label">Effects</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-close-animation">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Also Burn Dialogs</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="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<property name="icon-name">edit-clear-symbolic</property>
<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>
</interface>
@@ -18,6 +18,52 @@
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<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">
<object class="GtkAdjustment" id="matrix-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>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-matrix-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
+1 -180
View File
@@ -2,31 +2,6 @@
<interface>
<requires lib="gtk" version="4.0" />
<object class="GtkListStore" id="animation-mode-list">
<columns>
<column type="gchararray" />
<column type="gchararray" />
</columns>
<data>
<row>
<col id="0">Fire</col>
<col id="1">fire</col>
</row>
<row>
<col id="0">Matrix</col>
<col id="1">matrix</col>
</row>
<row>
<col id="0">TV Effect</col>
<col id="1">tv</col>
</row>
<row>
<col id="0">T-Rex Attack</col>
<col id="1">trex</col>
</row>
</data>
</object>
<object class="GtkMenuButton" id="menu-button">
<property name="menu-model">main-menu</property>
<property name="icon-name">open-menu-symbolic</property>
@@ -43,161 +18,7 @@
<property name="transition-type">slide-up-down</property>
<property name="hexpand">1</property>
<child>
<object class="GtkStackPage">
<property name="title">General Options</property>
<property name="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">60</property>
<property name="margin-bottom">60</property>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Close Window Animation</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="GtkComboBox" id="close-animation">
<property name="valign">center</property>
<property name="model">animation-mode-list</property>
<property name="id_column">1</property>
<property name="active_id">fire</property>
<child>
<object class="GtkCellRendererText" />
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="reset-close-animation">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
<child>
<object class="GtkBox">
<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">
<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>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Also Burn Dialogs</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="GtkSwitch" id="destroy-dialogs">
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-destroy-dialogs">
<property name="icon-name">edit-clear-symbolic</property>
<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>
</property>
</object>
</child>
<!-- Stack pages are inserted here -->
</object>
</child>
@@ -18,6 +18,52 @@
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<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">
<object class="GtkAdjustment" id="trex-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>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-trex-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
-63
View File
@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="tv-prefs">
<property name="orientation">vertical</property>
<property name="margin-start">60</property>
<property name="margin-end">60</property>
<property name="margin-top">60</property>
<property name="margin-bottom">60</property>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Color</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="tv-effect-color">
<property name="use_alpha">0</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-tv-effect-color">
<property name="icon-name">edit-clear-symbolic</property>
<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>
</interface>
+109
View File
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="tv-prefs">
<property name="orientation">vertical</property>
<property name="margin-start">60</property>
<property name="margin-end">60</property>
<property name="margin-top">60</property>
<property name="margin-bottom">60</property>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<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">
<object class="GtkAdjustment" id="tv-animation-time">
<property name="upper">5000</property>
<property name="lower">100</property>
<property name="step-increment">10</property>
<property name="page-increment">100</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-tv-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<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="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Color</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="tv-effect-color">
<property name="use_alpha">0</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-tv-effect-color">
<property name="icon-name">edit-clear-symbolic</property>
<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>
</interface>
@@ -1,27 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id='org.gnome.shell.extensions.burn-my-windows.AnimationType'>
<value value='1' nick='fire' />
<value value='2' nick='matrix' />
<value value='3' nick='tv' />
<value value='4' nick='trex' />
</enum>
<schema path="/org/gnome/shell/extensions/burn-my-windows/" id="org.gnome.shell.extensions.burn-my-windows">
<key name="close-animation" enum="org.gnome.shell.extensions.burn-my-windows.AnimationType">
<default>"fire"</default>
<summary>Close Animation</summary>
<description>The animation used for window closing.</description>
</key>
<key name="destroy-animation-time" type="i">
<default>1500</default>
<summary>Destroy Animation Time</summary>
<description>The time it takes to burn the windows.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- General Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="destroy-dialogs" type="b">
<default>false</default>
@@ -29,22 +13,38 @@
<description>Set to true to burn dialogs as well.</description>
</key>
<key name="flame-movement-speed" type="d">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Fire Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="fire-close-effect" type="b">
<default>true</default>
<summary>Fire Close Effect</summary>
<description>Use the fire effect for window closing.</description>
</key>
<key name="fire-animation-time" type="i">
<default>1500</default>
<summary>Fire Animation Time</summary>
<description>The time the fire effect takes.</description>
</key>
<key name="fire-movement-speed" type="d">
<default>0.5</default>
<summary>Flame Movement Speed</summary>
<description>The speed at which the flames move.</description>
<summary>Fire Movement Speed</summary>
<description>The speed at which the fire moves.</description>
</key>
<key name="flame-scale" type="d">
<key name="fire-scale" type="d">
<default>1.0</default>
<summary>Flame Scale</summary>
<description>The size of the flames.</description>
<summary>Fire Scale</summary>
<description>The size of the fire.</description>
</key>
<key name="flame-3d-noise" type="b">
<key name="fire-3d-noise" type="b">
<default>false</default>
<summary>Flame 3D Noise</summary>
<description>Use a 3D noise for the flames.</description>
<summary>Fire 3D Noise</summary>
<description>Use a 3D noise for the fire.</description>
</key>
<key name="fire-color-1" type="s">
@@ -77,6 +77,21 @@
<description>The fifth color of the fire gradient.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Matrix Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="matrix-close-effect" type="b">
<default>false</default>
<summary>Matrix Close Effect</summary>
<description>Use the matrix effect for window closing.</description>
</key>
<key name="matrix-animation-time" type="i">
<default>2000</default>
<summary>Matrix Animation Time</summary>
<description>The time the matrix effect takes.</description>
</key>
<key name="matrix-scale" type="i">
<default>20</default>
@@ -102,6 +117,21 @@
<description>The color matrix trails.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- TV Effect Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="tv-close-effect" type="b">
<default>false</default>
<summary>TV Close Effect</summary>
<description>Use the tv effect for window closing.</description>
</key>
<key name="tv-animation-time" type="i">
<default>250</default>
<summary>TV Animation Time</summary>
<description>The time the tv effect takes.</description>
</key>
<key name="tv-effect-color" type="s">
<default>"rgb(255, 255, 255)"</default>
@@ -109,6 +139,21 @@
<description>The color of the TV effect.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- T-Rex Attack Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="trex-close-effect" type="b">
<default>false</default>
<summary>T-Rex Close Effect</summary>
<description>Use the trex effect for window closing.</description>
</key>
<key name="trex-animation-time" type="i">
<default>1500</default>
<summary>T-Rex Animation Time</summary>
<description>The time the trex effect takes.</description>
</key>
<key name="claw-scratch-color" type="s">
<default>"rgb(170, 0, 0)"</default>
@@ -134,7 +179,6 @@
<description>Number of claw scratches drawn on top of each other.</description>
</key>
</schema>
</schemalist>
+165
View File
@@ -0,0 +1,165 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const {Gio} = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.common.utils;
const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var FirePage = class FirePage extends PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
super(settings, builder);
this._builder.add_from_resource(
`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/firePage.ui`);
// Bind all properties.
this._bindAdjustment('fire-animation-time');
this._bindAdjustment('fire-movement-speed');
this._bindAdjustment('fire-scale');
this._bindSwitch('fire-3d-noise');
this._bindColorButton('fire-color-1');
this._bindColorButton('fire-color-2');
this._bindColorButton('fire-color-3');
this._bindColorButton('fire-color-4');
this._bindColorButton('fire-color-5');
// The fire-gradient-reset button needs to be bound explicitly.
this._builder.get_object('reset-fire-colors').connect('clicked', () => {
this._settings.reset('fire-color-1');
this._settings.reset('fire-color-2');
this._settings.reset('fire-color-3');
this._settings.reset('fire-color-4');
this._settings.reset('fire-color-5');
});
// Initialize the fire-preset dropdown.
this._createFirePresets();
const stack = this._builder.get_object('main-stack');
stack.add_titled(this._builder.get_object('fire-prefs'), 'fire', 'Fire');
}
// ---------------------------------------------------------------------- public methods
getMinVersion() {
return [3, 36];
}
getEnabledKey() {
return 'fire-close-effect';
}
getAnimationTime() {
return this._settings.get_int('fire-animation-time');
}
// ----------------------------------------------------------------------- private stuff
// This populates the preset dropdown menu for the fire options.
_createFirePresets() {
this._builder.get_object('settings-widget').connect('realize', (widget) => {
const presets = [
{
name: 'Default Fire',
scale: 1.0,
speed: 0.5,
color1: 'rgba(76, 51, 25, 0.0)',
color2: 'rgba(180, 55, 30, 0.7)',
color3: 'rgba(255, 76, 38, 0.9)',
color4: 'rgba(255, 166, 25, 1)',
color5: 'rgba(255, 255, 255, 1)'
},
{
name: 'Hell Fire',
scale: 1.5,
speed: 0.2,
color1: 'rgba(0,0,0,0)',
color2: 'rgba(103,7,80,0.5)',
color3: 'rgba(150,0,24,0.9)',
color4: 'rgb(255,200,0)',
color5: 'rgba(255, 255, 255, 1)'
},
{
name: 'Dark and Smutty',
scale: 1.0,
speed: 0.5,
color1: 'rgba(0,0,0,0)',
color2: 'rgba(36,3,0,0.5)',
color3: 'rgba(150,0,24,0.9)',
color4: 'rgb(255,177,21)',
color5: 'rgb(255,238,166)'
},
{
name: 'Cold Breeze',
scale: 1.5,
speed: -0.1,
color1: 'rgba(0,110,255,0)',
color2: 'rgba(30,111,180,0.24)',
color3: 'rgba(38,181,255,0.54)',
color4: 'rgba(34,162,255,0.84)',
color5: 'rgb(97,189,255)'
},
{
name: 'Santa is Coming',
scale: 0.4,
speed: -0.5,
color1: 'rgba(0,110,255,0)',
color2: 'rgba(208,233,255,0.24)',
color3: 'rgba(207,235,255,0.84)',
color4: 'rgb(208,243,255)',
color5: 'rgb(255,255,255)'
}
];
const menu = Gio.Menu.new();
const group = Gio.SimpleActionGroup.new();
const groupName = 'presets';
// Add all presets.
presets.forEach((preset, i) => {
const actionName = 'fire' + i;
menu.append(preset.name, groupName + '.' + actionName);
let action = Gio.SimpleAction.new(actionName, null);
// Load the preset on activation.
action.connect('activate', () => {
this._settings.set_double('fire-movement-speed', preset.speed);
this._settings.set_double('fire-scale', preset.scale);
this._settings.set_string('fire-color-1', preset.color1);
this._settings.set_string('fire-color-2', preset.color2);
this._settings.set_string('fire-color-3', preset.color3);
this._settings.set_string('fire-color-4', preset.color4);
this._settings.set_string('fire-color-5', preset.color5);
});
group.add_action(action);
});
this._builder.get_object('fire-preset-button').set_menu_model(menu);
const root = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
root.insert_action_group(groupName, group);
});
}
}
+43
View File
@@ -0,0 +1,43 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.common.utils;
const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var GeneralPage = class GeneralPage extends PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
super(settings, builder);
this._builder.add_from_resource(
`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/generalPage.ui`);
// Bind all properties.
this._bindSwitch('destroy-dialogs');
const stack = this._builder.get_object('main-stack');
stack.add_titled(
this._builder.get_object('general-prefs'), 'general', 'General Options');
}
// ---------------------------------------------------------------------- public methods
}
+56
View File
@@ -0,0 +1,56 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var MatrixPage = class MatrixPage extends PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
super(settings, builder);
this._builder.add_from_resource('/ui/gtk4/matrixPage.ui');
// Bind all properties.
this._bindAdjustment('matrix-animation-time');
this._bindAdjustment('matrix-scale');
this._bindAdjustment('matrix-randomness');
this._bindColorButton('matrix-trail-color');
this._bindColorButton('matrix-tip-color');
const stack = this._builder.get_object('main-stack');
stack.add_titled(this._builder.get_object('matrix-prefs'), 'matrix', 'Matrix');
}
// ---------------------------------------------------------------------- public methods
getMinVersion() {
return [40, 0];
}
getEnabledKey() {
return 'matrix-close-effect';
}
getAnimationTime() {
return this._settings.get_int('matrix-animation-time');
}
}
+102
View File
@@ -0,0 +1,102 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const {Gdk, Gio} = imports.gi;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var PrefsPage = class PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
this._settings = settings;
this._builder = builder;
}
// ---------------------------------------------------------------------- public methods
// Connects a Gtk.ComboBox (or anything else which has an 'active-id' property) to a
// settings key. It also binds the corresponding reset button.
_bindCombobox(settingsKey) {
this._bind(settingsKey, 'active-id');
}
// Connects a Gtk.Adjustment (or anything else which has a 'value' property) to a
// settings key. It also binds the corresponding reset button.
_bindAdjustment(settingsKey) {
this._bind(settingsKey, 'value');
}
// Connects a Gtk.Switch (or anything else which has an 'active' property) to a settings
// key. It also binds the corresponding reset button.
_bindSwitch(settingsKey) {
this._bind(settingsKey, 'active');
}
// Colors are stored as strings like 'rgb(1, 0.5, 0)'. As Gio.Settings.bind_with_mapping
// is not available yet, we need to do the color conversion manually. It also binds the
// corresponding reset button.
_bindColorButton(settingsKey) {
const button = this._builder.get_object(settingsKey);
if (button) {
// Update the settings when the color is modified.
button.connect('color-set', () => {
this._settings.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));
button.rgba = rgba;
};
this._settings.connect('changed::' + settingsKey, settingSignalHandler);
// Initialize the button with the state in the settings.
settingSignalHandler();
}
this._bindResetButton(settingsKey);
}
// Connects any widget's property to a settings key. The widget must have the same ID as
// the settings key. It also binds the corresponding reset button.
_bind(settingsKey, property) {
const object = this._builder.get_object(settingsKey);
if (object) {
this._settings.bind(settingsKey, object, property, Gio.SettingsBindFlags.DEFAULT);
}
this._bindResetButton(settingsKey);
}
// Searches for a reset button for the given settings key and make it reset the settings
// key when clicked.
_bindResetButton(settingsKey) {
const resetButton = this._builder.get_object('reset-' + settingsKey);
if (resetButton) {
resetButton.connect('clicked', () => {
this._settings.reset(settingsKey);
});
}
}
}
+56
View File
@@ -0,0 +1,56 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var TRexPage = class TRexPage extends PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
super(settings, builder);
this._builder.add_from_resource('/ui/gtk4/trexPage.ui');
// Bind all properties.
this._bindAdjustment('trex-animation-time');
this._bindColorButton('claw-scratch-color');
this._bindAdjustment('claw-scratch-scale');
this._bindAdjustment('claw-scratch-count');
this._bindAdjustment('claw-scratch-warp');
const stack = this._builder.get_object('main-stack');
stack.add_titled(this._builder.get_object('trex-prefs'), 'trex', 'T-Rex Attack');
}
// ---------------------------------------------------------------------- public methods
getMinVersion() {
return [40, 0];
}
getEnabledKey() {
return 'trex-close-effect';
}
getAnimationTime() {
return this._settings.get_int('trex-animation-time');
}
}
+54
View File
@@ -0,0 +1,54 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.common.utils;
const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
var TVEffectPage = class TVEffectPage extends PrefsPage {
// ------------------------------------------------------------ constructor / destructor
constructor(settings, builder) {
super(settings, builder);
this._builder.add_from_resource(`/ui/${utils.isGTK4() ? 'gtk4' : 'gtk3'}/tvPage.ui`);
// Bind all properties.
this._bindAdjustment('tv-animation-time');
this._bindColorButton('tv-effect-color');
const stack = this._builder.get_object('main-stack');
stack.add_titled(this._builder.get_object('tv-prefs'), 'tv', 'TV Effect');
}
// ---------------------------------------------------------------------- public methods
getMinVersion() {
return [3, 36];
}
getEnabledKey() {
return 'tv-close-effect';
}
getAnimationTime() {
return this._settings.get_int('tv-animation-time');
}
}