From f4babe7575af0764f04f38516fe4e41145df122d Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 5 Jun 2023 20:41:15 +0200 Subject: [PATCH] :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