[gnome-software] trivial: Add gs_app_set_branch()



commit d2b5380bcd4aa734b848916b9932bacfcdbc19a6
Author: Richard Hughes <richard hughsie com>
Date:   Tue Aug 9 14:59:00 2016 +0100

    trivial: Add gs_app_set_branch()

 src/gs-app.c |   36 +++++++++++++++++++++++++++++++++++-
 src/gs-app.h |    3 +++
 2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 441752e..9568d4c 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -60,6 +60,7 @@ struct _GsApp
 
        gchar                   *id;
        gchar                   *unique_id;
+       gchar                   *branch;
        gchar                   *name;
        GsAppQuality             name_quality;
        GPtrArray               *icons;
@@ -381,6 +382,8 @@ gs_app_to_string (GsApp *app)
                g_autofree gchar *path = g_strjoinv (" → ", app->menu_path);
                gs_app_kv_lpad (str, "menu-path", path);
        }
+       if (app->branch != NULL)
+               gs_app_kv_lpad (str, "branch", app->branch);
        if (app->origin != NULL && app->origin[0] != '\0')
                gs_app_kv_lpad (str, "origin", app->origin);
        if (app->origin_ui != NULL && app->origin_ui[0] != '\0')
@@ -877,7 +880,7 @@ gs_app_get_unique_id (GsApp *app)
                                                           app->origin,
                                                           app->kind,
                                                           app->id,
-                                                          NULL);       /* branch */
+                                                          app->branch);
        }
        return app->unique_id;
 }
@@ -942,6 +945,36 @@ gs_app_set_name (GsApp *app, GsAppQuality quality, const gchar *name)
 }
 
 /**
+ * gs_app_get_branch:
+ * @app: a #GsApp
+ *
+ * Gets the application branch.
+ *
+ * Returns: a string, or %NULL for unset
+ **/
+const gchar *
+gs_app_get_branch (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), NULL);
+       return app->branch;
+}
+
+/**
+ * gs_app_set_branch:
+ * @app: a #GsApp
+ * @branch: The branch, e.g. "master"
+ *
+ * Sets the application branch.
+ **/
+void
+gs_app_set_branch (GsApp *app, const gchar *branch)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       g_free (app->branch);
+       app->branch = g_strdup (branch);
+}
+
+/**
  * gs_app_get_source_default:
  * @app: a #GsApp
  *
@@ -2945,6 +2978,7 @@ gs_app_finalize (GObject *object)
 
        g_free (app->id);
        g_free (app->unique_id);
+       g_free (app->branch);
        g_free (app->name);
        g_hash_table_unref (app->urls);
        g_free (app->license);
diff --git a/src/gs-app.h b/src/gs-app.h
index b979389..440a770 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -119,6 +119,9 @@ void                 gs_app_set_progress            (GsApp          *app,
 const gchar    *gs_app_get_unique_id           (GsApp          *app);
 void            gs_app_set_unique_id           (GsApp          *app,
                                                 const gchar    *unique_id);
+const gchar    *gs_app_get_branch              (GsApp          *app);
+void            gs_app_set_branch              (GsApp          *app,
+                                                const gchar    *branch);
 const gchar    *gs_app_get_name                (GsApp          *app);
 void            gs_app_set_name                (GsApp          *app,
                                                 GsAppQuality    quality,


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