🔧 Add close-effects menu
This commit is contained in:
@@ -30,6 +30,8 @@ const GeneralPage = Me.imports.src.prefs.GeneralPage.GeneralPage;
|
|||||||
// we might consider to improve its layout... //
|
// we might consider to improve its layout... //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const EFFECT_TYPES = [FirePage, MatrixPage, TVEffectPage, TRexPage];
|
||||||
|
|
||||||
var PreferencesDialog = class PreferencesDialog {
|
var PreferencesDialog = class PreferencesDialog {
|
||||||
|
|
||||||
// ------------------------------------------------------------ constructor / destructor
|
// ------------------------------------------------------------ constructor / destructor
|
||||||
@@ -47,44 +49,70 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
this._builder.add_from_resource(`/ui/common/main-menu.ui`);
|
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'}/prefs.ui`);
|
||||||
|
|
||||||
this._generalPage = new GeneralPage(this._settings, this._builder);
|
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._effects = [];
|
||||||
this._tvEffectPage = new TVEffectPage(this._settings, this._builder);
|
EFFECT_TYPES.forEach(Type => {
|
||||||
this._trexPage = new TRexPage(this._settings, this._builder);
|
const [minMajor, minMinor] = Type.getMinShellVersion();
|
||||||
|
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
||||||
|
this._effects.push(new Type(this._settings, this._builder));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// This is our top-level widget which we will return later.
|
// This is our top-level widget which we will return later.
|
||||||
this._widget = this._builder.get_object('settings-widget');
|
this._widget = this._builder.get_object('settings-widget');
|
||||||
|
|
||||||
// Add a menu to the title bar of the preferences dialog.
|
// Some things can only be done once the widget is shown as we do not have access to
|
||||||
|
// the toplevel widget before.
|
||||||
this._widget.connect('realize', (widget) => {
|
this._widget.connect('realize', (widget) => {
|
||||||
const window = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
|
const window = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
|
||||||
|
|
||||||
// Show the version number in the title bar.
|
// Show the version number in the title bar.
|
||||||
window.set_title(`Burn-My-Windows ${Me.metadata.version}`);
|
window.set_title(`Burn-My-Windows ${Me.metadata.version}`);
|
||||||
|
|
||||||
// Add the menu.
|
// Add the main menu to the title bar.
|
||||||
const menu = this._builder.get_object('menu-button');
|
{
|
||||||
window.get_titlebar().pack_end(menu);
|
// Add the menu button to the title bar.
|
||||||
|
const menu = this._builder.get_object('menu-button');
|
||||||
|
window.get_titlebar().pack_end(menu);
|
||||||
|
|
||||||
// Populate the actions.
|
// Populate the menu with actions.
|
||||||
const group = Gio.SimpleActionGroup.new();
|
const group = Gio.SimpleActionGroup.new();
|
||||||
|
window.insert_action_group('prefs', group);
|
||||||
|
|
||||||
const addAction = (name, uri) => {
|
const addAction = (name, uri) => {
|
||||||
const action = Gio.SimpleAction.new(name, null);
|
const action = Gio.SimpleAction.new(name, null);
|
||||||
action.connect('activate', () => Gtk.show_uri(null, uri, Gdk.CURRENT_TIME));
|
action.connect('activate', () => Gtk.show_uri(null, uri, Gdk.CURRENT_TIME));
|
||||||
group.add_action(action);
|
group.add_action(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
addAction('homepage', 'https://github.com/Schneegans/Burn-My-Windows');
|
addAction('homepage', 'https://github.com/Schneegans/Burn-My-Windows');
|
||||||
addAction('changelog', 'https://github.com/Schneegans/Burn-My-Windows/blob/main/docs/changelog.md');
|
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('bugs', 'https://github.com/Schneegans/Burn-My-Windows/issues');
|
||||||
addAction('donate-paypal', 'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
|
addAction('donate-paypal', 'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
|
||||||
addAction('donate-github', 'https://github.com/sponsors/Schneegans');
|
addAction('donate-github', 'https://github.com/sponsors/Schneegans');
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
}
|
||||||
|
|
||||||
window.insert_action_group('prefs', group);
|
// Populate the close-effects drop-down menu.
|
||||||
|
{
|
||||||
|
const group = Gio.SimpleActionGroup.new();
|
||||||
|
window.insert_action_group('close-effects', group);
|
||||||
|
|
||||||
|
const menu = this._builder.get_object('close-effect-menu');
|
||||||
|
|
||||||
|
this._effects.forEach(effect => {
|
||||||
|
const prefix = effect.constructor.getSettingsPrefix();
|
||||||
|
const label = effect.constructor.getLabel();
|
||||||
|
|
||||||
|
const action = this._settings.create_action(`${prefix}-close-effect`);
|
||||||
|
group.add_action(action);
|
||||||
|
|
||||||
|
menu.append_item(
|
||||||
|
Gio.MenuItem.new(label, `close-effects.${prefix}-close-effect`));
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// As we do not have something like a destructor, we just listen for the destroy
|
// As we do not have something like a destructor, we just listen for the destroy
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
|
|
||||||
|
<menu id="close-effect-menu"></menu>
|
||||||
|
|
||||||
<object class="GtkBox" id="general-prefs">
|
<object class="GtkBox" id="general-prefs">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="margin-start">60</property>
|
<property name="margin-start">60</property>
|
||||||
@@ -54,21 +56,8 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkMenuButton" id="close-effect-button">
|
<object class="GtkMenuButton" id="close-effect-button">
|
||||||
<property name="label">Effects</property>
|
<property name="label">Choose Effects</property>
|
||||||
</object>
|
<property name="menu-model">close-effect-menu</property>
|
||||||
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
|
|
||||||
|
<menu id="close-effect-menu"></menu>
|
||||||
|
|
||||||
<object class="GtkBox" id="general-prefs">
|
<object class="GtkBox" id="general-prefs">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="margin-start">60</property>
|
<property name="margin-start">60</property>
|
||||||
@@ -54,16 +56,8 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkMenuButton" id="close-effect-button">
|
<object class="GtkMenuButton" id="close-effect-button">
|
||||||
<property name="label">Effects</property>
|
<property name="label">Choose Effects</property>
|
||||||
</object>
|
<property name="menu-model">close-effect-menu</property>
|
||||||
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
+14
-10
@@ -25,6 +25,20 @@ const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
|
|||||||
|
|
||||||
var FirePage = class FirePage extends PrefsPage {
|
var FirePage = class FirePage extends PrefsPage {
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------- static methods
|
||||||
|
|
||||||
|
static getMinShellVersion() {
|
||||||
|
return [3, 36];
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSettingsPrefix() {
|
||||||
|
return 'fire';
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLabel() {
|
||||||
|
return 'Fire';
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ constructor / destructor
|
// ------------------------------------------------------------ constructor / destructor
|
||||||
|
|
||||||
constructor(settings, builder) {
|
constructor(settings, builder) {
|
||||||
@@ -60,16 +74,6 @@ var FirePage = class FirePage extends PrefsPage {
|
|||||||
stack.add_titled(this._builder.get_object('fire-prefs'), 'fire', 'Fire');
|
stack.add_titled(this._builder.get_object('fire-prefs'), 'fire', 'Fire');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------- public methods
|
|
||||||
|
|
||||||
getEnabledKey() {
|
|
||||||
return 'fire-close-effect';
|
|
||||||
}
|
|
||||||
|
|
||||||
getAnimationTime() {
|
|
||||||
return this._settings.get_int('fire-animation-time');
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- private stuff
|
// ----------------------------------------------------------------------- private stuff
|
||||||
|
|
||||||
// This populates the preset dropdown menu for the fire options.
|
// This populates the preset dropdown menu for the fire options.
|
||||||
|
|||||||
+14
-14
@@ -23,15 +23,25 @@ const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
|
|||||||
|
|
||||||
var MatrixPage = class MatrixPage extends PrefsPage {
|
var MatrixPage = class MatrixPage extends PrefsPage {
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------- static methods
|
||||||
|
|
||||||
|
static getMinShellVersion() {
|
||||||
|
return [40, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSettingsPrefix() {
|
||||||
|
return 'matrix';
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLabel() {
|
||||||
|
return 'Matrix';
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ constructor / destructor
|
// ------------------------------------------------------------ constructor / destructor
|
||||||
|
|
||||||
constructor(settings, builder) {
|
constructor(settings, builder) {
|
||||||
super(settings, builder);
|
super(settings, builder);
|
||||||
|
|
||||||
if (!utils.shellVersionIsAtLeast(40, 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._builder.add_from_resource('/ui/gtk4/matrixPage.ui');
|
this._builder.add_from_resource('/ui/gtk4/matrixPage.ui');
|
||||||
|
|
||||||
// Bind all properties.
|
// Bind all properties.
|
||||||
@@ -44,14 +54,4 @@ var MatrixPage = class MatrixPage extends PrefsPage {
|
|||||||
const stack = this._builder.get_object('main-stack');
|
const stack = this._builder.get_object('main-stack');
|
||||||
stack.add_titled(this._builder.get_object('matrix-prefs'), 'matrix', 'Matrix');
|
stack.add_titled(this._builder.get_object('matrix-prefs'), 'matrix', 'Matrix');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------- public methods
|
|
||||||
|
|
||||||
getEnabledKey() {
|
|
||||||
return 'matrix-close-effect';
|
|
||||||
}
|
|
||||||
|
|
||||||
getAnimationTime() {
|
|
||||||
return this._settings.get_int('matrix-animation-time');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+14
-14
@@ -23,15 +23,25 @@ const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
|
|||||||
|
|
||||||
var TRexPage = class TRexPage extends PrefsPage {
|
var TRexPage = class TRexPage extends PrefsPage {
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------- static methods
|
||||||
|
|
||||||
|
static getMinShellVersion() {
|
||||||
|
return [40, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSettingsPrefix() {
|
||||||
|
return 'trex';
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLabel() {
|
||||||
|
return 'T-Rex Attack';
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ constructor / destructor
|
// ------------------------------------------------------------ constructor / destructor
|
||||||
|
|
||||||
constructor(settings, builder) {
|
constructor(settings, builder) {
|
||||||
super(settings, builder);
|
super(settings, builder);
|
||||||
|
|
||||||
if (!utils.shellVersionIsAtLeast(40, 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._builder.add_from_resource('/ui/gtk4/trexPage.ui');
|
this._builder.add_from_resource('/ui/gtk4/trexPage.ui');
|
||||||
|
|
||||||
// Bind all properties.
|
// Bind all properties.
|
||||||
@@ -44,14 +54,4 @@ var TRexPage = class TRexPage extends PrefsPage {
|
|||||||
const stack = this._builder.get_object('main-stack');
|
const stack = this._builder.get_object('main-stack');
|
||||||
stack.add_titled(this._builder.get_object('trex-prefs'), 'trex', 'T-Rex Attack');
|
stack.add_titled(this._builder.get_object('trex-prefs'), 'trex', 'T-Rex Attack');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------- public methods
|
|
||||||
|
|
||||||
getEnabledKey() {
|
|
||||||
return 'trex-close-effect';
|
|
||||||
}
|
|
||||||
|
|
||||||
getAnimationTime() {
|
|
||||||
return this._settings.get_int('trex-animation-time');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+14
-10
@@ -23,6 +23,20 @@ const PrefsPage = Me.imports.src.prefs.PrefsPage.PrefsPage;
|
|||||||
|
|
||||||
var TVEffectPage = class TVEffectPage extends PrefsPage {
|
var TVEffectPage = class TVEffectPage extends PrefsPage {
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------- static methods
|
||||||
|
|
||||||
|
static getMinShellVersion() {
|
||||||
|
return [3, 36];
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSettingsPrefix() {
|
||||||
|
return 'tv';
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLabel() {
|
||||||
|
return 'TV Effect';
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ constructor / destructor
|
// ------------------------------------------------------------ constructor / destructor
|
||||||
|
|
||||||
constructor(settings, builder) {
|
constructor(settings, builder) {
|
||||||
@@ -37,14 +51,4 @@ var TVEffectPage = class TVEffectPage extends PrefsPage {
|
|||||||
const stack = this._builder.get_object('main-stack');
|
const stack = this._builder.get_object('main-stack');
|
||||||
stack.add_titled(this._builder.get_object('tv-prefs'), 'tv', 'TV Effect');
|
stack.add_titled(this._builder.get_object('tv-prefs'), 'tv', 'TV Effect');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------- public methods
|
|
||||||
|
|
||||||
getEnabledKey() {
|
|
||||||
return 'tv-close-effect';
|
|
||||||
}
|
|
||||||
|
|
||||||
getAnimationTime() {
|
|
||||||
return this._settings.get_int('tv-animation-time');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user