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