Merge branch 'main' into feature/magic-lamp
This commit is contained in:
@@ -57,6 +57,7 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
new Me.imports.src.effects.Incinerate.Incinerate(),
|
||||
new Me.imports.src.effects.MagicLamp.MagicLamp(),
|
||||
new Me.imports.src.effects.Matrix.Matrix(),
|
||||
new Me.imports.src.effects.PaintBrush.PaintBrush(),
|
||||
new Me.imports.src.effects.Pixelate.Pixelate(),
|
||||
new Me.imports.src.effects.PixelWheel.PixelWheel(),
|
||||
new Me.imports.src.effects.PixelWipe.PixelWipe(),
|
||||
@@ -228,8 +229,16 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
const [minMajor, minMinor] = effect.getMinShellVersion();
|
||||
if (utils.shellVersionIsAtLeast(minMajor, minMinor)) {
|
||||
|
||||
const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`;
|
||||
const [hasPrefs] = Gio.resources_get_info(uiFile, 0);
|
||||
const uiFile = `/ui/${utils.getUIDir()}/${effect.getNick()}.ui`;
|
||||
|
||||
// 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.
|
||||
if (hasPrefs) {
|
||||
@@ -289,9 +298,11 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
}
|
||||
});
|
||||
this._effectRows.push(row);
|
||||
row.add_action(previewButton);
|
||||
} else {
|
||||
row.add_suffix(previewButton);
|
||||
}
|
||||
|
||||
row.add_action(previewButton);
|
||||
row.add_prefix(button);
|
||||
|
||||
group.add(row);
|
||||
@@ -385,6 +396,55 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
});
|
||||
}
|
||||
|
||||
// Count the number of times the user has opened the preferences window. Every now
|
||||
// and then, we show a dialog asking the user to support the extension. We connect
|
||||
// to the notify::visible signal to ensure that the dialog can be a modal dialog.
|
||||
window.connect('notify::visible', (window) => {
|
||||
// Do not show the dialog when the window is hidden.
|
||||
if (!window.get_visible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not show the dialog when the user has disabled it.
|
||||
if (!this._settings.get_boolean('show-support-dialog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const count = this._settings.get_int('prefs-open-count') + 1;
|
||||
this._settings.set_int('prefs-open-count', count);
|
||||
|
||||
// Show the dialog every 10th time.
|
||||
if (count % 10 == 0) {
|
||||
const dialog = this._createMessageDialog(
|
||||
'❤️ Do you love Burn-My-Windows?',
|
||||
`Even the smallest donation can have a big impact! If just one of ten Burn-My-Windows users donated $1 per month, I could dedicate myself to creating awesome open-source projects full-time!
|
||||
|
||||
Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a>
|
||||
GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a>`,
|
||||
window, [
|
||||
{
|
||||
label: 'Do not show this again!',
|
||||
destructive: true,
|
||||
default: false,
|
||||
action: () => {
|
||||
this._settings.set_boolean('show-support-dialog', false);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Remind me later.',
|
||||
destructive: false,
|
||||
default: true,
|
||||
}
|
||||
]);
|
||||
|
||||
if (utils.isGTK4()) {
|
||||
dialog.show();
|
||||
} else {
|
||||
dialog.show_all();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Populate the menu with actions.
|
||||
const group = Gio.SimpleActionGroup.new();
|
||||
window.insert_action_group('prefs', group);
|
||||
@@ -443,7 +503,7 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
addURIAction('translate', 'https://hosted.weblate.org/engage/burn-my-windows/');
|
||||
addURIAction('donate-kofi', 'https://ko-fi.com/schneegans');
|
||||
addURIAction('donate-github', 'https://github.com/sponsors/Schneegans');
|
||||
addURIAction('donate-paypal', 'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
|
||||
addURIAction('donate-paypal', 'https://www.paypal.me/simonschneegans');
|
||||
addURIAction('wallpapers', 'https://github.com/Schneegans/ai-wallpapers');
|
||||
// clang-format on
|
||||
|
||||
@@ -583,56 +643,38 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
// This action shows a confirmation dialog. Upon user approval, the currently
|
||||
// active profile is deleted. We use the more beautiful Adw.MessageDialog if it is
|
||||
// available (usually on GNOME 43 and beyond).
|
||||
let deleteProfileDialog;
|
||||
const dialogTitle = _('Delete this Profile?');
|
||||
const dialogSubtitle = _(
|
||||
'The current effect profile with all its effect settings will be permanently lost.');
|
||||
const deleteProfileDialog = this._createMessageDialog(
|
||||
_('Delete this Profile?'),
|
||||
_('The current effect profile with all its effect settings will be permanently lost.'),
|
||||
window, [
|
||||
{
|
||||
label: _('Cancel'),
|
||||
destructive: false,
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
label: _('Delete'),
|
||||
destructive: true,
|
||||
default: false,
|
||||
action: () => {
|
||||
// Stop editing the current profile.
|
||||
this._builder.get_object('edit-profile-button').active = false;
|
||||
|
||||
if (utils.isADW() && Adw.MessageDialog) {
|
||||
deleteProfileDialog =
|
||||
new Adw.MessageDialog({heading: dialogTitle, body: dialogSubtitle});
|
||||
deleteProfileDialog.add_response('cancel', _('Cancel'));
|
||||
deleteProfileDialog.add_response('delete', _('Delete'));
|
||||
deleteProfileDialog.set_response_appearance('delete',
|
||||
Adw.ResponseAppearance.DESTRUCTIVE);
|
||||
deleteProfileDialog.set_default_response('cancel');
|
||||
deleteProfileDialog.set_close_response('cancel');
|
||||
} else {
|
||||
deleteProfileDialog = new Gtk.MessageDialog({
|
||||
text: dialogTitle,
|
||||
secondary_text: dialogSubtitle,
|
||||
modal: true,
|
||||
title: '',
|
||||
buttons: Gtk.ButtonsType.OK_CANCEL
|
||||
});
|
||||
}
|
||||
// Delete the currently active profile.
|
||||
this._profileManager.deleteProfile(this._activeProfile.path);
|
||||
|
||||
if (utils.isGTK4()) {
|
||||
deleteProfileDialog.set_hide_on_close(true);
|
||||
}
|
||||
// Select another one.
|
||||
this._settings.set_string('active-profile',
|
||||
this._profileManager.getProfiles()[0].path);
|
||||
|
||||
deleteProfileDialog.set_transient_for(window);
|
||||
|
||||
deleteProfileDialog.connect('response', (dialog, response) => {
|
||||
if (response == 'delete' || response == Gtk.ResponseType.OK) {
|
||||
// Stop editing the current profile.
|
||||
this._builder.get_object('edit-profile-button').active = false;
|
||||
|
||||
// Delete the currently active profile.
|
||||
this._profileManager.deleteProfile(this._activeProfile.path);
|
||||
|
||||
// Select another one.
|
||||
this._settings.set_string('active-profile',
|
||||
this._profileManager.getProfiles()[0].path);
|
||||
|
||||
// The number of profiles has changed, so we have to update the profile
|
||||
// selection menu.
|
||||
this._updateProfileMenu();
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
});
|
||||
// The number of profiles has changed, so we have to update the profile
|
||||
// selection menu.
|
||||
this._updateProfileMenu();
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
// This action deletes the currently active profile.
|
||||
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
|
||||
deleteProfileAction.connect('activate', () => {
|
||||
deleteProfileDialog.show();
|
||||
@@ -965,6 +1007,77 @@ var PreferencesDialog = class PreferencesDialog {
|
||||
window.show_all();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to show a message dialog. The dialog is modal and has a title, a
|
||||
// message and a list of buttons. Each button is an object with a label, a default flag
|
||||
// and a destructive flag. Each button object can also have an "action" callback that is
|
||||
// called when the button is clicked.
|
||||
// This method works on GTK3, GTK4, and libadwaita.
|
||||
_createMessageDialog(title, message, window, buttons) {
|
||||
let dialog;
|
||||
|
||||
if (utils.isADW() && Adw.MessageDialog) {
|
||||
dialog = new Adw.MessageDialog({
|
||||
heading: title,
|
||||
body: message,
|
||||
body_use_markup: true,
|
||||
modal: true,
|
||||
});
|
||||
|
||||
buttons.forEach((button, i) => {
|
||||
const response = i.toString();
|
||||
dialog.add_response(response, button.label);
|
||||
|
||||
if (button.default) {
|
||||
dialog.set_default_response(response);
|
||||
dialog.set_close_response(response);
|
||||
}
|
||||
|
||||
if (button.destructive) {
|
||||
dialog.set_response_appearance(response, Adw.ResponseAppearance.DESTRUCTIVE);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
dialog = new Gtk.MessageDialog({
|
||||
text: title,
|
||||
secondary_text: message,
|
||||
secondary_use_markup: true,
|
||||
modal: true,
|
||||
title: '',
|
||||
});
|
||||
|
||||
buttons.forEach((button, i) => {
|
||||
dialog.add_button(button.label, i);
|
||||
|
||||
if (button.default) {
|
||||
dialog.set_default_response(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (utils.isGTK4()) {
|
||||
dialog.set_hide_on_close(true);
|
||||
}
|
||||
|
||||
dialog.set_transient_for(window);
|
||||
|
||||
// If the dialog is closed or a button is clicked, we hide the dialog and call the
|
||||
// button's action callback if it exists.
|
||||
dialog.connect('response', (dialog, response) => {
|
||||
const i = parseInt(response);
|
||||
|
||||
const button = buttons[i];
|
||||
if (button && button.action) {
|
||||
button.action();
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
||||
// This is used for setting up the translations.
|
||||
|
||||
Reference in New Issue
Block a user