[gnome-software] plugins: Add a hardcoded-kind plugin to provide a list of system applications



commit 75cafdf6b423c10fd031e68ac98ff3cf578775c6
Author: Richard Hughes <richard hughsie com>
Date:   Thu Mar 7 10:41:34 2013 +0000

    plugins: Add a hardcoded-kind plugin to provide a list of system applications
    
    System applications can't be removed in the GUI tool.

 src/gs-main.c                          |    3 +
 src/gs-self-test.c                     |    2 +
 src/plugins/Makefile.am                |    8 ++-
 src/plugins/README                     |    8 +++
 src/plugins/gs-plugin-hardcoded-kind.c |   99 ++++++++++++++++++++++++++++++++
 5 files changed, 119 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-main.c b/src/gs-main.c
index 38527d5..d2439ad 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -1621,6 +1621,9 @@ main (int argc, char **argv)
                goto out;
        }
 
+       /* FIXME: use GSettings key rather than hard-coding this */
+       gs_plugin_loader_set_enabled (priv->plugin_loader, "hardcoded-kind", TRUE);
+
        /* wait */
        status = g_application_run (G_APPLICATION (priv->application), argc, argv);
 out:
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index b773ee4..7e2e5f7 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -60,6 +60,8 @@ gs_plugin_loader_func (void)
        /* enable some that will give us predictable results */
        ret = gs_plugin_loader_set_enabled (loader, "dummy", TRUE);
        g_assert (ret);
+       ret = gs_plugin_loader_set_enabled (loader, "hardcoded-kind", 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 8233ed3..2b3b3b3 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -18,11 +18,17 @@ AM_CPPFLAGS =                                               \
 
 plugindir = $(libdir)/gs-plugins
 plugin_LTLIBRARIES =                                   \
-       libgs_plugin_dummy.la
+       libgs_plugin_dummy.la                   \
+       libgs_plugin_hardcoded-kind.la
 
 libgs_plugin_dummy_la_SOURCES = gs-plugin-dummy.c
 libgs_plugin_dummy_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_dummy_la_LDFLAGS = -module -avoid-version
 libgs_plugin_dummy_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
 
+libgs_plugin_hardcoded_kind_la_SOURCES = gs-plugin-hardcoded-kind.c
+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)
+
 -include $(top_srcdir)/git.mk
diff --git a/src/plugins/README b/src/plugins/README
index aea4215..6914474 100644
--- a/src/plugins/README
+++ b/src/plugins/README
@@ -54,3 +54,11 @@ Methods:     Search
 Requires:      <nothing>
 Refines:       [id]->[name]
                [id]->[summary]
+
+== hardcoded-kind ==
+Overview:      Provides some hardcoded static core applications that cannot
+               be removed.
+Methods:       <nothing>
+Requires:      <nothing>
+Refines:       [id]->[kind]
+Note:          This is based on the gnome jhbuild moduleset
diff --git a/src/plugins/gs-plugin-hardcoded-kind.c b/src/plugins/gs-plugin-hardcoded-kind.c
new file mode 100644
index 0000000..2bb86a2
--- /dev/null
+++ b/src/plugins/gs-plugin-hardcoded-kind.c
@@ -0,0 +1,99 @@
+/* -*- 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-kind";
+}
+
+/**
+ * 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)
+{
+       GList *l;
+       GsApp *app;
+       guint i;
+       const gchar *apps[] = {
+               "baobab",
+               "eog",
+               "epiphany",
+               "evince",
+               "empathy",
+               "gcalctool",
+               "gedit",
+               "gnome-bluetooth",
+               "gnome-clocks",
+               "gnome-contacts",
+               "gnome-dictionary",
+               "gnome-disks",
+               "gnome-eog",
+               "gnome-font-viewer",
+               "gnome-gucharmap",
+               "gnome-keyring",
+               "gnome-menus",
+               "gnome-packagekit",
+               "gnome-screenshot",
+               "gnome-session",
+               "gnome-software",
+               "gnome-system-log",
+               "gnome-system-monitor",
+               "gnome-terminal",
+               "gnome-user-docs",
+               "gnome-user-share",
+               "gucharmap",
+               "nautilus",
+               "sushi",
+               "totem",
+               "vino",
+               "yelp",
+               NULL };
+
+       /* just mark each one as core */
+       for (l = list; l != NULL; l = l->next) {
+               app = GS_APP (l->data);
+               for (i = 0; apps[i] != NULL; i++) {
+                       if (g_strcmp0 (apps[i], gs_app_get_id (app)) == 0) {
+                               gs_app_set_kind (app, GS_APP_KIND_SYSTEM);
+                               break;
+                       }
+               }
+       }
+       return TRUE;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]