[gnome-software] Allow different distro spins to refine the list of hardcoded popular applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Allow different distro spins to refine the list of hardcoded popular applications
- Date: Sun, 9 Feb 2014 07:36:21 +0000 (UTC)
commit f1da877b85743b67846fee623b7e880a4d267ae9
Author: Richard Hughes <richard hughsie com>
Date: Sun Feb 9 08:28:53 2014 +0100
Allow different distro spins to refine the list of hardcoded popular applications
data/Makefile.am | 1 +
data/popular-apps.xml | 20 +++++
src/gs-plugin-loader.c | 3 +
src/gs-self-test.c | 2 +-
src/plugins/Makefile.am | 10 +-
src/plugins/gs-plugin-hardcoded-popular.c | 111 ------------------------
src/plugins/gs-plugin-moduleset-popular.c | 131 +++++++++++++++++++++++++++++
7 files changed, 161 insertions(+), 117 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index e002397..3daf9c4 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -17,6 +17,7 @@ dist_resources_DATA = \
featured-weather-bg.png \
featured-xchat.png \
featured.ini \
+ popular-apps.xml \
moduleset-core.xml \
moduleset-gnome-apps.xml
diff --git a/data/popular-apps.xml b/data/popular-apps.xml
new file mode 100644
index 0000000..7b7890b
--- /dev/null
+++ b/data/popular-apps.xml
@@ -0,0 +1,20 @@
+<moduleset name="popular">
+ <module type="application">transmission-gtk.desktop</module>
+ <module type="application">inkscape.desktop</module>
+ <module type="application">scribus.desktop</module>
+ <module type="application">simple-scan.desktop</module>
+ <module type="application">tomboy.desktop</module>
+ <module type="application">gtg.desktop</module>
+ <module type="application">stellarium.desktop</module>
+ <module type="application">gnome-maps.desktop</module>
+ <module type="application">calibre.desktop</module>
+ <module type="application">hotot-gtk.desktop</module>
+ <module type="application">musique.desktop</module>
+ <module type="application">sol.desktop</module>
+ <module type="application">shutter.desktop</module>
+ <module type="application">gnucash.desktop</module>
+ <module type="application">iagno.desktop</module>
+ <module type="application">mozilla-thunderbird.desktop</module>
+ <module type="application">geary.desktop</module>
+ <module type="application">pdfshuffler.desktop</module>
+</moduleset>
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 9533e1c..b2baa70 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -1060,6 +1060,9 @@ gs_plugin_loader_get_popular_thread_cb (GSimpleAsyncResult *res,
goto out;
}
+ /* shuffle around the list */
+ gs_plugin_list_randomize (&state->list);
+
/* success */
state->ret = TRUE;
gs_plugin_loader_get_all_state_finish (state, NULL);
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 0b24fa0..5d2d775 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -371,7 +371,7 @@ gs_plugin_loader_func (void)
g_assert (ret);
ret = gs_plugin_loader_set_enabled (loader, "hardcoded-kind", TRUE);
g_assert (ret);
- ret = gs_plugin_loader_set_enabled (loader, "hardcoded-popular", TRUE);
+ ret = gs_plugin_loader_set_enabled (loader, "moduleset-popular", TRUE);
g_assert (ret);
ret = gs_plugin_loader_set_enabled (loader, "hardcoded-ratings", TRUE);
g_assert (ret);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 3e32e1d..380e2c1 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -34,7 +34,7 @@ plugin_LTLIBRARIES = \
libgs_plugin_moduleset-core.la \
libgs_plugin_moduleset-gnome.la \
libgs_plugin_hardcoded-categories.la \
- libgs_plugin_hardcoded-popular.la \
+ libgs_plugin_moduleset-popular.la \
libgs_plugin_menu-spec-categories.la \
libgs_plugin_menu-spec-refine.la \
libgs_plugin_local-ratings.la \
@@ -119,10 +119,10 @@ libgs_plugin_moduleset_core_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_moduleset_core_la_LDFLAGS = -module -avoid-version
libgs_plugin_moduleset_core_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
-libgs_plugin_hardcoded_popular_la_SOURCES = gs-plugin-hardcoded-popular.c
-libgs_plugin_hardcoded_popular_la_LIBADD = $(GS_PLUGIN_LIBS)
-libgs_plugin_hardcoded_popular_la_LDFLAGS = -module -avoid-version
-libgs_plugin_hardcoded_popular_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+libgs_plugin_moduleset_popular_la_SOURCES = gs-plugin-moduleset-popular.c
+libgs_plugin_moduleset_popular_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_moduleset_popular_la_LDFLAGS = -module -avoid-version
+libgs_plugin_moduleset_popular_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
libgs_plugin_hardcoded_categories_la_SOURCES = gs-plugin-hardcoded-categories.c
libgs_plugin_hardcoded_categories_la_LIBADD = $(GS_PLUGIN_LIBS)
diff --git a/src/plugins/gs-plugin-moduleset-popular.c b/src/plugins/gs-plugin-moduleset-popular.c
new file mode 100644
index 0000000..b6e0647
--- /dev/null
+++ b/src/plugins/gs-plugin-moduleset-popular.c
@@ -0,0 +1,131 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011-2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <gs-plugin.h>
+#include <gs-category.h>
+
+#include "gs-moduleset.h"
+
+struct GsPluginPrivate {
+ GsModuleset *moduleset;
+ gsize done_init;
+};
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+ return "moduleset-popular";
+}
+
+/**
+ * gs_plugin_initialize:
+ */
+void
+gs_plugin_initialize (GsPlugin *plugin)
+{
+ plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
+ plugin->priv->moduleset = gs_moduleset_new ();
+}
+
+/**
+ * gs_plugin_destroy:
+ */
+void
+gs_plugin_destroy (GsPlugin *plugin)
+{
+ g_object_unref (plugin->priv->moduleset);
+}
+
+/**
+ * gs_plugin_startup:
+ */
+static gboolean
+gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
+{
+ gboolean ret;
+ gchar *filename;
+
+ /* Parse the XML */
+ gs_profile_start (plugin->profile, "moduleset-popular::startup");
+ filename = g_build_filename (DATADIR,
+ "gnome-software",
+ "popular-apps.xml",
+ NULL);
+ ret = gs_moduleset_parse_filename (plugin->priv->moduleset,
+ filename,
+ error);
+ if (!ret)
+ goto out;
+out:
+ g_free (filename);
+ gs_profile_stop (plugin->profile, "moduleset-popular::startup");
+ return ret;
+}
+
+/**
+ * gs_plugin_add_popular:
+ */
+gboolean
+gs_plugin_add_popular (GsPlugin *plugin,
+ GList **list,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsApp *app;
+ gboolean ret = TRUE;
+ gchar **apps = NULL;
+ guint i;
+
+ /* load XML files */
+ if (g_once_init_enter (&plugin->priv->done_init)) {
+ ret = gs_plugin_startup (plugin, cancellable, error);
+ g_once_init_leave (&plugin->priv->done_init, TRUE);
+ if (!ret)
+ goto out;
+ }
+
+ if (g_getenv ("GNOME_SOFTWARE_POPULAR")) {
+ apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
+ } else {
+ apps = gs_moduleset_get_by_kind (plugin->priv->moduleset,
+ GS_MODULESET_MODULE_KIND_APPLICATION);
+ }
+
+ /* just add all */
+ for (i = 0; apps[i]; i++) {
+ app = gs_app_new (apps[i]);
+ gs_plugin_add_app (list, app);
+ g_object_unref (app);
+ }
+out:
+ g_strfreev (apps);
+ return ret;
+}
+
+/* vim: set noexpandtab: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]