[gtk+] Fix gdk_x11_display_text_property_to_text_list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fix gdk_x11_display_text_property_to_text_list
- Date: Fri, 24 Dec 2010 21:28:47 +0000 (UTC)
commit 29eb3fba5f3a8e85c19cd3bd404f9e88a1541805
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 24 16:27:31 2010 -0500
Fix gdk_x11_display_text_property_to_text_list
This was an incomplete attempt to get rid of the custom free function.
Lets just keep it for now. Bug 637849, patch by Dan Winship.
Also add a test case for this function.
gdk/tests/Makefile.am | 4 +++
gdk/tests/encoding.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
gdk/x11/gdkselection-x11.c | 4 +-
3 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/gdk/tests/Makefile.am b/gdk/tests/Makefile.am
index 9a75314..e23df12 100644
--- a/gdk/tests/Makefile.am
+++ b/gdk/tests/Makefile.am
@@ -23,6 +23,10 @@ TEST_PROGS += gdk-color
gdk_color_SOURCES = gdk-color.c
gdk_color_LDADD = $(progs_ldadd)
+TEST_PROGS += encoding
+encoding_SOURCES = encoding.c
+encoding_LDADD = $(progs_ldadd)
+
CLEANFILES = \
cairosurface.png \
gdksurface.png
diff --git a/gdk/tests/encoding.c b/gdk/tests/encoding.c
new file mode 100644
index 0000000..e1d0307
--- /dev/null
+++ b/gdk/tests/encoding.c
@@ -0,0 +1,46 @@
+#include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
+
+static void
+test_to_text_list (void)
+{
+ GdkDisplay *display;
+
+ display = gdk_display_get_default ();
+
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ GdkAtom encoding;
+ gint format;
+ const guchar *text;
+ gint length;
+ gchar **list;
+ gint n;
+
+ encoding = gdk_atom_intern ("UTF8_STRING", FALSE);
+ format = 8;
+ text = (const guchar*)"abcdef \304\201 \304\205\0ABCDEF \304\200 \304\204";
+ length = 25;
+ n = gdk_x11_display_text_property_to_text_list (display, encoding, format, text, length, &list);
+ g_assert_cmpint (n, ==, 2);
+ g_assert (g_str_has_prefix (list[0], "abcdef "));
+ g_assert (g_str_has_prefix (list[1], "ABCDEF "));
+
+ gdk_x11_free_text_list (list);
+ }
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+ gdk_init (&argc, &argv);
+
+ g_test_add_func ("/encoding/to-text-list", test_to_text_list);
+
+ return g_test_run ();
+}
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index 5a0dfea..f13207b 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -340,7 +340,7 @@ _gdk_x11_display_send_selection_notify (GdkDisplay *display,
* @format: the format of the property
* @text: The text data
* @length: The number of items to transform
- * @list: location to store a terminated array of strings in
+ * @list: location to store an array of strings in
* the encoding of the current locale. This array should be
* freed using gdk_free_text_list().
*
@@ -385,7 +385,7 @@ gdk_x11_display_text_property_to_text_list (GdkDisplay *display,
else
{
if (list)
- *list = g_strdupv (local_list);
+ *list = local_list;
else
XFreeStringList (local_list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]