[gnome-software] Add the concept of 'kudos' to an application



commit 927cbd1be67f82b8bfcb917cd8c62ffd54084c76
Author: Richard Hughes <richard hughsie com>
Date:   Wed Feb 26 21:18:29 2014 +0000

    Add the concept of 'kudos' to an application
    
    Applications can do certain things if they achieve various kudos.

 src/gs-app.c |   30 ++++++++++++++++++++++++++++++
 src/gs-app.h |   11 +++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 609fda1..bddb77a 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -95,6 +95,7 @@ struct GsAppPrivate
        GHashTable              *related_hash; /* of "id-source" */
        GPtrArray               *history; /* of GsApp */
        guint64                  install_date;
+       guint64                  kudos;
 };
 
 enum {
@@ -224,6 +225,14 @@ gs_app_to_string (GsApp *app)
                                gs_app_state_to_string (priv->state));
        if (priv->id_full != NULL)
                g_string_append_printf (str, "\tid:\t%s\n", priv->id_full);
+       if ((priv->kudos & GS_APP_KUDO_MY_LANGUAGE) > 0)
+               g_string_append (str, "\tkudo:\tmy-language\n");
+       if ((priv->kudos & GS_APP_KUDO_RECENT_RELEASE) > 0)
+               g_string_append (str, "\tkudo:\trecent-release\n");
+       if ((priv->kudos & GS_APP_KUDO_FEATURED_RECOMMENDED) > 0)
+               g_string_append (str, "\tkudo:\tfeatured-recommended\n");
+       if ((priv->kudos & GS_APP_KUDO_INTEGRATION) > 0)
+               g_string_append (str, "\tkudo:\tintegration\n");
        if (priv->name != NULL)
                g_string_append_printf (str, "\tname:\t%s\n", priv->name);
        if (priv->icon != NULL)
@@ -1555,6 +1564,26 @@ gs_app_set_keywords (GsApp *app, GPtrArray *keywords)
 }
 
 /**
+ * gs_app_add_kudo:
+ */
+void
+gs_app_add_kudo (GsApp *app, GsAppKudo kudo)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       app->priv->kudos |= kudo;
+}
+
+/**
+ * gs_app_get_kudos:
+ */
+guint64
+gs_app_get_kudos (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), 0);
+       return app->priv->kudos;
+}
+
+/**
  * gs_app_subsume:
  *
  * Imports all the useful data from @other into @app.
@@ -1608,6 +1637,7 @@ gs_app_subsume (GsApp *app, GsApp *other)
                app_tmp = g_ptr_array_index (priv2->related, i);
                gs_app_add_related (app, app_tmp);
        }
+       priv->kudos |= priv2->kudos;
 
        /* also metadata */
        keys = g_hash_table_get_keys (priv2->metadata);
diff --git a/src/gs-app.h b/src/gs-app.h
index b7946d1..d18106c 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -97,6 +97,14 @@ typedef enum {
        GS_APP_RATING_KIND_LAST
 } GsAppRatingKind;
 
+typedef enum {
+       GS_APP_KUDO_MY_LANGUAGE                 = 1 << 0,
+       GS_APP_KUDO_RECENT_RELEASE              = 1 << 1,
+       GS_APP_KUDO_FEATURED_RECOMMENDED        = 1 << 2,
+       GS_APP_KUDO_INTEGRATION                 = 1 << 3,
+       GS_APP_KUDO_LAST
+} GsAppKudo;
+
 #define        GS_APP_INSTALL_DATE_UNSET               0
 #define        GS_APP_INSTALL_DATE_UNKNOWN             1 /* 1s past the epoch */
 #define        GS_APP_SIZE_UNKNOWN                     0
@@ -246,6 +254,9 @@ void                 gs_app_add_category            (GsApp          *app,
 GPtrArray      *gs_app_get_keywords            (GsApp          *app);
 void            gs_app_set_keywords            (GsApp          *app,
                                                 GPtrArray      *keywords);
+void            gs_app_add_kudo                (GsApp          *app,
+                                                GsAppKudo       kudo);
+guint64                 gs_app_get_kudos               (GsApp          *app);
 
 G_END_DECLS
 


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