[gnome-software] Add a GSetting key to override the default popular applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add a GSetting key to override the default popular applications
- Date: Thu, 17 Sep 2015 13:39:33 +0000 (UTC)
commit 82a7021bebc9a79d0cfc45af55cd357a12e1bcb0
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 17 14:14:23 2015 +0100
Add a GSetting key to override the default popular applications
This allows Fleet Commander to over-write the list for corporate builds.
data/org.gnome.software.gschema.xml | 5 +++++
src/plugins/gs-plugin-moduleset.c | 29 ++++++++++++++++++++++++-----
2 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index 1598762..fe43cb8 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -24,6 +24,11 @@
<summary>Non-free applications show a warning dialog before install</summary>
<description>When non-free applications are installed a warning dialog can be shown. This controls if
that dialog is supressed.</description>
</key>
+ <key name="popular-overrides" type="as">
+ <default>[]</default>
+ <summary>A list of popular applications</summary>
+ <description>A list of applications to use, overriding the system defined ones.</description>
+ </key>
<key name="extra-sources" type="as">
<default>[]</default>
<summary>The list of extra sources that have been previously enabled</summary>
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index 11b807f..ff3bbf9 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -188,6 +188,28 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
}
/**
+ * gs_plugin_moduleset_get_popular:
+ */
+static gchar **
+gs_plugin_moduleset_get_popular (GsPlugin *plugin)
+{
+ g_autoptr(GSettings) settings = NULL;
+ g_auto(GStrv) apps = NULL;
+
+ /* debugging only */
+ if (g_getenv ("GNOME_SOFTWARE_POPULAR"))
+ return g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
+
+ /* are we using a corporate build */
+ settings = g_settings_new ("org.gnome.software");
+ apps = g_settings_get_strv (settings, "popular-overrides");
+ if (g_strv_length (apps) > 0)
+ return g_strdupv (apps);
+
+ return gs_moduleset_get_popular_apps (plugin->priv->moduleset);
+}
+
+/**
* gs_plugin_add_popular:
*/
gboolean
@@ -208,11 +230,8 @@ gs_plugin_add_popular (GsPlugin *plugin,
return FALSE;
}
- if (g_getenv ("GNOME_SOFTWARE_POPULAR")) {
- apps = g_strsplit (g_getenv ("GNOME_SOFTWARE_POPULAR"), ",", 0);
- } else {
- apps = gs_moduleset_get_popular_apps (plugin->priv->moduleset);
- }
+ /* get popular apps based on various things */
+ apps = gs_plugin_moduleset_get_popular (plugin);
if (apps == NULL) {
g_set_error (error,
GS_PLUGIN_ERROR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]