[gnome-software/wip/william/cherry-pick-4: 6/23] Add gs_os_release_get_ubuntu_codename
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/william/cherry-pick-4: 6/23] Add gs_os_release_get_ubuntu_codename
- Date: Fri, 3 Jun 2016 07:01:01 +0000 (UTC)
commit a0717494d4d7ee6f2bc9cc3f4177e75fa82f4dbf
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Jun 2 15:24:41 2016 -0400
Add gs_os_release_get_ubuntu_codename
src/gs-os-release.c | 21 +++++++++++++++++++++
src/gs-os-release.h | 1 +
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-os-release.c b/src/gs-os-release.c
index 3398511..94e9bc4 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 *ubuntu_codename;
};
static void gs_os_release_initable_iface_init (GInitableIface *iface);
@@ -119,6 +120,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->ubuntu_codename = g_strdup (tmp);
+ continue;
+ }
}
return TRUE;
}
@@ -199,6 +204,21 @@ gs_os_release_get_pretty_name (GsOsRelease *os_release)
}
/**
+ * gs_os_release_get_ubuntu_codename:
+ * @os_release: A #GsOsRelease
+ *
+ * Gets the Ubuntu code name from the os-release parser.
+ *
+ * Returns: a string, or %NULL
+ **/
+const gchar *
+gs_os_release_get_ubuntu_codename (GsOsRelease *os_release)
+{
+ g_return_val_if_fail (GS_IS_OS_RELEASE (os_release), NULL);
+ return os_release->ubuntu_codename;
+}
+
+/**
* gs_os_release_finalize:
**/
static void
@@ -210,6 +230,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->ubuntu_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..508b81f 100644
--- a/src/gs-os-release.h
+++ b/src/gs-os-release.h
@@ -39,6 +39,7 @@ 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_ubuntu_codename (GsOsRelease *os_release);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]