[gnome-software] plugins: Add a hardcoded-popular plugin to provide a list of popular applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] plugins: Add a hardcoded-popular plugin to provide a list of popular applications
- Date: Thu, 7 Mar 2013 16:06:54 +0000 (UTC)
commit 868911dab7aa9cbc047ff5371c0ab5faf50e2c5b
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 7 10:44:58 2013 +0000
plugins: Add a hardcoded-popular plugin to provide a list of popular applications
src/gs-main.c | 1 +
src/gs-self-test.c | 13 ++++++
src/plugins/Makefile.am | 10 +++-
src/plugins/README | 6 +++
src/plugins/gs-plugin-hardcoded-popular.c | 67 +++++++++++++++++++++++++++++
5 files changed, 95 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-main.c b/src/gs-main.c
index d2439ad..2cdc474 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -1623,6 +1623,7 @@ main (int argc, char **argv)
/* FIXME: use GSettings key rather than hard-coding this */
gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-kind", TRUE);
+ gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-popular", TRUE);
/* wait */
status = g_application_run (G_APPLICATION (priv->application), argc, argv);
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 7e2e5f7..c24d2ae 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -46,6 +46,8 @@ gs_plugin_loader_func (void)
{
gboolean ret;
GError *error = NULL;
+ GList *list;
+ GsApp *app;
GsPluginLoader *loader;
loader = gs_plugin_loader_new ();
@@ -62,9 +64,20 @@ 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);
+ g_assert (ret);
ret = gs_plugin_loader_set_enabled (loader, "notgoingtoexist", TRUE);
g_assert (!ret);
+ list = gs_plugin_loader_get_popular (loader, &error);
+ g_assert_no_error (error);
+ g_assert (list != NULL);
+ g_assert_cmpint (g_list_length (list), ==, 7);
+ app = g_list_nth_data (list, 0);
+ g_assert_cmpstr (gs_app_get_id (app), ==, "gnome-boxes");
+ g_assert_cmpstr (gs_app_get_name (app), ==, "Boxes");
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
+
g_object_unref (loader);
}
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 2b3b3b3..fe15d42 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -18,8 +18,9 @@ AM_CPPFLAGS = \
plugindir = $(libdir)/gs-plugins
plugin_LTLIBRARIES = \
- libgs_plugin_dummy.la \
- libgs_plugin_hardcoded-kind.la
+ libgs_plugin_dummy.la \
+ libgs_plugin_hardcoded-kind.la \
+ libgs_plugin_hardcoded-popular.la
libgs_plugin_dummy_la_SOURCES = gs-plugin-dummy.c
libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
@@ -31,4 +32,9 @@ libgs_plugin_hardcoded_kind_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_hardcoded_kind_la_LDFLAGS = -module -avoid-version
libgs_plugin_hardcoded_kind_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)
+
-include $(top_srcdir)/git.mk
diff --git a/src/plugins/README b/src/plugins/README
index 6914474..af55e32 100644
--- a/src/plugins/README
+++ b/src/plugins/README
@@ -62,3 +62,9 @@ Methods: <nothing>
Requires: <nothing>
Refines: [id]->[kind]
Note: This is based on the gnome jhbuild moduleset
+
+== hardcoded-popular ==
+Overview: Provides some hardcoded static favourite applications.
+Methods: AddPopular
+Requires: <nothing>
+Refines: <nothing>
diff --git a/src/plugins/gs-plugin-hardcoded-popular.c b/src/plugins/gs-plugin-hardcoded-popular.c
new file mode 100644
index 0000000..3b2d5b1
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-popular.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2011-2013 Richard Hughes <richard hughsie 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 <gs-plugin.h>
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+ return "hardcoded-popular";
+}
+
+/**
+ * gs_plugin_get_priority:
+ */
+gdouble
+gs_plugin_get_priority (GsPlugin *plugin)
+{
+ return -100.0f;
+}
+
+/**
+ * gs_plugin_add_popular:
+ */
+gboolean
+gs_plugin_add_popular (GsPlugin *plugin, GList **list, GError **error)
+{
+ GsApp *app;
+ guint i;
+ const gchar *apps[] = {
+ "transmission-gtk",
+ "cheese",
+ "inkscape",
+ "sound-juicer",
+ "gedit",
+ "gnome-boxes",
+ NULL };
+
+ /* just add each one */
+ for (i = 0; apps[i] != NULL; i++) {
+ app = gs_app_new (apps[i]);
+ gs_plugin_add_app (list, app);
+ }
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]