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', () => {