[gnome-software/1021-please-add-a-way-to-show-only-open-source-apps: 9/11] gs-prefs-dialog: Add 'show-only-free-apps' setting
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1021-please-add-a-way-to-show-only-open-source-apps: 9/11] gs-prefs-dialog: Add 'show-only-free-apps' setting
- Date: Tue, 11 Oct 2022 15:42:42 +0000 (UTC)
commit 1be4b43587bb264e35da2176bf315ddfb620e17f
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 10 14:48:04 2022 +0200
gs-prefs-dialog: Add 'show-only-free-apps' setting
Add the `show-only-free-apps` setting into the GUI.
src/gs-prefs-dialog.c | 18 ++++++++++++++++++
src/gs-prefs-dialog.ui | 15 ++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-prefs-dialog.c b/src/gs-prefs-dialog.c
index df49aa034..3ae77e8a8 100644
--- a/src/gs-prefs-dialog.c
+++ b/src/gs-prefs-dialog.c
@@ -25,12 +25,20 @@ struct _GsPrefsDialog
GsPluginLoader *plugin_loader;
GtkWidget *switch_updates;
GtkWidget *switch_updates_notify;
+ GtkWidget *switch_free_apps;
AdwActionRow *automatic_updates_row;
AdwActionRow *automatic_update_notifications_row;
+ AdwActionRow *show_only_free_apps_row;
};
G_DEFINE_TYPE (GsPrefsDialog, gs_prefs_dialog, ADW_TYPE_PREFERENCES_WINDOW)
+static void
+gs_prefs_dialog_show_only_free_apps_changed_cb (GsPrefsDialog *self)
+{
+ g_signal_emit_by_name (self->plugin_loader, "reload", 0);
+}
+
static void
gs_prefs_dialog_dispose (GObject *object)
{
@@ -60,10 +68,18 @@ gs_prefs_dialog_init (GsPrefsDialog *dialog)
dialog->switch_updates,
"active",
G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (dialog->settings,
+ "show-only-free-apps",
+ dialog->switch_free_apps,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect_object (dialog->switch_free_apps, "notify::active",
+ G_CALLBACK (gs_prefs_dialog_show_only_free_apps_changed_cb), dialog,
G_CONNECT_SWAPPED);
#if ADW_CHECK_VERSION(1,2,0)
adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (dialog->automatic_updates_row), FALSE);
adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (dialog->automatic_update_notifications_row),
FALSE);
+ adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (dialog->show_only_free_apps_row), FALSE);
#endif
}
@@ -78,8 +94,10 @@ gs_prefs_dialog_class_init (GsPrefsDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-prefs-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, switch_updates);
gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, switch_updates_notify);
+ gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, switch_free_apps);
gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, automatic_updates_row);
gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog,
automatic_update_notifications_row);
+ gtk_widget_class_bind_template_child (widget_class, GsPrefsDialog, show_only_free_apps_row);
}
GtkWidget *
diff --git a/src/gs-prefs-dialog.ui b/src/gs-prefs-dialog.ui
index 3fcb8c1bd..afb83186a 100644
--- a/src/gs-prefs-dialog.ui
+++ b/src/gs-prefs-dialog.ui
@@ -4,7 +4,7 @@
<template class="GsPrefsDialog" parent="AdwPreferencesWindow">
<property name="title" translatable="yes">Update Preferences</property>
<property name="default_width">610</property>
- <property name="default_height">300</property>
+ <property name="default_height">370</property>
<property name="search_enabled">False</property>
<style>
<class name="update-preferences"/>
@@ -40,6 +40,19 @@
</child>
</object>
</child>
+ <child>
+ <object class="AdwActionRow" id="show_only_free_apps_row">
+ <property name="title" translatable="yes">Show Only Free Apps</property>
+ <property name="subtitle" translatable="yes">Show only freely licensed apps and hide any
proprietary apps.</property>
+ <property name="subtitle_lines">0</property>
+ <property name="activatable_widget">switch_free_apps</property>
+ <child>
+ <object class="GtkSwitch" id="switch_free_apps">
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]