1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 #include "gdkselection.h"
31 #include "gdkproperty.h"
32 #include "gdkprivate.h"
33 #include "gdkprivate-broadway.h"
34 #include "gdkdisplay-broadway.h"
39 typedef struct _OwnerInfo OwnerInfo;
48 static GSList *owner_list;
50 /* When a window is destroyed we check if it is the owner
51 * of any selections. This is somewhat inefficient, but
52 * owner_list is typically short, and it is a low memory,
56 _gdk_broadway_selection_window_destroyed (GdkWindow *window)
58 GSList *tmp_list = owner_list;
61 OwnerInfo *info = tmp_list->data;
62 tmp_list = tmp_list->next;
64 if (info->owner == window)
66 owner_list = g_slist_remove (owner_list, info);
73 _gdk_broadway_display_set_selection_owner (GdkDisplay *display,
82 if (gdk_display_is_closed (display))
85 tmp_list = owner_list;
88 info = tmp_list->data;
89 if (info->selection == selection)
91 owner_list = g_slist_remove (owner_list, info);
95 tmp_list = tmp_list->next;
100 info = g_new (OwnerInfo, 1);
102 info->serial = _gdk_display_get_next_serial (display);
104 info->selection = selection;
106 owner_list = g_slist_prepend (owner_list, info);
113 _gdk_broadway_display_get_selection_owner (GdkDisplay *display,
119 if (gdk_display_is_closed (display))
122 tmp_list = owner_list;
125 info = tmp_list->data;
126 if (info->selection == selection)
128 tmp_list = tmp_list->next;
135 _gdk_broadway_display_convert_selection (GdkDisplay *display,
136 GdkWindow *requestor,
141 g_warning ("convert_selection not implemented\n");
145 _gdk_broadway_display_get_selection_property (GdkDisplay *display,
146 GdkWindow *requestor,
152 *ret_type = GDK_NONE;
158 g_warning ("get_selection_property not implemented\n");
164 _gdk_broadway_display_send_selection_notify (GdkDisplay *display,
165 GdkWindow *requestor,
171 g_return_if_fail (GDK_IS_DISPLAY (display));
173 g_warning ("send_selection_notify not implemented\n");
178 make_list (const gchar *text,
183 GSList *strings = NULL;
186 const gchar *p = text;
189 GError *error = NULL;
191 while (p < text + length)
196 while (*q && q < text + length)
201 str = g_convert (p, q - p,
202 "UTF-8", "ISO-8859-1",
207 g_warning ("Error converting selection from STRING: %s",
209 g_error_free (error);
214 str = g_strndup (p, q - p);
215 if (!g_utf8_validate (str, -1, NULL))
217 g_warning ("Error converting selection from UTF8_STRING");
225 strings = g_slist_prepend (strings, str);
234 *list = g_new (gchar *, n_strings + 1);
235 (*list)[n_strings] = NULL;
243 (*list)[--i] = tmp_list->data;
245 g_free (tmp_list->data);
247 tmp_list = tmp_list->next;
250 g_slist_free (strings);
256 _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
263 g_return_val_if_fail (text != NULL, 0);
264 g_return_val_if_fail (length >= 0, 0);
265 g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
267 if (encoding == GDK_TARGET_STRING)
269 return make_list ((gchar *)text, length, TRUE, list);
271 else if (encoding == gdk_atom_intern_static_string ("UTF8_STRING"))
273 return make_list ((gchar *)text, length, FALSE, list);
282 _gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
285 return g_strdup (str);