[Spice-devel] [spice-gtk 2/2] Add fallback for g_key_file_set_uint64

Christophe Fergeau cfergeau at redhat.com
Wed Feb 27 05:44:40 PST 2013


This was only added in glib 2.26
---
 gtk/glib-compat.c | 27 +++++++++++++++++++++++++++
 gtk/glib-compat.h |  5 +++++
 2 files changed, 32 insertions(+)

diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 5f2e29e..0c108ef 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -18,6 +18,33 @@
 
 #if !GLIB_CHECK_VERSION(2,26,0)
 G_DEFINE_BOXED_TYPE (GError, spice_error, g_error_copy, g_error_free)
+
+/**
+ * g_key_file_set_uint64:
+ * @key_file: a #GKeyFile
+ * @group_name: a group name
+ * @key: a key
+ * @value: an integer value
+ *
+ * Associates a new integer value with @key under @group_name.
+ * If @key cannot be found then it is created.
+ *
+ * Since: 2.26
+ **/
+void
+g_key_file_set_uint64 (GKeyFile    *key_file,
+                       const gchar *group_name,
+                       const gchar *key,
+                       guint64      value)
+{
+  gchar *result;
+
+  g_return_if_fail (key_file != NULL);
+
+  result = g_strdup_printf ("%" G_GUINT64_FORMAT, value);
+  g_key_file_set_value (key_file, group_name, key, result);
+  g_free (result);
+}
 #endif
 
 #if !GLIB_CHECK_VERSION(2,28,0)
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index 64e7eb1..cc5232a 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -68,6 +68,11 @@ type_name##_get_type (void) \
 GType spice_error_get_type (void) G_GNUC_CONST;
 
 #define G_PARAM_DEPRECATED  (1 << 31)
+
+void      g_key_file_set_uint64             (GKeyFile             *key_file,
+					     const gchar          *group_name,
+					     const gchar          *key,
+					     guint64               value);
 #endif /* glib 2.26 */
 
 #if !GLIB_CHECK_VERSION(2,28,0)
-- 
1.8.1.2



More information about the Spice-devel mailing list