]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkclipboard.sgml
Add GtkClipboardIamgeReceivedFunc
[~andy/gtk] / docs / reference / gtk / tmpl / gtkclipboard.sgml
1 <!-- ##### SECTION Title ##### -->
2 Clipboards
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Storing data on clipboards
6
7 <!-- ##### SECTION Long_Description ##### -->
8   <para>
9     The #GtkClipboard object represents a clipboard of data shared
10     between different processes or between different widgets in
11     the same process. Each clipboard is identified by a name encoded as a
12     #GdkAtom. (Conversion to and from strings can be done with
13     gdk_atom_intern() and gdk_atom_name().) The default clipboard
14     corresponds to the "CLIPBOARD" atom; another commonly used clipboard
15     is the "PRIMARY" clipboard, which, in X, traditionally contains
16     the currently selected text.
17   </para>
18   <para>
19     To support having a number of different formats on the clipboard
20     at the same time, the clipboard mechanism allows providing
21     callbacks instead of the actual data.  When you set the contents
22     of the clipboard, you can either supply the data directly (via
23     functions like gtk_clipboard_set_text()), or you can supply a
24     callback to be called at a later time when the data is needed (via
25     gtk_clipboard_set_with_data() or gtk_clipboard_set_with_owner().)
26     Providing a callback also avoids having to make copies of the data
27     when it is not needed.
28   </para>
29   <para>
30     gtk_clipboard_set_with_data() and gtk_clipboard_set_with_owner()
31     are quite similar; the choice between the two depends mostly on
32     which is more convenient in a particular situation.
33     The former is most useful when you want to have a blob of data
34     with callbacks to convert it into the various data types that you
35     advertise. When the @clear_func you provided is called, you
36     simply free the data blob. The latter is more useful when the
37     contents of clipboard reflect the internal state of a #GObject
38     (As an example, for the PRIMARY clipboard, when an entry widget
39     provides the clipboard's contents the contents are simply the
40     text within the selected region.) If the contents change, the
41     entry widget can call gtk_clipboard_set_with_owner() to update
42     the timestamp for clipboard ownership, without having to worry
43     about @clear_func being called.
44   </para>
45   <para>
46     Requesting the data from the clipboard is essentially
47     asynchronous. If the contents of the clipboard are provided within
48     the same process, then a direct function call will be made to
49     retrieve the data, but if they are provided by another process,
50     then the data needs to be retrieved from the other process, which
51     may take some time. To avoid blocking the user interface, the call
52     to request the selection, gtk_clipboard_request_contents() takes a
53     callback that will be called when the contents are received (or
54     when the request fails.) If you don't want to deal with providing
55     a separate callback, you can also use gtk_clipboard_wait_for_contents().
56     What this does is run the GLib main loop recursively waiting for
57     the contents. This can simplify the code flow, but you still have
58     to be aware that other callbacks in your program can be called
59     while this recursive mainloop is running.
60   </para>
61   <para>
62     Along with the functions to get the clipboard contents as an
63     arbitrary data chunk, there are also functions to retrieve
64     it as text, gtk_clipboard_request_text() and
65     gtk_clipboard_wait_for_text(). These functions take care of
66     determining which formats are advertised by the clipboard
67     provider, asking for the clipboard in the best available format
68     and converting the results into the UTF-8 encoding. (The standard
69     form for representing strings in GTK+.)
70   </para>
71
72 <!-- ##### SECTION See_Also ##### -->
73 <para>
74 <variablelist>
75
76 <varlistentry>
77 <term>#GtkSelection</term>
78 <listitem><para>#GtkClipboard provides a high-level wrapper around the
79             lower level routines that deal with X selections. It is
80             also possibly to directly manipulate the X selections,
81             though it is seldom necessary to do so.</para></listitem>
82 </varlistentry>
83
84 </variablelist>
85 </para>
86
87 <!-- ##### SECTION Stability_Level ##### -->
88
89
90 <!-- ##### STRUCT GtkClipboard ##### -->
91 <para>
92
93 </para>
94
95
96 <!-- ##### USER_FUNCTION GtkClipboardReceivedFunc ##### -->
97 <para>
98     A function to be called when the results of gtk_clipboard_request_contents()
99     are received, or when the request fails.
100 </para>
101
102 @clipboard: the #GtkClipboard
103 @selection_data: a #GtkSelectionData containing the data was received.
104                  If retrieving the data failed, then then length field
105                  of @selection_data will be negative.
106 @data: the @user_data supplied to gtk_clipboard_request_contents().
107
108
109 <!-- ##### USER_FUNCTION GtkClipboardTextReceivedFunc ##### -->
110 <para>
111     A function to be called when the results of gtk_clipboard_request_text()
112     are received, or when the request fails.
113 </para>
114
115 @clipboard: the #GtkClipboard
116 @text: the text received, as a UTF-8 encoded string, or %NULL
117             if retrieving the data failed.
118 @data: the @user_data supplied to gtk_clipboard_request_text().
119
120
121 <!-- ##### USER_FUNCTION GtkClipboardImageReceivedFunc ##### -->
122 <para>
123     A function to be called when the results of gtk_clipboard_request_image()
124     are received, or when the request fails.
125 </para>
126
127 @clipboard: the #GtkClipboard
128 @pixbuf: the received image
129 @data: the @user_data supplied to gtk_clipboard_request_image().
130 @Since: 2.6
131
132 <!-- ##### USER_FUNCTION GtkClipboardTargetsReceivedFunc ##### -->
133 <para>
134     A function to be called when the results of gtk_clipboard_request_targets()
135     are received, or when the request fails.
136 </para>
137
138 @clipboard: the #GtkClipboard
139 @atoms: the supported targets, as array of #GdkAtom, or %NULL 
140             if retrieving the data failed.
141 @n_atoms: the length of the @atoms array.
142 @data: the @user_data supplied to gtk_clipboard_request_targets().
143 @Since: 2.4
144
145
146 <!-- ##### USER_FUNCTION GtkClipboardGetFunc ##### -->
147 <para>
148 A function that will be called to provide the contents of the selection.
149 If multiple types of data were advertised, the requested type can
150 be determined from the @info parameter or by checking the target field
151 of @selection_data. If the data could successfully be converted into
152 then it should be stored into the @selection_data object by
153 calling gtk_selection_data_set() (or related functions such
154 as gtk_selection_data_set_text()). If no data is set, the requestor
155 will be informed that the attempt to get the data failed.    
156 </para>
157
158 @clipboard: the #GtkClipboard
159 @selection_data: a #GtkSelectionData argument in which the requested
160                      data should be stored.
161 @info: the info field corresponding to the requested
162                      target from the #GtkTargetEntry array passed to
163                      gtk_clipboard_set_with_data() or gtk_clipboard_set_with_owner().
164 @user_data_or_owner: the @user_data argument passed to gtk_clipboard_set_with_data(), or
165                      the @owner argument passed to gtk_clipboard_set_with_owner()
166
167
168 <!-- ##### USER_FUNCTION GtkClipboardClearFunc ##### -->
169 <para>
170 A function that will be called when the contents of the clipboard are changed
171 or cleared. Once this has called, the @user_data_or_owner argument
172 will not be used again.
173 </para>
174
175 @clipboard: the #GtkClipboard
176 @user_data_or_owner: the @user_data argument passed to gtk_clipboard_set_with_data(), or
177                      the @owner argument passed to gtk_clipboard_set_with_owner()
178
179
180 <!-- ##### FUNCTION gtk_clipboard_get ##### -->
181 <para>
182
183 </para>
184
185 @selection: 
186 @Returns: 
187
188
189 <!-- ##### FUNCTION gtk_clipboard_get_for_display ##### -->
190 <para>
191
192 </para>
193
194 @display: 
195 @selection: 
196 @Returns: 
197
198
199 <!-- ##### FUNCTION gtk_clipboard_get_display ##### -->
200 <para>
201
202 </para>
203
204 @clipboard: 
205 @Returns: 
206
207
208 <!-- ##### FUNCTION gtk_clipboard_set_with_data ##### -->
209 <para>
210
211 </para>
212
213 @clipboard: 
214 @targets: 
215 @n_targets: 
216 @get_func: 
217 @clear_func: 
218 @user_data: 
219 @Returns: 
220
221
222 <!-- ##### FUNCTION gtk_clipboard_set_with_owner ##### -->
223 <para>
224
225 </para>
226
227 @clipboard: 
228 @targets: 
229 @n_targets: 
230 @get_func: 
231 @clear_func: 
232 @owner: 
233 @Returns: 
234
235
236 <!-- ##### FUNCTION gtk_clipboard_get_owner ##### -->
237 <para>
238
239 </para>
240
241 @clipboard: 
242 @Returns: 
243
244
245 <!-- ##### FUNCTION gtk_clipboard_clear ##### -->
246 <para>
247
248 </para>
249
250 @clipboard: 
251
252
253 <!-- ##### FUNCTION gtk_clipboard_set_text ##### -->
254 <para>
255
256 </para>
257
258 @clipboard: 
259 @text: 
260 @len: 
261
262
263 <!-- ##### FUNCTION gtk_clipboard_set_image ##### -->
264 <para>
265
266 </para>
267
268 @clipboard: 
269 @pixbuf: 
270
271
272 <!-- ##### FUNCTION gtk_clipboard_request_contents ##### -->
273 <para>
274
275 </para>
276
277 @clipboard: 
278 @target: 
279 @callback: 
280 @user_data: 
281
282
283 <!-- ##### FUNCTION gtk_clipboard_request_text ##### -->
284 <para>
285
286 </para>
287
288 @clipboard: 
289 @callback: 
290 @user_data: 
291
292
293 <!-- ##### FUNCTION gtk_clipboard_request_image ##### -->
294 <para>
295
296 </para>
297
298 @clipboard: 
299 @callback: 
300 @user_data: 
301
302
303 <!-- ##### FUNCTION gtk_clipboard_request_targets ##### -->
304 <para>
305
306 </para>
307
308 @clipboard: 
309 @callback: 
310 @user_data: 
311
312
313 <!-- ##### FUNCTION gtk_clipboard_wait_for_contents ##### -->
314 <para>
315
316 </para>
317
318 @clipboard: 
319 @target: 
320 @Returns: 
321
322
323 <!-- ##### FUNCTION gtk_clipboard_wait_for_text ##### -->
324 <para>
325
326 </para>
327
328 @clipboard: 
329 @Returns: 
330
331
332 <!-- ##### FUNCTION gtk_clipboard_wait_for_image ##### -->
333 <para>
334
335 </para>
336
337 @clipboard: 
338 @Returns: 
339
340
341 <!-- ##### FUNCTION gtk_clipboard_wait_is_text_available ##### -->
342 <para>
343
344 </para>
345
346 @clipboard: 
347 @Returns: 
348
349
350 <!-- ##### FUNCTION gtk_clipboard_wait_is_image_available ##### -->
351 <para>
352
353 </para>
354
355 @clipboard: 
356 @Returns: 
357
358
359 <!-- ##### FUNCTION gtk_clipboard_wait_for_targets ##### -->
360 <para>
361
362 </para>
363
364 @clipboard: 
365 @targets: 
366 @n_targets: 
367 @Returns: 
368
369 <!--
370 Local variables:
371 mode: sgml
372 sgml-parent-document: ("../gtk-docs.sgml" "book" "refsect2" "")
373 End:
374 -->
375
376
377 <!-- ##### FUNCTION gtk_clipboard_wait_is_target_available ##### -->
378 <para>
379
380 </para>
381
382 @clipboard: 
383 @target: 
384 @Returns: 
385
386
387 <!-- ##### FUNCTION gtk_clipboard_set_can_store ##### -->
388 <para>
389
390 </para>
391
392 @clipboard: 
393 @targets: 
394 @n_targets: 
395
396
397 <!-- ##### FUNCTION gtk_clipboard_store ##### -->
398 <para>
399
400 </para>
401
402 @clipboard: 
403
404