🎉 Add a dialog to ask for support
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -37,6 +37,40 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</style>
|
||||
</object>
|
||||
|
||||
<!-- This dialog is occasionaly shown to ask the user for support. -->
|
||||
<object class="AdwMessageDialog" id="support-dialog">
|
||||
<property name="heading">Do you want to support Burn-My-Windows?</property>
|
||||
<property name="body">If only one out of ten users would support this project with 1$ / month, I could work full-time on open-source projects!</property>
|
||||
<property name="default-response">later</property>
|
||||
<property name="close-response">later</property>
|
||||
<responses>
|
||||
<response id="never" appearance="destructive">Do not show this again!</response>
|
||||
<response id="later">Maybe later...</response>
|
||||
</responses>
|
||||
<property name="extra-child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="use-markup">true</property>
|
||||
<property name="label">Support me on Ko-fi: <a href='https://ko-fi.com/schneegans'>https://ko-fi.com/schneegans</a></property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="use-markup">true</property>
|
||||
<property name="label">Support me on GitHub: <a href='https://github.com/sponsors/schneegans'>https://github.com/sponsors/schneegans</a></property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
</object>
|
||||
|
||||
<object class="AdwFlap" id="profile-editor-flap">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="fold-threshold-policy">natural</property>
|
||||
|
||||
@@ -43,6 +43,18 @@ SPDX-License-Identifier: CC0-1.0
|
||||
<description>Used to check whether the extension got updated from the extension side.</description>
|
||||
</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>
|
||||
|
||||
</schemalist>
|
||||
Reference in New Issue
Block a user