[gnome-software] Load a core moduleset from a file
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Load a core moduleset from a file
- Date: Sat, 8 Feb 2014 11:13:35 +0000 (UTC)
commit fc4f7215aaa08d9268766b3ff631c83e489638cf
Author: Richard Hughes <richard hughsie com>
Date: Sat Feb 8 12:12:23 2014 +0100
Load a core moduleset from a file
This is intentionally incomplete at this point; more research required.
data/Makefile.am | 1 +
data/moduleset-core.xml | 8 ++
src/gs-app.c | 3 +
src/gs-app.h | 13 ++--
src/gs-shell-details.c | 6 +-
src/plugins/Makefile.am | 9 ++
src/plugins/gs-plugin-moduleset-core.c | 138 ++++++++++++++++++++++++++++++++
7 files changed, 169 insertions(+), 9 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index fe35dee..e002397 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 \
+ moduleset-core.xml \
moduleset-gnome-apps.xml
@GSETTINGS_RULES@
diff --git a/data/moduleset-core.xml b/data/moduleset-core.xml
new file mode 100644
index 0000000..ff96c35
--- /dev/null
+++ b/data/moduleset-core.xml
@@ -0,0 +1,8 @@
+<moduleset name="core-workstation">
+ <module type="pkgname">kernel</module>
+ <module type="pkgname">glibc</module>
+</moduleset>
+<moduleset name="core-gnome">
+ <module type="pkgname">glib2</module>
+ <module type="pkgname">gtk3</module>
+</moduleset>
diff --git a/src/gs-app.c b/src/gs-app.c
index 369edbe..bbdb763 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -145,6 +145,8 @@ gs_app_kind_to_string (GsAppKind kind)
return "missing";
if (kind == GS_APP_KIND_SOURCE)
return "source";
+ if (kind == GS_APP_KIND_CORE)
+ return "core";
return NULL;
}
@@ -520,6 +522,7 @@ gs_app_set_kind (GsApp *app, GsAppKind kind)
/* package can become either normal or a system application */
if (kind == GS_APP_KIND_NORMAL ||
kind == GS_APP_KIND_SYSTEM ||
+ kind == GS_APP_KIND_CORE ||
kind == GS_APP_KIND_UNKNOWN)
state_change_ok = TRUE;
break;
diff --git a/src/gs-app.h b/src/gs-app.h
index c01c35e..b7946d1 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -57,12 +57,13 @@ typedef enum {
typedef enum {
GS_APP_KIND_UNKNOWN,
- GS_APP_KIND_NORMAL, /* can be updated, removed and installed */
- GS_APP_KIND_SYSTEM, /* can be updated, but not installed or removed */
- GS_APP_KIND_PACKAGE, /* can be updated, but not installed or removed */
- GS_APP_KIND_OS_UPDATE, /* can be updated, but not installed or removed */
- GS_APP_KIND_MISSING, /* you can't do anything to this */
- GS_APP_KIND_SOURCE, /* can be installed, but not updated or removed */
+ GS_APP_KIND_NORMAL, /* app [ install:1 remove:1 update:1 ] */
+ GS_APP_KIND_SYSTEM, /* app [ install:0 remove:0 update:1 ] */
+ GS_APP_KIND_PACKAGE, /* pkg [ install:0 remove:0 update:1 ] */
+ GS_APP_KIND_OS_UPDATE, /* pkg [ install:0 remove:0 update:1 ] */
+ GS_APP_KIND_MISSING, /* meta [ install:0 remove:0 update:0 ] */
+ GS_APP_KIND_SOURCE, /* src [ install:1 remove:0 update:0 ] */
+ GS_APP_KIND_CORE, /* pkg [ install:0 remove:0 update:1 ] */
GS_APP_KIND_LAST
} GsAppKind;
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index c8d87f3..220889a 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
* Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
*
* Licensed under the GNU General Public License Version 2
@@ -146,7 +146,7 @@ gs_shell_details_refresh (GsShellDetails *shell_details)
switch (state) {
case GS_APP_STATE_AVAILABLE:
case GS_APP_STATE_LOCAL:
- gtk_widget_set_visible (widget, TRUE);
+ gtk_widget_set_visible (widget, gs_app_get_kind (priv->app) != GS_APP_KIND_CORE);
gtk_widget_set_sensitive (widget, TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "suggested-action");
/* TRANSLATORS: button text in the header when an application
@@ -714,7 +714,7 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
/* are we trying to replace something in the baseos */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "infobar_details_package_baseos"));
switch (gs_app_get_kind (priv->app)) {
- case GS_APP_KIND_OS_UPDATE:
+ case GS_APP_KIND_CORE:
gtk_widget_set_visible (widget, TRUE);
break;
default:
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 61db23d..3e32e1d 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -31,6 +31,7 @@ plugin_LTLIBRARIES = \
libgs_plugin_datadir_filename_local.la \
libgs_plugin_desktopdb.la \
libgs_plugin_hardcoded-featured.la \
+ libgs_plugin_moduleset-core.la \
libgs_plugin_moduleset-gnome.la \
libgs_plugin_hardcoded-categories.la \
libgs_plugin_hardcoded-popular.la \
@@ -110,6 +111,14 @@ libgs_plugin_moduleset_gnome_la_LIBADD = $(GS_PLUGIN_LIBS)
libgs_plugin_moduleset_gnome_la_LDFLAGS = -module -avoid-version
libgs_plugin_moduleset_gnome_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
+libgs_plugin_moduleset_core_la_SOURCES = \
+ gs-moduleset.c \
+ gs-moduleset.h \
+ gs-plugin-moduleset-core.c
+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
diff --git a/src/plugins/gs-plugin-moduleset-core.c b/src/plugins/gs-plugin-moduleset-core.c
new file mode 100644
index 0000000..9188dbe
--- /dev/null
+++ b/src/plugins/gs-plugin-moduleset-core.c
@@ -0,0 +1,138 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013-2014 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>
+
+#include "gs-moduleset.h"
+
+struct GsPluginPrivate {
+ GsModuleset *moduleset;
+ gsize done_init;
+};
+
+/**
+ * gs_plugin_get_name:
+ */
+const gchar *
+gs_plugin_get_name (void)
+{
+ return "moduleset-core";
+}
+
+/**
+ * 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_get_deps:
+ */
+const gchar **
+gs_plugin_get_deps (GsPlugin *plugin)
+{
+ static const gchar *deps[] = {
+ "packagekit", /* pkgname */
+ NULL };
+ return deps;
+}
+
+/**
+ * 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-core::startup");
+ filename = g_build_filename (DATADIR,
+ "gnome-software",
+ "moduleset-core.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-core::startup");
+ return ret;
+}
+
+/**
+ * gs_plugin_refine:
+ */
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+ GList **list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GList *l;
+ GsApp *app;
+ gboolean ret = TRUE;
+ gchar **pkgs = 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;
+ }
+
+ /* just mark each one as core */
+ pkgs = gs_moduleset_get_by_kind (plugin->priv->moduleset,
+ GS_MODULESET_MODULE_KIND_PACKAGE);
+ for (l = *list; l != NULL; l = l->next) {
+ app = GS_APP (l->data);
+ for (i = 0; pkgs[i] != NULL; i++) {
+ if (g_strcmp0 (pkgs[i], gs_app_get_source_default (app)) == 0) {
+ gs_app_set_kind (app, GS_APP_KIND_CORE);
+ break;
+ }
+ }
+ }
+out:
+ g_strfreev (pkgs);
+ return ret;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]