]> Pileus Git - ~andy/gtk/blob - gdk/quartz/gdkselection-quartz.c
Bug 556527 - The current page property is not passed to GtkPrintUnixDialog
[~andy/gtk] / gdk / quartz / gdkselection-quartz.c
1 /* gdkselection-quartz.c
2  *
3  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4  * Copyright (C) 1998-2002 Tor Lillqvist
5  * Copyright (C) 2005 Imendio AB
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include "config.h"
24
25 #include "gdkselection.h"
26 #include "gdkproperty.h"
27
28 gboolean
29 gdk_selection_owner_set_for_display (GdkDisplay *display,
30                                      GdkWindow  *owner,
31                                      GdkAtom     selection,
32                                      guint32     time,
33                                      gint        send_event)
34 {
35   /* FIXME: Implement */
36   return TRUE;
37 }
38
39 GdkWindow*
40 gdk_selection_owner_get_for_display (GdkDisplay *display,
41                                      GdkAtom     selection)
42 {
43   /* FIXME: Implement */
44   return NULL;
45 }
46
47 void
48 gdk_selection_convert (GdkWindow *requestor,
49                        GdkAtom    selection,
50                        GdkAtom    target,
51                        guint32    time)
52 {
53   /* FIXME: Implement */
54 }
55
56 gint
57 gdk_selection_property_get (GdkWindow  *requestor,
58                             guchar    **data,
59                             GdkAtom    *ret_type,
60                             gint       *ret_format)
61 {
62   /* FIXME: Implement */
63   return 0;
64 }
65
66 void
67 gdk_selection_send_notify_for_display (GdkDisplay *display,
68                                        guint32     requestor,
69                                        GdkAtom     selection,
70                                        GdkAtom     target,
71                                        GdkAtom     property,
72                                        guint32     time)
73 {
74   /* FIXME: Implement */
75 }
76
77 gint
78 gdk_text_property_to_text_list_for_display (GdkDisplay   *display,
79                                             GdkAtom       encoding,
80                                             gint          format, 
81                                             const guchar *text,
82                                             gint          length,
83                                             gchar      ***list)
84 {
85   /* FIXME: Implement */
86   return 0;
87 }
88
89 gint
90 gdk_string_to_compound_text_for_display (GdkDisplay  *display,
91                                          const gchar *str,
92                                          GdkAtom     *encoding,
93                                          gint        *format,
94                                          guchar     **ctext,
95                                          gint        *length)
96 {
97   /* FIXME: Implement */
98   return 0;
99 }
100
101 void gdk_free_compound_text (guchar *ctext)
102 {
103   /* FIXME: Implement */
104 }
105
106 gchar *
107 gdk_utf8_to_string_target (const gchar *str)
108 {
109   /* FIXME: Implement */
110   return NULL;
111 }
112
113 gboolean
114 gdk_utf8_to_compound_text_for_display (GdkDisplay  *display,
115                                        const gchar *str,
116                                        GdkAtom     *encoding,
117                                        gint        *format,
118                                        guchar     **ctext,
119                                        gint        *length)
120 {
121   /* FIXME: Implement */
122   return 0;
123 }
124
125 void
126 gdk_free_text_list (gchar **list)
127 {
128   g_return_if_fail (list != NULL);
129
130   g_free (*list);
131   g_free (list);
132 }
133
134 static gint
135 make_list (const gchar  *text,
136            gint          length,
137            gboolean      latin1,
138            gchar      ***list)
139 {
140   GSList *strings = NULL;
141   gint n_strings = 0;
142   gint i;
143   const gchar *p = text;
144   const gchar *q;
145   GSList *tmp_list;
146   GError *error = NULL;
147
148   while (p < text + length)
149     {
150       gchar *str;
151       
152       q = p;
153       while (*q && q < text + length)
154         q++;
155
156       if (latin1)
157         {
158           str = g_convert (p, q - p,
159                            "UTF-8", "ISO-8859-1",
160                            NULL, NULL, &error);
161
162           if (!str)
163             {
164               g_warning ("Error converting selection from STRING: %s",
165                          error->message);
166               g_error_free (error);
167             }
168         }
169       else
170         str = g_strndup (p, q - p);
171
172       if (str)
173         {
174           strings = g_slist_prepend (strings, str);
175           n_strings++;
176         }
177
178       p = q + 1;
179     }
180
181   if (list)
182     *list = g_new (gchar *, n_strings + 1);
183
184   (*list)[n_strings] = NULL;
185   
186   i = n_strings;
187   tmp_list = strings;
188   while (tmp_list)
189     {
190       if (list)
191         (*list)[--i] = tmp_list->data;
192       else
193         g_free (tmp_list->data);
194
195       tmp_list = tmp_list->next;
196     }
197
198   g_slist_free (strings);
199
200   return n_strings;
201 }
202
203 gint 
204 gdk_text_property_to_utf8_list_for_display (GdkDisplay    *display,
205                                             GdkAtom        encoding,
206                                             gint           format,
207                                             const guchar  *text,
208                                             gint           length,
209                                             gchar       ***list)
210 {
211   g_return_val_if_fail (text != NULL, 0);
212   g_return_val_if_fail (length >= 0, 0);
213
214   if (encoding == GDK_TARGET_STRING)
215     {
216       return make_list ((gchar *)text, length, TRUE, list);
217     }
218   else if (encoding == gdk_atom_intern_static_string ("UTF8_STRING"))
219     {
220       return make_list ((gchar *)text, length, FALSE, list);
221     }
222   else
223     {
224       gchar *enc_name = gdk_atom_name (encoding);
225
226       g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled\n", enc_name);
227       g_free (enc_name);
228
229       if (list)
230         *list = NULL;
231
232       return 0;
233     }
234 }
235