1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Clipboard;
26 
27 private import gdk.Display;
28 private import gdk.Event;
29 private import gdkpixbuf.Pixbuf;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import gtk.SelectionData;
34 private import gtk.TargetEntry;
35 private import gtk.TextBuffer;
36 public  import gtkc.gdktypes;
37 private import gtkc.gtk;
38 public  import gtkc.gtktypes;
39 
40 
41 /**
42  * The #GtkClipboard object represents a clipboard of data shared
43  * between different processes or between different widgets in
44  * the same process. Each clipboard is identified by a name encoded as a
45  * #GdkAtom. (Conversion to and from strings can be done with
46  * gdk_atom_intern() and gdk_atom_name().) The default clipboard
47  * corresponds to the “CLIPBOARD” atom; another commonly used clipboard
48  * is the “PRIMARY” clipboard, which, in X, traditionally contains
49  * the currently selected text.
50  * 
51  * To support having a number of different formats on the clipboard
52  * at the same time, the clipboard mechanism allows providing
53  * callbacks instead of the actual data.  When you set the contents
54  * of the clipboard, you can either supply the data directly (via
55  * functions like gtk_clipboard_set_text()), or you can supply a
56  * callback to be called at a later time when the data is needed (via
57  * gtk_clipboard_set_with_data() or gtk_clipboard_set_with_owner().)
58  * Providing a callback also avoids having to make copies of the data
59  * when it is not needed.
60  * 
61  * gtk_clipboard_set_with_data() and gtk_clipboard_set_with_owner()
62  * are quite similar; the choice between the two depends mostly on
63  * which is more convenient in a particular situation.
64  * The former is most useful when you want to have a blob of data
65  * with callbacks to convert it into the various data types that you
66  * advertise. When the @clear_func you provided is called, you
67  * simply free the data blob. The latter is more useful when the
68  * contents of clipboard reflect the internal state of a #GObject
69  * (As an example, for the PRIMARY clipboard, when an entry widget
70  * provides the clipboard’s contents the contents are simply the
71  * text within the selected region.) If the contents change, the
72  * entry widget can call gtk_clipboard_set_with_owner() to update
73  * the timestamp for clipboard ownership, without having to worry
74  * about @clear_func being called.
75  * 
76  * Requesting the data from the clipboard is essentially
77  * asynchronous. If the contents of the clipboard are provided within
78  * the same process, then a direct function call will be made to
79  * retrieve the data, but if they are provided by another process,
80  * then the data needs to be retrieved from the other process, which
81  * may take some time. To avoid blocking the user interface, the call
82  * to request the selection, gtk_clipboard_request_contents() takes a
83  * callback that will be called when the contents are received (or
84  * when the request fails.) If you don’t want to deal with providing
85  * a separate callback, you can also use gtk_clipboard_wait_for_contents().
86  * What this does is run the GLib main loop recursively waiting for
87  * the contents. This can simplify the code flow, but you still have
88  * to be aware that other callbacks in your program can be called
89  * while this recursive mainloop is running.
90  * 
91  * Along with the functions to get the clipboard contents as an
92  * arbitrary data chunk, there are also functions to retrieve
93  * it as text, gtk_clipboard_request_text() and
94  * gtk_clipboard_wait_for_text(). These functions take care of
95  * determining which formats are advertised by the clipboard
96  * provider, asking for the clipboard in the best available format
97  * and converting the results into the UTF-8 encoding. (The standard
98  * form for representing strings in GTK+.)
99  */
100 public class Clipboard : ObjectG
101 {
102 	/** the main Gtk struct */
103 	protected GtkClipboard* gtkClipboard;
104 
105 	/** Get the main Gtk struct */
106 	public GtkClipboard* getClipboardStruct()
107 	{
108 		return gtkClipboard;
109 	}
110 
111 	/** the main Gtk struct as a void* */
112 	protected override void* getStruct()
113 	{
114 		return cast(void*)gtkClipboard;
115 	}
116 
117 	protected override void setStruct(GObject* obj)
118 	{
119 		gtkClipboard = cast(GtkClipboard*)obj;
120 		super.setStruct(obj);
121 	}
122 
123 	/**
124 	 * Sets our main struct and passes it to the parent class.
125 	 */
126 	public this (GtkClipboard* gtkClipboard, bool ownedRef = false)
127 	{
128 		this.gtkClipboard = gtkClipboard;
129 		super(cast(GObject*)gtkClipboard, ownedRef);
130 	}
131 
132 	/**
133 	 */
134 
135 	public static GType getType()
136 	{
137 		return gtk_clipboard_get_type();
138 	}
139 
140 	/**
141 	 * Returns the clipboard object for the given selection.
142 	 * See gtk_clipboard_get_for_display() for complete details.
143 	 *
144 	 * Params:
145 	 *     selection = a #GdkAtom which identifies the clipboard to use
146 	 *
147 	 * Return: the appropriate clipboard object. If no clipboard
148 	 *     already exists, a new one will be created. Once a clipboard
149 	 *     object has been created, it is persistent and, since it is
150 	 *     owned by GTK+, must not be freed or unreffed.
151 	 */
152 	public static Clipboard get(GdkAtom selection)
153 	{
154 		auto p = gtk_clipboard_get(selection);
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return ObjectG.getDObject!(Clipboard)(cast(GtkClipboard*) p);
162 	}
163 
164 	/**
165 	 * Returns the default clipboard object for use with cut/copy/paste menu items
166 	 * and keyboard shortcuts.
167 	 *
168 	 * Params:
169 	 *     display = the #GdkDisplay for which the clipboard is to be retrieved.
170 	 *
171 	 * Return: the default clipboard object.
172 	 *
173 	 * Since: 3.16
174 	 */
175 	public static Clipboard getDefault(Display display)
176 	{
177 		auto p = gtk_clipboard_get_default((display is null) ? null : display.getDisplayStruct());
178 		
179 		if(p is null)
180 		{
181 			return null;
182 		}
183 		
184 		return ObjectG.getDObject!(Clipboard)(cast(GtkClipboard*) p);
185 	}
186 
187 	/**
188 	 * Returns the clipboard object for the given selection.
189 	 * Cut/copy/paste menu items and keyboard shortcuts should use
190 	 * the default clipboard, returned by passing %GDK_SELECTION_CLIPBOARD for @selection.
191 	 * (%GDK_NONE is supported as a synonym for GDK_SELECTION_CLIPBOARD
192 	 * for backwards compatibility reasons.)
193 	 * The currently-selected object or text should be provided on the clipboard
194 	 * identified by #GDK_SELECTION_PRIMARY. Cut/copy/paste menu items
195 	 * conceptually copy the contents of the #GDK_SELECTION_PRIMARY clipboard
196 	 * to the default clipboard, i.e. they copy the selection to what the
197 	 * user sees as the clipboard.
198 	 *
199 	 * (Passing #GDK_NONE is the same as using `gdk_atom_intern
200 	 * ("CLIPBOARD", FALSE)`.
201 	 *
202 	 * See the
203 	 * [FreeDesktop Clipboard Specification](http://www.freedesktop.org/Standards/clipboards-spec)
204 	 * for a detailed discussion of the “CLIPBOARD” vs. “PRIMARY”
205 	 * selections under the X window system. On Win32 the
206 	 * #GDK_SELECTION_PRIMARY clipboard is essentially ignored.)
207 	 *
208 	 * It’s possible to have arbitrary named clipboards; if you do invent
209 	 * new clipboards, you should prefix the selection name with an
210 	 * underscore (because the ICCCM requires that nonstandard atoms are
211 	 * underscore-prefixed), and namespace it as well. For example,
212 	 * if your application called “Foo” has a special-purpose
213 	 * clipboard, you might call it “_FOO_SPECIAL_CLIPBOARD”.
214 	 *
215 	 * Params:
216 	 *     display = the #GdkDisplay for which the clipboard is to be retrieved or created.
217 	 *     selection = a #GdkAtom which identifies the clipboard to use.
218 	 *
219 	 * Return: the appropriate clipboard object. If no
220 	 *     clipboard already exists, a new one will be created. Once a clipboard
221 	 *     object has been created, it is persistent and, since it is owned by
222 	 *     GTK+, must not be freed or unrefd.
223 	 *
224 	 * Since: 2.2
225 	 */
226 	public static Clipboard getForDisplay(Display display, GdkAtom selection)
227 	{
228 		auto p = gtk_clipboard_get_for_display((display is null) ? null : display.getDisplayStruct(), selection);
229 		
230 		if(p is null)
231 		{
232 			return null;
233 		}
234 		
235 		return ObjectG.getDObject!(Clipboard)(cast(GtkClipboard*) p);
236 	}
237 
238 	/**
239 	 * Clears the contents of the clipboard. Generally this should only
240 	 * be called between the time you call gtk_clipboard_set_with_owner()
241 	 * or gtk_clipboard_set_with_data(),
242 	 * and when the @clear_func you supplied is called. Otherwise, the
243 	 * clipboard may be owned by someone else.
244 	 */
245 	public void clear()
246 	{
247 		gtk_clipboard_clear(gtkClipboard);
248 	}
249 
250 	/**
251 	 * Gets the #GdkDisplay associated with @clipboard
252 	 *
253 	 * Return: the #GdkDisplay associated with @clipboard
254 	 *
255 	 * Since: 2.2
256 	 */
257 	public Display getDisplay()
258 	{
259 		auto p = gtk_clipboard_get_display(gtkClipboard);
260 		
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 		
266 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
267 	}
268 
269 	/**
270 	 * If the clipboard contents callbacks were set with
271 	 * gtk_clipboard_set_with_owner(), and the gtk_clipboard_set_with_data() or
272 	 * gtk_clipboard_clear() has not subsequently called, returns the owner set
273 	 * by gtk_clipboard_set_with_owner().
274 	 *
275 	 * Return: the owner of the clipboard, if any;
276 	 *     otherwise %NULL.
277 	 */
278 	public ObjectG getOwner()
279 	{
280 		auto p = gtk_clipboard_get_owner(gtkClipboard);
281 		
282 		if(p is null)
283 		{
284 			return null;
285 		}
286 		
287 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
288 	}
289 
290 	/**
291 	 * Requests the contents of clipboard as the given target.
292 	 * When the results of the result are later received the supplied callback
293 	 * will be called.
294 	 *
295 	 * Params:
296 	 *     target = an atom representing the form into which the clipboard
297 	 *         owner should convert the selection.
298 	 *     callback = A function to call when the results are received
299 	 *         (or the retrieval fails). If the retrieval fails the length field of
300 	 *         @selection_data will be negative.
301 	 *     userData = user data to pass to @callback
302 	 */
303 	public void requestContents(GdkAtom target, GtkClipboardReceivedFunc callback, void* userData)
304 	{
305 		gtk_clipboard_request_contents(gtkClipboard, target, callback, userData);
306 	}
307 
308 	/**
309 	 * Requests the contents of the clipboard as image. When the image is
310 	 * later received, it will be converted to a #GdkPixbuf, and
311 	 * @callback will be called.
312 	 *
313 	 * The @pixbuf parameter to @callback will contain the resulting
314 	 * #GdkPixbuf if the request succeeded, or %NULL if it failed. This
315 	 * could happen for various reasons, in particular if the clipboard
316 	 * was empty or if the contents of the clipboard could not be
317 	 * converted into an image.
318 	 *
319 	 * Params:
320 	 *     callback = a function to call when the image is received,
321 	 *         or the retrieval fails. (It will always be called one way or the other.)
322 	 *     userData = user data to pass to @callback.
323 	 *
324 	 * Since: 2.6
325 	 */
326 	public void requestImage(GtkClipboardImageReceivedFunc callback, void* userData)
327 	{
328 		gtk_clipboard_request_image(gtkClipboard, callback, userData);
329 	}
330 
331 	/**
332 	 * Requests the contents of the clipboard as rich text. When the rich
333 	 * text is later received, @callback will be called.
334 	 *
335 	 * The @text parameter to @callback will contain the resulting rich
336 	 * text if the request succeeded, or %NULL if it failed. The @length
337 	 * parameter will contain @text’s length. This function can fail for
338 	 * various reasons, in particular if the clipboard was empty or if the
339 	 * contents of the clipboard could not be converted into rich text form.
340 	 *
341 	 * Params:
342 	 *     buffer = a #GtkTextBuffer
343 	 *     callback = a function to call when the text is received,
344 	 *         or the retrieval fails. (It will always be called one way or the other.)
345 	 *     userData = user data to pass to @callback.
346 	 *
347 	 * Since: 2.10
348 	 */
349 	public void requestRichText(TextBuffer buffer, GtkClipboardRichTextReceivedFunc callback, void* userData)
350 	{
351 		gtk_clipboard_request_rich_text(gtkClipboard, (buffer is null) ? null : buffer.getTextBufferStruct(), callback, userData);
352 	}
353 
354 	/**
355 	 * Requests the contents of the clipboard as list of supported targets.
356 	 * When the list is later received, @callback will be called.
357 	 *
358 	 * The @targets parameter to @callback will contain the resulting targets if
359 	 * the request succeeded, or %NULL if it failed.
360 	 *
361 	 * Params:
362 	 *     callback = a function to call when the targets are
363 	 *         received, or the retrieval fails. (It will always be called
364 	 *         one way or the other.)
365 	 *     userData = user data to pass to @callback.
366 	 *
367 	 * Since: 2.4
368 	 */
369 	public void requestTargets(GtkClipboardTargetsReceivedFunc callback, void* userData)
370 	{
371 		gtk_clipboard_request_targets(gtkClipboard, callback, userData);
372 	}
373 
374 	/**
375 	 * Requests the contents of the clipboard as text. When the text is
376 	 * later received, it will be converted to UTF-8 if necessary, and
377 	 * @callback will be called.
378 	 *
379 	 * The @text parameter to @callback will contain the resulting text if
380 	 * the request succeeded, or %NULL if it failed. This could happen for
381 	 * various reasons, in particular if the clipboard was empty or if the
382 	 * contents of the clipboard could not be converted into text form.
383 	 *
384 	 * Params:
385 	 *     callback = a function to call when the text is received,
386 	 *         or the retrieval fails. (It will always be called one way or the other.)
387 	 *     userData = user data to pass to @callback.
388 	 */
389 	public void requestText(GtkClipboardTextReceivedFunc callback, void* userData)
390 	{
391 		gtk_clipboard_request_text(gtkClipboard, callback, userData);
392 	}
393 
394 	/**
395 	 * Requests the contents of the clipboard as URIs. When the URIs are
396 	 * later received @callback will be called.
397 	 *
398 	 * The @uris parameter to @callback will contain the resulting array of
399 	 * URIs if the request succeeded, or %NULL if it failed. This could happen
400 	 * for various reasons, in particular if the clipboard was empty or if the
401 	 * contents of the clipboard could not be converted into URI form.
402 	 *
403 	 * Params:
404 	 *     callback = a function to call when the URIs are received,
405 	 *         or the retrieval fails. (It will always be called one way or the other.)
406 	 *     userData = user data to pass to @callback.
407 	 *
408 	 * Since: 2.14
409 	 */
410 	public void requestUris(GtkClipboardURIReceivedFunc callback, void* userData)
411 	{
412 		gtk_clipboard_request_uris(gtkClipboard, callback, userData);
413 	}
414 
415 	/**
416 	 * Hints that the clipboard data should be stored somewhere when the
417 	 * application exits or when gtk_clipboard_store () is called.
418 	 *
419 	 * This value is reset when the clipboard owner changes.
420 	 * Where the clipboard data is stored is platform dependent,
421 	 * see gdk_display_store_clipboard () for more information.
422 	 *
423 	 * Params:
424 	 *     targets = array containing
425 	 *         information about which forms should be stored or %NULL
426 	 *         to indicate that all forms should be stored.
427 	 *     nTargets = number of elements in @targets
428 	 *
429 	 * Since: 2.6
430 	 */
431 	public void setCanStore(TargetEntry[] targets)
432 	{
433 		GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length];
434 		for ( int i = 0; i < targets.length; i++ )
435 		{
436 			targetsArray[i] = *(targets[i].getTargetEntryStruct());
437 		}
438 		
439 		gtk_clipboard_set_can_store(gtkClipboard, targetsArray.ptr, cast(int)targets.length);
440 	}
441 
442 	/**
443 	 * Sets the contents of the clipboard to the given #GdkPixbuf.
444 	 * GTK+ will take responsibility for responding for requests
445 	 * for the image, and for converting the image into the
446 	 * requested format.
447 	 *
448 	 * Params:
449 	 *     pixbuf = a #GdkPixbuf
450 	 *
451 	 * Since: 2.6
452 	 */
453 	public void setImage(Pixbuf pixbuf)
454 	{
455 		gtk_clipboard_set_image(gtkClipboard, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
456 	}
457 
458 	/**
459 	 * Sets the contents of the clipboard to the given UTF-8 string. GTK+ will
460 	 * make a copy of the text and take responsibility for responding
461 	 * for requests for the text, and for converting the text into
462 	 * the requested format.
463 	 *
464 	 * Params:
465 	 *     text = a UTF-8 string.
466 	 *     len = length of @text, in bytes, or -1, in which case
467 	 *         the length will be determined with strlen().
468 	 */
469 	public void setText(string text, int len)
470 	{
471 		gtk_clipboard_set_text(gtkClipboard, Str.toStringz(text), len);
472 	}
473 
474 	/**
475 	 * Virtually sets the contents of the specified clipboard by providing
476 	 * a list of supported formats for the clipboard data and a function
477 	 * to call to get the actual data when it is requested.
478 	 *
479 	 * Params:
480 	 *     targets = array containing information
481 	 *         about the available forms for the clipboard data
482 	 *     nTargets = number of elements in @targets
483 	 *     getFunc = function to call to get the actual clipboard data
484 	 *     clearFunc = when the clipboard contents are set again,
485 	 *         this function will be called, and @get_func will not be subsequently
486 	 *         called.
487 	 *     userData = user data to pass to @get_func and @clear_func.
488 	 *
489 	 * Return: %TRUE if setting the clipboard data succeeded.
490 	 *     If setting the clipboard data failed the provided callback
491 	 *     functions will be ignored.
492 	 */
493 	public bool setWithData(TargetEntry[] targets, GtkClipboardGetFunc getFunc, GtkClipboardClearFunc clearFunc, void* userData)
494 	{
495 		GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length];
496 		for ( int i = 0; i < targets.length; i++ )
497 		{
498 			targetsArray[i] = *(targets[i].getTargetEntryStruct());
499 		}
500 		
501 		return gtk_clipboard_set_with_data(gtkClipboard, targetsArray.ptr, cast(uint)targets.length, getFunc, clearFunc, userData) != 0;
502 	}
503 
504 	/**
505 	 * Virtually sets the contents of the specified clipboard by providing
506 	 * a list of supported formats for the clipboard data and a function
507 	 * to call to get the actual data when it is requested.
508 	 *
509 	 * The difference between this function and gtk_clipboard_set_with_data()
510 	 * is that instead of an generic @user_data pointer, a #GObject is passed
511 	 * in.
512 	 *
513 	 * Params:
514 	 *     targets = array containing information
515 	 *         about the available forms for the clipboard data
516 	 *     nTargets = number of elements in @targets
517 	 *     getFunc = function to call to get the actual clipboard data
518 	 *     clearFunc = when the clipboard contents are set again,
519 	 *         this function will be called, and @get_func will not be subsequently
520 	 *         called
521 	 *     owner = an object that “owns” the data. This object will be passed
522 	 *         to the callbacks when called
523 	 *
524 	 * Return: %TRUE if setting the clipboard data succeeded.
525 	 *     If setting the clipboard data failed the provided callback
526 	 *     functions will be ignored.
527 	 */
528 	public bool setWithOwner(TargetEntry[] targets, GtkClipboardGetFunc getFunc, GtkClipboardClearFunc clearFunc, ObjectG owner)
529 	{
530 		GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length];
531 		for ( int i = 0; i < targets.length; i++ )
532 		{
533 			targetsArray[i] = *(targets[i].getTargetEntryStruct());
534 		}
535 		
536 		return gtk_clipboard_set_with_owner(gtkClipboard, targetsArray.ptr, cast(uint)targets.length, getFunc, clearFunc, (owner is null) ? null : owner.getObjectGStruct()) != 0;
537 	}
538 
539 	/**
540 	 * Stores the current clipboard data somewhere so that it will stay
541 	 * around after the application has quit.
542 	 *
543 	 * Since: 2.6
544 	 */
545 	public void store()
546 	{
547 		gtk_clipboard_store(gtkClipboard);
548 	}
549 
550 	/**
551 	 * Requests the contents of the clipboard using the given target.
552 	 * This function waits for the data to be received using the main
553 	 * loop, so events, timeouts, etc, may be dispatched during the wait.
554 	 *
555 	 * Params:
556 	 *     target = an atom representing the form into which the clipboard
557 	 *         owner should convert the selection.
558 	 *
559 	 * Return: a newly-allocated #GtkSelectionData object or %NULL
560 	 *     if retrieving the given target failed. If non-%NULL,
561 	 *     this value must be freed with gtk_selection_data_free()
562 	 *     when you are finished with it.
563 	 */
564 	public SelectionData waitForContents(GdkAtom target)
565 	{
566 		auto p = gtk_clipboard_wait_for_contents(gtkClipboard, target);
567 		
568 		if(p is null)
569 		{
570 			return null;
571 		}
572 		
573 		return ObjectG.getDObject!(SelectionData)(cast(GtkSelectionData*) p);
574 	}
575 
576 	/**
577 	 * Requests the contents of the clipboard as image and converts
578 	 * the result to a #GdkPixbuf. This function waits for
579 	 * the data to be received using the main loop, so events,
580 	 * timeouts, etc, may be dispatched during the wait.
581 	 *
582 	 * Return: a newly-allocated #GdkPixbuf
583 	 *     object which must be disposed with g_object_unref(), or
584 	 *     %NULL if retrieving the selection data failed. (This could
585 	 *     happen for various reasons, in particular if the clipboard
586 	 *     was empty or if the contents of the clipboard could not be
587 	 *     converted into an image.)
588 	 *
589 	 * Since: 2.6
590 	 */
591 	public Pixbuf waitForImage()
592 	{
593 		auto p = gtk_clipboard_wait_for_image(gtkClipboard);
594 		
595 		if(p is null)
596 		{
597 			return null;
598 		}
599 		
600 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
601 	}
602 
603 	/**
604 	 * Requests the contents of the clipboard as rich text.  This function
605 	 * waits for the data to be received using the main loop, so events,
606 	 * timeouts, etc, may be dispatched during the wait.
607 	 *
608 	 * Params:
609 	 *     buffer = a #GtkTextBuffer
610 	 *     format = return location for the format of the returned data
611 	 *
612 	 * Return: a
613 	 *     newly-allocated binary block of data which must be
614 	 *     freed with g_free(), or %NULL if retrieving the
615 	 *     selection data failed. (This could happen for various
616 	 *     reasons, in particular if the clipboard was empty or
617 	 *     if the contents of the clipboard could not be
618 	 *     converted into text form.)
619 	 *
620 	 * Since: 2.10
621 	 */
622 	public ubyte[] waitForRichText(TextBuffer buffer, out GdkAtom format)
623 	{
624 		size_t length;
625 		
626 		auto p = gtk_clipboard_wait_for_rich_text(gtkClipboard, (buffer is null) ? null : buffer.getTextBufferStruct(), &format, &length);
627 		
628 		return p[0 .. length];
629 	}
630 
631 	/**
632 	 * Returns a list of targets that are present on the clipboard, or %NULL
633 	 * if there aren’t any targets available. The returned list must be
634 	 * freed with g_free().
635 	 * This function waits for the data to be received using the main
636 	 * loop, so events, timeouts, etc, may be dispatched during the wait.
637 	 *
638 	 * Params:
639 	 *     targets = location
640 	 *         to store an array of targets. The result stored here must
641 	 *         be freed with g_free().
642 	 *     nTargets = location to store number of items in @targets.
643 	 *
644 	 * Return: %TRUE if any targets are present on the clipboard,
645 	 *     otherwise %FALSE.
646 	 *
647 	 * Since: 2.4
648 	 */
649 	public bool waitForTargets(out GdkAtom[] targets)
650 	{
651 		GdkAtom* outtargets = null;
652 		int nTargets;
653 		
654 		auto p = gtk_clipboard_wait_for_targets(gtkClipboard, &outtargets, &nTargets) != 0;
655 		
656 		targets = outtargets[0 .. nTargets];
657 		
658 		return p;
659 	}
660 
661 	/**
662 	 * Requests the contents of the clipboard as text and converts
663 	 * the result to UTF-8 if necessary. This function waits for
664 	 * the data to be received using the main loop, so events,
665 	 * timeouts, etc, may be dispatched during the wait.
666 	 *
667 	 * Return: a newly-allocated UTF-8 string which must
668 	 *     be freed with g_free(), or %NULL if retrieving
669 	 *     the selection data failed. (This could happen
670 	 *     for various reasons, in particular if the
671 	 *     clipboard was empty or if the contents of the
672 	 *     clipboard could not be converted into text form.)
673 	 */
674 	public string waitForText()
675 	{
676 		return Str.toString(gtk_clipboard_wait_for_text(gtkClipboard));
677 	}
678 
679 	/**
680 	 * Requests the contents of the clipboard as URIs. This function waits
681 	 * for the data to be received using the main loop, so events,
682 	 * timeouts, etc, may be dispatched during the wait.
683 	 *
684 	 * Return: a newly-allocated %NULL-terminated array of strings which must
685 	 *     be freed with g_strfreev(), or %NULL if retrieving the
686 	 *     selection data failed. (This could happen for various reasons,
687 	 *     in particular if the clipboard was empty or if the contents of
688 	 *     the clipboard could not be converted into URI form.)
689 	 *
690 	 * Since: 2.14
691 	 */
692 	public string[] waitForUris()
693 	{
694 		return Str.toStringArray(gtk_clipboard_wait_for_uris(gtkClipboard));
695 	}
696 
697 	/**
698 	 * Test to see if there is an image available to be pasted
699 	 * This is done by requesting the TARGETS atom and checking
700 	 * if it contains any of the supported image targets. This function
701 	 * waits for the data to be received using the main loop, so events,
702 	 * timeouts, etc, may be dispatched during the wait.
703 	 *
704 	 * This function is a little faster than calling
705 	 * gtk_clipboard_wait_for_image() since it doesn’t need to retrieve
706 	 * the actual image data.
707 	 *
708 	 * Return: %TRUE is there is an image available, %FALSE otherwise.
709 	 *
710 	 * Since: 2.6
711 	 */
712 	public bool waitIsImageAvailable()
713 	{
714 		return gtk_clipboard_wait_is_image_available(gtkClipboard) != 0;
715 	}
716 
717 	/**
718 	 * Test to see if there is rich text available to be pasted
719 	 * This is done by requesting the TARGETS atom and checking
720 	 * if it contains any of the supported rich text targets. This function
721 	 * waits for the data to be received using the main loop, so events,
722 	 * timeouts, etc, may be dispatched during the wait.
723 	 *
724 	 * This function is a little faster than calling
725 	 * gtk_clipboard_wait_for_rich_text() since it doesn’t need to retrieve
726 	 * the actual text.
727 	 *
728 	 * Params:
729 	 *     buffer = a #GtkTextBuffer
730 	 *
731 	 * Return: %TRUE is there is rich text available, %FALSE otherwise.
732 	 *
733 	 * Since: 2.10
734 	 */
735 	public bool waitIsRichTextAvailable(TextBuffer buffer)
736 	{
737 		return gtk_clipboard_wait_is_rich_text_available(gtkClipboard, (buffer is null) ? null : buffer.getTextBufferStruct()) != 0;
738 	}
739 
740 	/**
741 	 * Checks if a clipboard supports pasting data of a given type. This
742 	 * function can be used to determine if a “Paste” menu item should be
743 	 * insensitive or not.
744 	 *
745 	 * If you want to see if there’s text available on the clipboard, use
746 	 * gtk_clipboard_wait_is_text_available () instead.
747 	 *
748 	 * Params:
749 	 *     target = A #GdkAtom indicating which target to look for.
750 	 *
751 	 * Return: %TRUE if the target is available, %FALSE otherwise.
752 	 *
753 	 * Since: 2.6
754 	 */
755 	public bool waitIsTargetAvailable(GdkAtom target)
756 	{
757 		return gtk_clipboard_wait_is_target_available(gtkClipboard, target) != 0;
758 	}
759 
760 	/**
761 	 * Test to see if there is text available to be pasted
762 	 * This is done by requesting the TARGETS atom and checking
763 	 * if it contains any of the supported text targets. This function
764 	 * waits for the data to be received using the main loop, so events,
765 	 * timeouts, etc, may be dispatched during the wait.
766 	 *
767 	 * This function is a little faster than calling
768 	 * gtk_clipboard_wait_for_text() since it doesn’t need to retrieve
769 	 * the actual text.
770 	 *
771 	 * Return: %TRUE is there is text available, %FALSE otherwise.
772 	 */
773 	public bool waitIsTextAvailable()
774 	{
775 		return gtk_clipboard_wait_is_text_available(gtkClipboard) != 0;
776 	}
777 
778 	/**
779 	 * Test to see if there is a list of URIs available to be pasted
780 	 * This is done by requesting the TARGETS atom and checking
781 	 * if it contains the URI targets. This function
782 	 * waits for the data to be received using the main loop, so events,
783 	 * timeouts, etc, may be dispatched during the wait.
784 	 *
785 	 * This function is a little faster than calling
786 	 * gtk_clipboard_wait_for_uris() since it doesn’t need to retrieve
787 	 * the actual URI data.
788 	 *
789 	 * Return: %TRUE is there is an URI list available, %FALSE otherwise.
790 	 *
791 	 * Since: 2.14
792 	 */
793 	public bool waitIsUrisAvailable()
794 	{
795 		return gtk_clipboard_wait_is_uris_available(gtkClipboard) != 0;
796 	}
797 
798 	int[string] connectedSignals;
799 
800 	void delegate(GdkEventOwnerChange*, Clipboard)[] onOwnerChangeListeners;
801 	/**
802 	 * The ::owner-change signal is emitted when GTK+ receives an
803 	 * event that indicates that the ownership of the selection
804 	 * associated with @clipboard has changed.
805 	 *
806 	 * Params:
807 	 *     event = the @GdkEventOwnerChange event
808 	 *
809 	 * Since: 2.6
810 	 */
811 	void addOnOwnerChange(void delegate(GdkEventOwnerChange*, Clipboard) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
812 	{
813 		if ( "owner-change" !in connectedSignals )
814 		{
815 			Signals.connectData(
816 				this,
817 				"owner-change",
818 				cast(GCallback)&callBackOwnerChange,
819 				cast(void*)this,
820 				null,
821 				connectFlags);
822 			connectedSignals["owner-change"] = 1;
823 		}
824 		onOwnerChangeListeners ~= dlg;
825 	}
826 	extern(C) static void callBackOwnerChange(GtkClipboard* clipboardStruct, GdkEventOwnerChange* event, Clipboard _clipboard)
827 	{
828 		foreach ( void delegate(GdkEventOwnerChange*, Clipboard) dlg; _clipboard.onOwnerChangeListeners )
829 		{
830 			dlg(event, _clipboard);
831 		}
832 	}
833 
834 	void delegate(Event, Clipboard)[] onOwnerChangeGenericListeners;
835 	/**
836 	 * The ::owner-change signal is emitted when GTK+ receives an
837 	 * event that indicates that the ownership of the selection
838 	 * associated with @clipboard has changed.
839 	 *
840 	 * Params:
841 	 *     event = the @GdkEventOwnerChange event
842 	 *
843 	 * Since: 2.6
844 	 */
845 	void addOnOwnerChange(void delegate(Event, Clipboard) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
846 	{
847 		if ( "owner-change-generic-event" !in connectedSignals )
848 		{
849 			Signals.connectData(
850 				this,
851 				"owner-change",
852 				cast(GCallback)&callBackOwnerChangeGeneric,
853 				cast(void*)this,
854 				null,
855 				connectFlags);
856 			connectedSignals["owner-change-generic-event"] = 1;
857 		}
858 		onOwnerChangeGenericListeners ~= dlg;
859 	}
860 	extern(C) static void callBackOwnerChangeGeneric(GtkClipboard* clipboardStruct, GdkEvent* event, Clipboard _clipboard)
861 	{
862 		foreach ( void delegate(Event, Clipboard) dlg; _clipboard.onOwnerChangeGenericListeners )
863 		{
864 			dlg(ObjectG.getDObject!(Event)(event), _clipboard);
865 		}
866 	}
867 }