🔧 Use map event to show the support dialog

This commit is contained in:
Simon Schneegans
2023-06-06 07:32:58 +02:00
parent 6cc26d0dbc
commit 2e20bc8753
+41 -38
View File
@@ -394,44 +394,6 @@ 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.
const showSupportDialog = this._settings.get_boolean('show-support-dialog');
if (showSupportDialog) {
const count = this._settings.get_int('prefs-open-count') + 1;
this._settings.set_int('prefs-open-count', count);
// if (count % 10 == 0) {
const dialog = this._createMessageDialog(
'Do you want to support Burn-My-Windows?',
`If only one out of ten users would support this project with 1$ / month, I could work full-time on open-source projects!
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: 'Maybe 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);
@@ -670,6 +632,47 @@ GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/spon
} }
}); });
// 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.
this._widget.connect('map', (widget) => {
const showSupportDialog = this._settings.get_boolean('show-support-dialog');
if (showSupportDialog) {
const window = utils.isGTK4() ? widget.get_root() : widget.get_toplevel();
const count = this._settings.get_int('prefs-open-count') + 1;
this._settings.set_int('prefs-open-count', count);
// if (count % 10 == 0) {
const dialog = this._createMessageDialog(
'Do you want to support Burn-My-Windows?',
`If only one out of ten users would support this project with 1$ / month, I could work full-time on open-source projects!
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: 'Maybe later...',
destructive: false,
default: true,
}
]);
if (utils.isGTK4()) {
dialog.show();
} else {
dialog.show_all();
}
// }
}
});
// 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
// signal of our main widget. // signal of our main widget.
this._widget.connect('destroy', () => { this._widget.connect('destroy', () => {