[gnome-software] Allow plugins to access the distro codename
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Allow plugins to access the distro codename
- Date: Mon, 4 Jul 2016 08:04:37 +0000 (UTC)
commit 08d66a723db39e722eaa32417fa5ceff300e919f
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Jul 4 09:01:53 2016 +0100
Allow plugins to access the distro codename
Signed-off-by: Richard Hughes <richard hughsie com>
src/gs-os-release.c | 21 +++++++++++++++++++++
src/gs-os-release.h | 13 +++++++------
2 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-os-release.c b/src/gs-os-release.c
index c92d364..c43ae17 100644
--- a/src/gs-os-release.c
+++ b/src/gs-os-release.c
@@ -45,6 +45,7 @@ struct _GsOsRelease
gchar *id;
gchar *version_id;
gchar *pretty_name;
+ gchar *distro_codename;
};
static void gs_os_release_initable_iface_init (GInitableIface *iface);
@@ -116,6 +117,10 @@ gs_os_release_initable_init (GInitable *initable,
os_release->pretty_name = g_strdup (tmp);
continue;
}
+ if (g_strcmp0 (lines[i], "UBUNTU_CODENAME") == 0) {
+ os_release->distro_codename = g_strdup (tmp);
+ continue;
+ }
}
return TRUE;
}
@@ -195,6 +200,21 @@ gs_os_release_get_pretty_name (GsOsRelease *os_release)
return os_release->pretty_name;
}
+/**
+ * gs_os_release_get_distro_codename:
+ * @os_release: A #GsOsRelease
+ *
+ * Gets the distro codename from the os-release parser.
+ *
+ * Returns: a string, or %NULL
+ **/
+const gchar *
+gs_os_release_get_distro_codename (GsOsRelease *os_release)
+{
+ g_return_val_if_fail (GS_IS_OS_RELEASE (os_release), NULL);
+ return os_release->distro_codename;
+}
+
static void
gs_os_release_finalize (GObject *object)
{
@@ -204,6 +224,7 @@ gs_os_release_finalize (GObject *object)
g_free (os_release->id);
g_free (os_release->version_id);
g_free (os_release->pretty_name);
+ g_free (os_release->distro_codename);
G_OBJECT_CLASS (gs_os_release_parent_class)->finalize (object);
}
diff --git a/src/gs-os-release.h b/src/gs-os-release.h
index ffd338e..7bf5b15 100644
--- a/src/gs-os-release.h
+++ b/src/gs-os-release.h
@@ -33,12 +33,13 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsOsRelease, gs_os_release, GS, OS_RELEASE, GObject)
-GsOsRelease *gs_os_release_new (GError **error);
-const gchar *gs_os_release_get_name (GsOsRelease *os_release);
-const gchar *gs_os_release_get_version (GsOsRelease *os_release);
-const gchar *gs_os_release_get_id (GsOsRelease *os_release);
-const gchar *gs_os_release_get_version_id (GsOsRelease *os_release);
-const gchar *gs_os_release_get_pretty_name (GsOsRelease *os_release);
+GsOsRelease *gs_os_release_new (GError **error);
+const gchar *gs_os_release_get_name (GsOsRelease *os_release);
+const gchar *gs_os_release_get_version (GsOsRelease *os_release);
+const gchar *gs_os_release_get_id (GsOsRelease *os_release);
+const gchar *gs_os_release_get_version_id (GsOsRelease *os_release);
+const gchar *gs_os_release_get_pretty_name (GsOsRelease *os_release);
+const gchar *gs_os_release_get_distro_codename (GsOsRelease *os_release);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]