From f4babe7575af0764f04f38516fe4e41145df122d Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 20:41:15 +0200 Subject: [PATCH 01/13] :tada: Add a dialog to ask for support --- prefs.js | 19 +++++++++++ resources/ui/adw/prefs.ui | 34 +++++++++++++++++++ ...ell.extensions.burn-my-windows.gschema.xml | 12 +++++++ 3 files changed, 65 insertions(+) diff --git a/prefs.js b/prefs.js index 82d7614..a997d24 100644 --- a/prefs.js +++ b/prefs.js @@ -394,6 +394,25 @@ 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._builder.get_object('support-dialog'); + dialog.set_transient_for(window); + dialog.connect('response', (dialog, response) => { + if (response === 'never') { + this._settings.set_boolean('show-support-dialog', false); + } + }); + dialog.show(); + } + } + // Populate the menu with actions. const group = Gio.SimpleActionGroup.new(); window.insert_action_group('prefs', group); diff --git a/resources/ui/adw/prefs.ui b/resources/ui/adw/prefs.ui index 40e9858..cc4cf19 100644 --- a/resources/ui/adw/prefs.ui +++ b/resources/ui/adw/prefs.ui @@ -37,6 +37,40 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + 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! + later + later + + Do not show this again! + Maybe later... + + + + vertical + + + true + start + true + Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> + + + + + true + start + true + Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> + + + + + + + vertical natural diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml index 50fd50e..844fc0e 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -43,6 +43,18 @@ SPDX-License-Identifier: CC0-1.0 Used to check whether the extension got updated from the extension side. + + 0 + Prefs Open Count + The number of times the settings dialog was openend. + + + + true + Show Support Dialog + If set to false, the ask-for-support dialog will never be shown. + + \ No newline at end of file From 106ed964d5db3b605856d60a3d138f6be27b42ad Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 20:44:16 +0200 Subject: [PATCH 02/13] :memo: Add changelog entry --- docs/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index effac63..b484440 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -9,6 +9,10 @@ SPDX-License-Identifier: CC-BY-4.0 **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 - 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). From d89be65fe3a2a0c8d4a1e493a94ca673ec706d09 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 21:51:33 +0200 Subject: [PATCH 03/13] :wrench: Add support dialog for GTK3 and GTK4 --- prefs.js | 7 +++++- resources/ui/gtk3/prefs.ui | 49 ++++++++++++++++++++++++++++++++++++++ resources/ui/gtk4/prefs.ui | 49 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/prefs.js b/prefs.js index a997d24..f389e74 100644 --- a/prefs.js +++ b/prefs.js @@ -405,9 +405,14 @@ var PreferencesDialog = class PreferencesDialog { const dialog = this._builder.get_object('support-dialog'); dialog.set_transient_for(window); dialog.connect('response', (dialog, response) => { - if (response === 'never') { + if ((utils.isADW() && response === 'never') || + (!utils.isADW() && response === 2)) { this._settings.set_boolean('show-support-dialog', false); } + + if (!utils.isGTK4()) { + dialog.close(); + } }); dialog.show(); } diff --git a/resources/ui/gtk3/prefs.ui b/resources/ui/gtk3/prefs.ui index badce07..9b455e3 100644 --- a/resources/ui/gtk3/prefs.ui +++ b/resources/ui/gtk3/prefs.ui @@ -67,6 +67,55 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + 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! + true + + + + + + + true + start + true + Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> + + + + + true + start + true + Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> + + + + + + + + + Do not show this again! + + + + + Maybe later... + + + + + + + + support_later_button + support_never_button + + + over-down-up diff --git a/resources/ui/gtk4/prefs.ui b/resources/ui/gtk4/prefs.ui index 9c1d507..c362bc8 100644 --- a/resources/ui/gtk4/prefs.ui +++ b/resources/ui/gtk4/prefs.ui @@ -33,6 +33,55 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + 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! + true + + + + + + + true + start + true + Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> + + + + + true + start + true + Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> + + + + + + + + + Do not show this again! + + + + + Maybe later... + + + + + + + + support_later_button + support_never_button + + + over-down-up From b8759174f8a3003b7d897d9e15a927ceead18962 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 21:53:00 +0200 Subject: [PATCH 04/13] :beetle: Show dialog on GTK3 --- prefs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prefs.js b/prefs.js index f389e74..f19c319 100644 --- a/prefs.js +++ b/prefs.js @@ -414,7 +414,12 @@ var PreferencesDialog = class PreferencesDialog { dialog.close(); } }); - dialog.show(); + + if (utils.isGTK4()) { + dialog.show(); + } else { + dialog.show_all(); + } } } From 78d4e799251bbf3e1188035d6fbf20e22824ec5f Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 21:58:52 +0200 Subject: [PATCH 05/13] :beetle: Fix support dialog on GTK4 --- prefs.js | 2 +- resources/ui/gtk4/prefs.ui | 58 ++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/prefs.js b/prefs.js index f19c319..7f0dcd1 100644 --- a/prefs.js +++ b/prefs.js @@ -410,7 +410,7 @@ var PreferencesDialog = class PreferencesDialog { this._settings.set_boolean('show-support-dialog', false); } - if (!utils.isGTK4()) { + if (!utils.isADW()) { dialog.close(); } }); diff --git a/resources/ui/gtk4/prefs.ui b/resources/ui/gtk4/prefs.ui index c362bc8..ffad045 100644 --- a/resources/ui/gtk4/prefs.ui +++ b/resources/ui/gtk4/prefs.ui @@ -38,40 +38,36 @@ SPDX-License-Identifier: GPL-3.0-or-later 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! true - + - - - - - true - start - true - Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> - - - - - true - start - true - Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> - - + + + true + start + true + Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> - - - - - Do not show this again! - - - - - Maybe later... - - + + + true + start + true + Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> + + + + + + + + + Do not show this again! + + + + + Maybe later... From 6cc26d0dbc31c4f9f7dd3507da7165663b6abc73 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 06:03:59 +0200 Subject: [PATCH 06/13] :wrench: Show support dialog programmatically --- prefs.js | 179 ++++++++++++++++++++++++------------- resources/ui/adw/prefs.ui | 34 ------- resources/ui/gtk3/prefs.ui | 49 ---------- resources/ui/gtk4/prefs.ui | 45 ---------- 4 files changed, 117 insertions(+), 190 deletions(-) diff --git a/prefs.js b/prefs.js index 7f0dcd1..235952f 100644 --- a/prefs.js +++ b/prefs.js @@ -401,26 +401,35 @@ var PreferencesDialog = class PreferencesDialog { 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._builder.get_object('support-dialog'); - dialog.set_transient_for(window); - dialog.connect('response', (dialog, response) => { - if ((utils.isADW() && response === 'never') || - (!utils.isADW() && response === 2)) { - this._settings.set_boolean('show-support-dialog', false); - } + // 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! - if (!utils.isADW()) { - dialog.close(); +Ko-fi: https://ko-fi.com/schneegans +GitHub: https://github.com/sponsors/schneegans`, + 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(); - } + if (utils.isGTK4()) { + dialog.show(); + } else { + dialog.show_all(); } + // } } // Populate the menu with actions. @@ -621,56 +630,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(); @@ -1003,6 +994,70 @@ var PreferencesDialog = class PreferencesDialog { window.show_all(); } } + + _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); + + 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. diff --git a/resources/ui/adw/prefs.ui b/resources/ui/adw/prefs.ui index cc4cf19..40e9858 100644 --- a/resources/ui/adw/prefs.ui +++ b/resources/ui/adw/prefs.ui @@ -37,40 +37,6 @@ SPDX-License-Identifier: GPL-3.0-or-later - - - 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! - later - later - - Do not show this again! - Maybe later... - - - - vertical - - - true - start - true - Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> - - - - - true - start - true - Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> - - - - - - - vertical natural diff --git a/resources/ui/gtk3/prefs.ui b/resources/ui/gtk3/prefs.ui index 9b455e3..badce07 100644 --- a/resources/ui/gtk3/prefs.ui +++ b/resources/ui/gtk3/prefs.ui @@ -67,55 +67,6 @@ SPDX-License-Identifier: GPL-3.0-or-later - - - 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! - true - - - - - - - true - start - true - Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> - - - - - true - start - true - Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> - - - - - - - - - Do not show this again! - - - - - Maybe later... - - - - - - - - support_later_button - support_never_button - - - over-down-up diff --git a/resources/ui/gtk4/prefs.ui b/resources/ui/gtk4/prefs.ui index ffad045..9c1d507 100644 --- a/resources/ui/gtk4/prefs.ui +++ b/resources/ui/gtk4/prefs.ui @@ -33,51 +33,6 @@ SPDX-License-Identifier: GPL-3.0-or-later - - - 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! - true - - - - - true - start - true - Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a> - - - - - true - start - true - Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a> - - - - - - - - - Do not show this again! - - - - - Maybe later... - - - - - - support_later_button - support_never_button - - - over-down-up From 2e20bc8753de72f2fd8a2e90add9b5e35ecca5b7 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 07:32:58 +0200 Subject: [PATCH 07/13] :wrench: Use map event to show the support dialog --- prefs.js | 79 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/prefs.js b/prefs.js index 235952f..c16b2a8 100644 --- a/prefs.js +++ b/prefs.js @@ -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: https://ko-fi.com/schneegans -GitHub: https://github.com/sponsors/schneegans`, - 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. const group = Gio.SimpleActionGroup.new(); window.insert_action_group('prefs', group); @@ -670,6 +632,47 @@ GitHub: 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: https://ko-fi.com/schneegans +GitHub: https://github.com/sponsors/schneegans`, + 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 // signal of our main widget. this._widget.connect('destroy', () => { From 154b5bec32e7e4d5325c7ff17b649ae95a855dcb Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 07:44:30 +0200 Subject: [PATCH 08/13] :wrench: Use notify::visible event to show the support dialog --- prefs.js | 89 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/prefs.js b/prefs.js index c16b2a8..f60f6af 100644 --- a/prefs.js +++ b/prefs.js @@ -394,6 +394,54 @@ 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); + + // 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: https://ko-fi.com/schneegans +GitHub: https://github.com/sponsors/schneegans`, + 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. const group = Gio.SimpleActionGroup.new(); window.insert_action_group('prefs', group); @@ -632,47 +680,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. - 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: https://ko-fi.com/schneegans -GitHub: https://github.com/sponsors/schneegans`, - 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 // signal of our main widget. this._widget.connect('destroy', () => { From d936717ac0dec61a7b483f2dc4be0279b6c55ec7 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 08:33:17 +0200 Subject: [PATCH 09/13] :wrench: Improve wording of the support-dialog --- prefs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prefs.js b/prefs.js index f60f6af..020269a 100644 --- a/prefs.js +++ b/prefs.js @@ -413,8 +413,8 @@ var PreferencesDialog = class PreferencesDialog { // 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! + '❤️ 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: https://ko-fi.com/schneegans GitHub: https://github.com/sponsors/schneegans`, @@ -428,7 +428,7 @@ GitHub: https://github.com/spon } }, { - label: 'Maybe later...', + label: 'Remind me later.', destructive: false, default: true, } From 4a747602d9437090fc0c233df86e0dbd854c5edb Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 08:33:48 +0200 Subject: [PATCH 10/13] :wrench: Only show the support dialog every tenth time --- prefs.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/prefs.js b/prefs.js index 020269a..82c0754 100644 --- a/prefs.js +++ b/prefs.js @@ -411,35 +411,35 @@ var PreferencesDialog = class PreferencesDialog { 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 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! + 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: https://ko-fi.com/schneegans GitHub: https://github.com/sponsors/schneegans`, - window, [ - { - label: 'Do not show this again!', - destructive: true, - default: false, - action: () => { - this._settings.set_boolean('show-support-dialog', false); + 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, } - }, - { - label: 'Remind me later.', - destructive: false, - default: true, - } - ]); + ]); - if (utils.isGTK4()) { - dialog.show(); - } else { - dialog.show_all(); + if (utils.isGTK4()) { + dialog.show(); + } else { + dialog.show_all(); + } } - // } }); // Populate the menu with actions. From e450e619e6541ad777f7c9e47954d9edb0f2c16c Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 08:35:12 +0200 Subject: [PATCH 11/13] :wrench: Use burning heart emoji --- prefs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prefs.js b/prefs.js index 82c0754..c0043bf 100644 --- a/prefs.js +++ b/prefs.js @@ -413,7 +413,7 @@ var PreferencesDialog = class PreferencesDialog { if (count % 10 == 0) { const dialog = this._createMessageDialog( - '❤️ Do you love Burn-My-Windows?', + '❤️‍🔥 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: https://ko-fi.com/schneegans From a585da93a83573bf012673a94d933de69c2c83ea Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 08:36:43 +0200 Subject: [PATCH 12/13] :wrench: Revert to heart emoji as the burning emoji does not work on GTK3 --- prefs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prefs.js b/prefs.js index c0043bf..82c0754 100644 --- a/prefs.js +++ b/prefs.js @@ -413,7 +413,7 @@ var PreferencesDialog = class PreferencesDialog { if (count % 10 == 0) { const dialog = this._createMessageDialog( - '❤️‍🔥 Do you love Burn-My-Windows?', + '❤️ 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: https://ko-fi.com/schneegans From 0c58b507d8fe71743c7f3b133405f1f8d55fd25d Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Tue, 6 Jun 2023 08:47:23 +0200 Subject: [PATCH 13/13] :memo: Add some comments --- prefs.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prefs.js b/prefs.js index 82c0754..7c0ad56 100644 --- a/prefs.js +++ b/prefs.js @@ -411,6 +411,7 @@ var PreferencesDialog = class PreferencesDialog { 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?', @@ -1005,6 +1006,11 @@ GitHub: https://github.com/spon } } + // 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; @@ -1055,6 +1061,8 @@ GitHub: https://github.com/spon 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);