🔀 Merge pull request #346 from Schneegans/feature/support-dialog
This commit is contained in:
@@ -9,6 +9,10 @@ SPDX-License-Identifier: CC-BY-4.0
|
|||||||
|
|
||||||
**Release Date:** TBD
|
**Release Date:** TBD
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
- When opening the preferences, a dialog is now shown occasionally to kindly ask for a donation. The dialog can be disabled once it has been shown for the first time.
|
||||||
|
|
||||||
#### Bug Fixes
|
#### Bug Fixes
|
||||||
|
|
||||||
- Fixed an issue on GNOME 44.2 which caused the effects to look broken. It was caused by [this change](https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2650).
|
- Fixed an issue on GNOME 44.2 which caused the effects to look broken. It was caused by [this change](https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2650).
|
||||||
|
|||||||
@@ -394,6 +394,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.
|
// Populate the menu with actions.
|
||||||
const group = Gio.SimpleActionGroup.new();
|
const group = Gio.SimpleActionGroup.new();
|
||||||
window.insert_action_group('prefs', group);
|
window.insert_action_group('prefs', group);
|
||||||
@@ -592,56 +641,38 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
// This action shows a confirmation dialog. Upon user approval, the currently
|
// 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
|
// active profile is deleted. We use the more beautiful Adw.MessageDialog if it is
|
||||||
// available (usually on GNOME 43 and beyond).
|
// available (usually on GNOME 43 and beyond).
|
||||||
let deleteProfileDialog;
|
const deleteProfileDialog = this._createMessageDialog(
|
||||||
const dialogTitle = _('Delete this Profile?');
|
_('Delete this Profile?'),
|
||||||
const dialogSubtitle = _(
|
_('The current effect profile with all its effect settings will be permanently lost.'),
|
||||||
'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) {
|
// Delete the currently active profile.
|
||||||
deleteProfileDialog =
|
this._profileManager.deleteProfile(this._activeProfile.path);
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isGTK4()) {
|
// Select another one.
|
||||||
deleteProfileDialog.set_hide_on_close(true);
|
this._settings.set_string('active-profile',
|
||||||
}
|
this._profileManager.getProfiles()[0].path);
|
||||||
|
|
||||||
deleteProfileDialog.set_transient_for(window);
|
// The number of profiles has changed, so we have to update the profile
|
||||||
|
// selection menu.
|
||||||
deleteProfileDialog.connect('response', (dialog, response) => {
|
this._updateProfileMenu();
|
||||||
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// This action deletes the currently active profile.
|
||||||
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
|
const deleteProfileAction = Gio.SimpleAction.new('profile-delete', null);
|
||||||
deleteProfileAction.connect('activate', () => {
|
deleteProfileAction.connect('activate', () => {
|
||||||
deleteProfileDialog.show();
|
deleteProfileDialog.show();
|
||||||
@@ -974,6 +1005,77 @@ var PreferencesDialog = class PreferencesDialog {
|
|||||||
window.show_all();
|
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.
|
// This is used for setting up the translations.
|
||||||
|
|||||||
@@ -43,6 +43,18 @@ SPDX-License-Identifier: CC0-1.0
|
|||||||
<description>Used to check whether the extension got updated from the extension side.</description>
|
<description>Used to check whether the extension got updated from the extension side.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="prefs-open-count" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Prefs Open Count</summary>
|
||||||
|
<description>The number of times the settings dialog was openend.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="show-support-dialog" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Show Support Dialog</summary>
|
||||||
|
<description>If set to false, the ask-for-support dialog will never be shown.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
</schemalist>
|
</schemalist>
|
||||||
Reference in New Issue
Block a user