[gtk+/wayland-selections: 12/17] wayland: implement text_property_to_utf8_list()



commit 923891b83944b011d20c6c47e55e43b3501576de
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 21 19:50:21 2014 +0200

    wayland: implement text_property_to_utf8_list()
    
    Of some sort, this is enough to get text transfers on wayland, anything but
    utf8 as plain/text should be pretty rare.

 gdk/wayland/gdkselection-wayland.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index 3970275..e31623a 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -77,7 +77,31 @@ _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay    *display,
                                                 gint           length,
                                                 gchar       ***list)
 {
-  return 0;
+  GPtrArray *array;
+  const gchar *ptr;
+  gsize chunk_len;
+  gchar *copy;
+  guint nitems;
+
+  ptr = (const gchar *) text;
+  array = g_ptr_array_new ();
+
+  while (ptr < (const gchar *) &text[length])
+    {
+      /* FIXME: Assuming it's all UTF8 */
+      chunk_len = strlen (ptr);
+      copy = g_strndup (ptr, chunk_len);
+      ptr = &ptr[chunk_len + 1];
+
+      g_ptr_array_add (array, copy);
+    }
+
+  nitems = array->len;
+
+  if (list)
+    *list = (gchar **) g_ptr_array_free (array, FALSE);
+
+  return nitems;
 }
 
 gchar *


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