[gnome-software/1021-please-add-a-way-to-show-only-open-source-apps: 11/11] gs-plugin-job-list-apps: Filter only free apps when set to
- 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: 11/11] gs-plugin-job-list-apps: Filter only free apps when set to
- Date: Tue, 11 Oct 2022 15:42:42 +0000 (UTC)
commit cadce388ba3f856cd2c84cd5a089ff783cad311b
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 10 15:17:12 2022 +0200
gs-plugin-job-list-apps: Filter only free apps when set to
When the user asks to see only free apps, filter out the proprietary
apps from the resulting list, unless they are already installed.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1021
lib/gs-plugin-job-list-apps.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/lib/gs-plugin-job-list-apps.c b/lib/gs-plugin-job-list-apps.c
index a556387e5..398771bfc 100644
--- a/lib/gs-plugin-job-list-apps.c
+++ b/lib/gs-plugin-job-list-apps.c
@@ -149,6 +149,20 @@ filter_valid_apps (GsApp *app,
return gs_plugin_loader_app_is_valid (app, refine_flags);
}
+static gboolean
+filter_freely_licensed_apps (GsApp *app,
+ gpointer user_data)
+{
+ return (gs_app_get_kind (app) != AS_COMPONENT_KIND_GENERIC &&
+ gs_app_get_kind (app) != AS_COMPONENT_KIND_DESKTOP_APP &&
+ gs_app_get_kind (app) != AS_COMPONENT_KIND_CONSOLE_APP &&
+ gs_app_get_kind (app) != AS_COMPONENT_KIND_WEB_APP) ||
+ gs_app_get_state (app) == GS_APP_STATE_INSTALLED ||
+ gs_app_get_state (app) == GS_APP_STATE_UPDATABLE ||
+ gs_app_get_state (app) == GS_APP_STATE_UPDATABLE_LIVE ||
+ gs_app_get_license_is_free (app);
+}
+
static gboolean
app_filter_qt_for_gtk_and_compatible (GsApp *app,
gpointer user_data)
@@ -303,6 +317,14 @@ finish_op (GTask *task,
if (self->query != NULL)
refine_flags = gs_app_query_get_refine_flags (self->query);
+ if ((refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE) == 0) {
+ g_autoptr(GSettings) settings = NULL;
+
+ settings = g_settings_new ("org.gnome.software");
+ if (g_settings_get_boolean (settings, "show-only-free-apps"))
+ refine_flags |= GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE;
+ }
+
if (merged_list != NULL &&
gs_app_list_length (merged_list) > 0 &&
refine_flags != GS_PLUGIN_REFINE_FLAGS_NONE) {
@@ -352,6 +374,7 @@ finish_task (GTask *task,
gpointer sort_func_data = NULL;
GsAppListFilterFunc filter_func = NULL;
gpointer filter_func_data = NULL;
+ g_autoptr(GSettings) settings = NULL;
guint max_results = 0;
g_autofree gchar *job_debug = NULL;
@@ -361,6 +384,10 @@ finish_task (GTask *task,
gs_app_list_filter (merged_list, filter_valid_apps, self);
gs_app_list_filter (merged_list, app_filter_qt_for_gtk_and_compatible, plugin_loader);
+ settings = g_settings_new ("org.gnome.software");
+ if (g_settings_get_boolean (settings, "show-only-free-apps"))
+ gs_app_list_filter (merged_list, filter_freely_licensed_apps, self);
+
/* Caller-specified filtering. */
if (self->query != NULL)
filter_func = gs_app_query_get_filter_func (self->query, &filter_func_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]