summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2014-08-21 19:50:21 +0200
committerCarlos Garnacho <carlosg@gnome.org>2014-09-01 19:17:53 +0200
commit32bf03c0539cc909a2d0b29034db9a7903125f83 (patch)
treef365fabf866589181be3d5819e0ebdbf717527a6 /gdk
parentbd410421d8f97bc8c3c984aa69b693d8415b3052 (diff)
downloadgtk+-32bf03c0539cc909a2d0b29034db9a7903125f83.tar.gz
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. https://bugzilla.gnome.org/show_bug.cgi?id=697855
Diffstat (limited to 'gdk')
-rw-r--r--gdk/wayland/gdkselection-wayland.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index 39702750ac..44cbee6cde 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -77,7 +77,37 @@ _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])
+ {
+ chunk_len = strlen (ptr);
+
+ if (g_utf8_validate (ptr, chunk_len, NULL))
+ {
+ copy = g_strndup (ptr, chunk_len);
+ g_ptr_array_add (array, copy);
+ }
+
+ ptr = &ptr[chunk_len + 1];
+ }
+
+ nitems = array->len;
+ g_ptr_array_add (array, NULL);
+
+ if (list)
+ *list = (gchar **) g_ptr_array_free (array, FALSE);
+ else
+ g_ptr_array_free (array, TRUE);
+
+ return nitems;
}
gchar *