[gnome-software] Set the project group in the GsApp



commit e97576307dcd53bedc1900537898438c26194827
Author: Richard Hughes <richard hughsie com>
Date:   Fri Sep 27 10:24:07 2013 +0100

    Set the project group in the GsApp
    
    Filtering the packages in the plugin is the wrong layer.

 src/gs-app.c                      |   25 +++++++++++++++++++++++++
 src/gs-app.h                      |    3 +++
 src/gs-plugin-loader.c            |    2 ++
 src/plugins/gs-plugin-appstream.c |    5 +++++
 4 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 7ec245d..c1f68f5 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -56,6 +56,7 @@ struct GsAppPrivate
        gchar                   *id;
        gchar                   *name;
        gchar                   *source;
+       gchar                   *project_group;
        gchar                   *version;
        gchar                   *summary;
        gchar                   *description;
@@ -445,6 +446,29 @@ gs_app_set_source (GsApp *app, const gchar *source)
 }
 
 /**
+ * gs_app_get_project_group:
+ */
+const gchar *
+gs_app_get_project_group (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), NULL);
+       return app->priv->project_group;
+}
+
+/**
+ * gs_app_set_project_group:
+ * @app:       A #GsApp instance
+ * @project_group:     The non-localized project group, e.g. "GNOME" or "KDE"
+ */
+void
+gs_app_set_project_group (GsApp *app, const gchar *project_group)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       g_free (app->priv->project_group);
+       app->priv->project_group = g_strdup (project_group);
+}
+
+/**
  * gs_app_get_pixbuf:
  */
 GdkPixbuf *
@@ -1046,6 +1070,7 @@ gs_app_finalize (GObject *object)
        g_free (priv->name);
        g_free (priv->url);
        g_free (priv->source);
+       g_free (priv->project_group);
        g_free (priv->version);
        g_free (priv->summary);
        g_free (priv->description);
diff --git a/src/gs-app.h b/src/gs-app.h
index 0b6d918..04f5bd8 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -98,6 +98,9 @@ void           gs_app_set_name                (GsApp          *app,
 const gchar    *gs_app_get_source              (GsApp          *app);
 void            gs_app_set_source              (GsApp          *app,
                                                 const gchar    *source);
+const gchar    *gs_app_get_project_group       (GsApp          *app);
+void            gs_app_set_project_group       (GsApp          *app,
+                                                const gchar    *source);
 const gchar    *gs_app_get_version             (GsApp          *app);
 void            gs_app_set_version             (GsApp          *app,
                                                 const gchar    *version);
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 281bd7f..1eba4b7 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -109,6 +109,8 @@ gs_plugin_loader_dedupe (GsPluginLoader *plugin_loader, GsApp *app)
                /* save any properties we already know */
                if (gs_app_get_source (app) != NULL)
                        gs_app_set_source (new_app, gs_app_get_source (app));
+               if (gs_app_get_project_group (app) != NULL)
+                       gs_app_set_project_group (new_app, gs_app_get_project_group (app));
                if (gs_app_get_name (app) != NULL)
                        gs_app_set_name (new_app, gs_app_get_name (app));
                if (gs_app_get_summary (app) != NULL)
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index b7b6b28..7275cde 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -338,6 +338,11 @@ gs_plugin_refine_item (GsPlugin *plugin,
        if (appstream_app_get_icon (item) != NULL && gs_app_get_pixbuf (app) == NULL)
                gs_plugin_refine_item_pixbuf (plugin, app, item);
 
+       /* set project group */
+       if (appstream_app_get_project_group (item) != NULL &&
+           gs_app_get_project_group (app) == NULL)
+               gs_app_set_project_group (app, appstream_app_get_project_group (item));
+
        /* set package name */
        if (appstream_app_get_pkgname (item) != NULL && gs_app_get_source (app) == NULL)
                gs_app_set_source (app, appstream_app_get_pkgname (item));


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