🎉 Add a dialog to ask for support

This commit is contained in:
Simon Schneegans
2023-06-05 20:41:15 +02:00
parent fff39f66a8
commit f4babe7575
3 changed files with 65 additions and 0 deletions
+19
View File
@@ -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. // 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);
+34
View File
@@ -37,6 +37,40 @@ SPDX-License-Identifier: GPL-3.0-or-later
</style> </style>
</object> </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: &lt;a href='https://ko-fi.com/schneegans'&gt;https://ko-fi.com/schneegans&lt;/a&gt;</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: &lt;a href='https://github.com/sponsors/schneegans'&gt;https://github.com/sponsors/schneegans&lt;/a&gt;</property>
</object>
</child>
</object>
</property>
</object>
<object class="AdwFlap" id="profile-editor-flap"> <object class="AdwFlap" id="profile-editor-flap">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="fold-threshold-policy">natural</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> <description>Used to check whether the extension got updated from the extension side.</description>
</key> </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> </schema>
</schemalist> </schemalist>