summaryrefslogtreecommitdiffstats
path: root/plugins/core/gs-plugin-hardcoded-popular.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 15:18:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 15:18:46 +0000
commit56294d30a82ec2da6f9ce399740c1ef65a9ddef4 (patch)
treebbe3823e41495d026ba8edc6eeaef166edb7e2a2 /plugins/core/gs-plugin-hardcoded-popular.c
parentInitial commit. (diff)
downloadgnome-software-upstream.tar.xz
gnome-software-upstream.zip
Adding upstream version 3.38.1.upstream/3.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/core/gs-plugin-hardcoded-popular.c')
-rw-r--r--plugins/core/gs-plugin-hardcoded-popular.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/core/gs-plugin-hardcoded-popular.c b/plugins/core/gs-plugin-hardcoded-popular.c
new file mode 100644
index 0000000..2431274
--- /dev/null
+++ b/plugins/core/gs-plugin-hardcoded-popular.c
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+
+#include <gnome-software.h>
+
+void
+gs_plugin_initialize (GsPlugin *plugin)
+{
+ /* let appstream add applications first */
+ gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
+}
+
+gboolean
+gs_plugin_add_popular (GsPlugin *plugin,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ guint i;
+ const gchar *apps[] = {
+ "org.gnome.Builder.desktop",
+ "org.gnome.Calculator.desktop",
+ "org.gnome.clocks.desktop",
+ "org.gnome.Dictionary.desktop",
+ "org.gnome.Documents.desktop",
+ "org.gnome.Evince",
+ "org.gnome.gedit.desktop",
+ "org.gnome.Maps.desktop",
+ "org.gnome.Weather",
+ NULL };
+
+ /* we've already got enough popular apps */
+ if (gs_app_list_length (list) >= 9)
+ return TRUE;
+
+ /* just add all */
+ g_debug ("using hardcoded as only %u apps", gs_app_list_length (list));
+ for (i = 0; apps[i] != NULL; i++) {
+ g_autoptr(GsApp) app = NULL;
+
+ /* look in the cache */
+ app = gs_plugin_cache_lookup (plugin, apps[i]);
+ if (app != NULL) {
+ gs_app_list_add (list, app);
+ continue;
+ }
+
+ /* create new */
+ app = gs_app_new (apps[i]);
+ gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+ gs_app_set_metadata (app, "GnomeSoftware::Creator",
+ gs_plugin_get_name (plugin));
+ gs_app_list_add (list, app);
+
+ /* save in the cache */
+ gs_plugin_cache_add (plugin, apps[i], app);
+ }
+ return TRUE;
+}