[gnome-software] plugins: Add a hardcoded-ratings plugin to provide rating values for a few applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] plugins: Add a hardcoded-ratings plugin to provide rating values for a few applications
- Date: Thu, 7 Mar 2013 16:06:59 +0000 (UTC)
commit a1e1eeef98cbb86e840f8a41d386bdd2eae4de31
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 7 10:46:35 2013 +0000
plugins: Add a hardcoded-ratings plugin to provide rating values for a few applications
src/gs-main.c | 1 +
src/gs-self-test.c | 2 +
src/plugins/Makefile.am | 8 +++-
src/plugins/README | 6 +++
src/plugins/gs-plugin-hardcoded-ratings.c | 71 +++++++++++++++++++++++++++++
5 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-main.c b/src/gs-main.c
index 2cdc474..0dbc93d 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -1624,6 +1624,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);
+ gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-ratings", 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 c24d2ae..3981037 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -66,6 +66,8 @@ gs_plugin_loader_func (void)
g_assert (ret);
ret = gs_plugin_loader_set_enabled (loader, "hardcoded-popular", TRUE);
g_assert (ret);
+ ret = gs_plugin_loader_set_enabled (loader, "hardcoded-ratings", TRUE);
+ g_assert (ret);
ret = gs_plugin_loader_set_enabled (loader, "notgoingtoexist", TRUE);
g_assert (!ret);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index fe15d42..5694249 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -20,7 +20,8 @@ plugindir = $(libdir)/gs-plugins
plugin_LTLIBRARIES = \
libgs_plugin_dummy.la \
libgs_plugin_hardcoded-kind.la \
- libgs_plugin_hardcoded-popular.la
+ libgs_plugin_hardcoded-popular.la \
+ libgs_plugin_hardcoded-ratings.la
libgs_plugin_dummy_la_SOURCES = gs-plugin-dummy.c
libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
@@ -37,4 +38,9 @@ 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_hardcoded_ratings_la_SOURCES = gs-plugin-hardcoded-ratings.c
+libgs_plugin_hardcoded_ratings_la_LIBADD = $(GS_PLUGIN_LIBS)
+libgs_plugin_hardcoded_ratings_la_LDFLAGS = -module -avoid-version
+libgs_plugin_hardcoded_ratings_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+
-include $(top_srcdir)/git.mk
diff --git a/src/plugins/README b/src/plugins/README
index af55e32..99d0128 100644
--- a/src/plugins/README
+++ b/src/plugins/README
@@ -68,3 +68,9 @@ Overview: Provides some hardcoded static favourite applications.
Methods: AddPopular
Requires: <nothing>
Refines: <nothing>
+
+== hardcoded-ratings ==
+Overview: Provides some hardcoded static ratings for applications.
+Methods: <nothing>
+Requires: <nothing>
+Refines: [id]->[rating]
diff --git a/src/plugins/gs-plugin-hardcoded-ratings.c b/src/plugins/gs-plugin-hardcoded-ratings.c
new file mode 100644
index 0000000..7cde53f
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-ratings.c
@@ -0,0 +1,71 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 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-ratings";
+}
+
+/**
+ * gs_plugin_get_priority:
+ */
+gdouble
+gs_plugin_get_priority (GsPlugin *plugin)
+{
+ return -100.0f;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin, GList *list, GError **error)
+{
+ const gchar *id;
+ GsApp *app;
+ GList *l;
+
+ //FIXME: get some actual data from somewhere
+ for (l = list; l != NULL; l = l->next) {
+ app = GS_APP (l->data);
+ if (gs_app_get_rating (app) != -1)
+ continue;
+ id = gs_app_get_id (app);
+ if (g_strcmp0 (id, "epiphany") == 0) {
+ gs_app_set_rating (app, 50);
+ goto out;
+ }
+ if (g_strcmp0 (id, "sushi") == 0) {
+ gs_app_set_rating (app, 100);
+ goto out;
+ }
+ }
+out:
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]