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 * Conversion parameters: 26 * inFile = 27 * outPack = gtk 28 * outFile = Selections 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = Selections 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_selection_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gdk.Display 48 * - gtk.Widget 49 * - gdk.Display 50 * - gdk.Pixbuf 51 * - gtk.TextBuffer 52 * structWrap: 53 * - GdkDisplay* -> Display 54 * - GdkPixbuf* -> Pixbuf 55 * - GtkTextBuffer* -> TextBuffer 56 * - GtkWidget* -> Widget 57 * module aliases: 58 * local aliases: 59 * overrides: 60 */ 61 62 module gtk.Selections; 63 64 public import gtkc.gtktypes; 65 66 private import gtkc.gtk; 67 private import glib.ConstructionException; 68 private import gobject.ObjectG; 69 70 71 private import glib.Str; 72 private import gdk.Display; 73 private import gtk.Widget; 74 private import gdk.Display; 75 private import gdk.Pixbuf; 76 private import gtk.TextBuffer; 77 78 79 80 81 /** 82 * Description 83 * The selection mechanism provides the basis for different types 84 * of communication between processes. In particular, drag and drop and 85 * GtkClipboard work via selections. You will very seldom or 86 * never need to use most of the functions in this section directly; 87 * GtkClipboard provides a nicer interface to the same functionality. 88 * Some of the datatypes defined this section are used in 89 * the GtkClipboard and drag-and-drop API's as well. The 90 * GtkTargetEntry structure and GtkTargetList objects represent 91 * lists of data types that are supported when sending or 92 * receiving data. The GtkSelectionData object is used to 93 * store a chunk of data along with the data type and other 94 * associated information. 95 */ 96 public class Selections 97 { 98 99 /** 100 */ 101 102 /** 103 * Claims ownership of a given selection for a particular widget, 104 * or, if widget is NULL, release ownership of the selection. 105 * Params: 106 * widget = a GtkWidget, or NULL. [allow-none] 107 * selection = an interned atom representing the selection to claim 108 * time = timestamp with which to claim the selection 109 * Returns: TRUE if the operation succeeded 110 */ 111 public static int ownerSet(Widget widget, GdkAtom selection, uint time) 112 { 113 // gboolean gtk_selection_owner_set (GtkWidget *widget, GdkAtom selection, guint32 time_); 114 return gtk_selection_owner_set((widget is null) ? null : widget.getWidgetStruct(), selection, time); 115 } 116 117 /** 118 * Claim ownership of a given selection for a particular widget, or, 119 * if widget is NULL, release ownership of the selection. 120 * Since 2.2 121 * Params: 122 * display = the Gdkdisplay where the selection is set 123 * widget = new selection owner (a GdkWidget), or NULL. [allow-none] 124 * selection = an interned atom representing the selection to claim. 125 * time = timestamp with which to claim the selection 126 * Returns: TRUE if the operation succeeded 127 */ 128 public static int ownerSetForDisplay(Display display, Widget widget, GdkAtom selection, uint time) 129 { 130 // gboolean gtk_selection_owner_set_for_display (GdkDisplay *display, GtkWidget *widget, GdkAtom selection, guint32 time_); 131 return gtk_selection_owner_set_for_display((display is null) ? null : display.getDisplayStruct(), (widget is null) ? null : widget.getWidgetStruct(), selection, time); 132 } 133 134 /** 135 * Appends a specified target to the list of supported targets for a 136 * given widget and selection. 137 * Params: 138 * widget = a GtkTarget 139 * selection = the selection 140 * target = target to add. 141 * info = A unsigned integer which will be passed back to the application. 142 */ 143 public static void addTarget(Widget widget, GdkAtom selection, GdkAtom target, uint info) 144 { 145 // void gtk_selection_add_target (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint info); 146 gtk_selection_add_target((widget is null) ? null : widget.getWidgetStruct(), selection, target, info); 147 } 148 149 /** 150 * Prepends a table of targets to the list of supported targets 151 * for a given widget and selection. 152 * Params: 153 * widget = a GtkWidget 154 * selection = the selection 155 * targets = a table of targets to add. [array length=ntargets] 156 */ 157 public static void addTargets(Widget widget, GdkAtom selection, GtkTargetEntry[] targets) 158 { 159 // void gtk_selection_add_targets (GtkWidget *widget, GdkAtom selection, const GtkTargetEntry *targets, guint ntargets); 160 gtk_selection_add_targets((widget is null) ? null : widget.getWidgetStruct(), selection, targets.ptr, cast(int) targets.length); 161 } 162 163 /** 164 * Remove all targets registered for the given selection for the 165 * widget. 166 * Params: 167 * widget = a GtkWidget 168 * selection = an atom representing a selection 169 */ 170 public static void clearTargets(Widget widget, GdkAtom selection) 171 { 172 // void gtk_selection_clear_targets (GtkWidget *widget, GdkAtom selection); 173 gtk_selection_clear_targets((widget is null) ? null : widget.getWidgetStruct(), selection); 174 } 175 176 /** 177 * Requests the contents of a selection. When received, 178 * a "selection-received" signal will be generated. 179 * Params: 180 * widget = The widget which acts as requestor 181 * selection = Which selection to get 182 * target = Form of information desired (e.g., STRING) 183 * time = Time of request (usually of triggering event) 184 * In emergency, you could use GDK_CURRENT_TIME 185 * Returns: TRUE if requested succeeded. FALSE if we could not process request. (e.g., there was already a request in process for this widget). 186 */ 187 public static int convert(Widget widget, GdkAtom selection, GdkAtom target, uint time) 188 { 189 // gboolean gtk_selection_convert (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint32 time_); 190 return gtk_selection_convert((widget is null) ? null : widget.getWidgetStruct(), selection, target, time); 191 } 192 193 /** 194 * Stores new data into a GtkSelectionData object. Should 195 * only be called from a selection handler callback. 196 * Zero-terminates the stored data. 197 * Params: 198 * selectionData = a pointer to a GtkSelectionData structure. 199 * type = the type of selection data 200 * format = format (number of bits in a unit) 201 * data = pointer to the data (will be copied). [array length=length] 202 */ 203 public static void dataSet(GtkSelectionData* selectionData, GdkAtom type, int format, char[] data) 204 { 205 // void gtk_selection_data_set (GtkSelectionData *selection_data, GdkAtom type, gint format, const guchar *data, gint length); 206 gtk_selection_data_set(selectionData, type, format, data.ptr, cast(int) data.length); 207 } 208 209 /** 210 * Sets the contents of the selection from a UTF-8 encoded string. 211 * The string is converted to the form determined by 212 * selection_data->target. 213 * Params: 214 * selectionData = a GtkSelectionData 215 * str = a UTF-8 string 216 * len = the length of str, or -1 if str is nul-terminated. 217 * Returns: TRUE if the selection was successfully set, otherwise FALSE. 218 */ 219 public static int dataSetText(GtkSelectionData* selectionData, string str, int len) 220 { 221 // gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, const gchar *str, gint len); 222 return gtk_selection_data_set_text(selectionData, Str.toStringz(str), len); 223 } 224 225 /** 226 * Gets the contents of the selection data as a UTF-8 string. 227 * Params: 228 * selectionData = a GtkSelectionData 229 * Returns: if the selection data contained a recognized text type and it could be converted to UTF-8, a newly allocated string containing the converted text, otherwise NULL. If the result is non-NULL it must be freed with g_free(). 230 */ 231 public static char* dataGetText(GtkSelectionData* selectionData) 232 { 233 // guchar * gtk_selection_data_get_text (GtkSelectionData *selection_data); 234 return gtk_selection_data_get_text(selectionData); 235 } 236 237 /** 238 * Sets the contents of the selection from a GdkPixbuf 239 * The pixbuf is converted to the form determined by 240 * selection_data->target. 241 * Since 2.6 242 * Params: 243 * selectionData = a GtkSelectionData 244 * pixbuf = a GdkPixbuf 245 * Returns: TRUE if the selection was successfully set, otherwise FALSE. 246 */ 247 public static int dataSetPixbuf(GtkSelectionData* selectionData, Pixbuf pixbuf) 248 { 249 // gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, GdkPixbuf *pixbuf); 250 return gtk_selection_data_set_pixbuf(selectionData, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 251 } 252 253 /** 254 * Gets the contents of the selection data as a GdkPixbuf. 255 * Since 2.6 256 * Params: 257 * selectionData = a GtkSelectionData 258 * Returns: if the selection data contained a recognized image type and it could be converted to a GdkPixbuf, a newly allocated pixbuf is returned, otherwise NULL. If the result is non-NULL it must be freed with g_object_unref(). [transfer full] 259 */ 260 public static Pixbuf dataGetPixbuf(GtkSelectionData* selectionData) 261 { 262 // GdkPixbuf * gtk_selection_data_get_pixbuf (GtkSelectionData *selection_data); 263 auto p = gtk_selection_data_get_pixbuf(selectionData); 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 271 } 272 273 /** 274 * Sets the contents of the selection from a list of URIs. 275 * The string is converted to the form determined by 276 * selection_data->target. 277 * Since 2.6 278 * Params: 279 * selectionData = a GtkSelectionData 280 * uris = a NULL-terminated array of 281 * strings holding URIs. [array zero-terminated=1] 282 * Returns: TRUE if the selection was successfully set, otherwise FALSE. 283 */ 284 public static int dataSetUris(GtkSelectionData* selectionData, string[] uris) 285 { 286 // gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data, gchar **uris); 287 return gtk_selection_data_set_uris(selectionData, Str.toStringzArray(uris)); 288 } 289 290 /** 291 * Gets the contents of the selection data as array of URIs. 292 * Since 2.6 293 * Params: 294 * selectionData = a GtkSelectionData 295 * Returns: if the selection data contains a list of URIs, a newly allocated NULL-terminated string array containing the URIs, otherwise NULL. If the result is non-NULL it must be freed with g_strfreev(). [array zero-terminated=1][element-type utf8][transfer full] 296 */ 297 public static string[] dataGetUris(GtkSelectionData* selectionData) 298 { 299 // gchar ** gtk_selection_data_get_uris (GtkSelectionData *selection_data); 300 return Str.toStringArray(gtk_selection_data_get_uris(selectionData)); 301 } 302 303 /** 304 * Gets the contents of selection_data as an array of targets. 305 * This can be used to interpret the results of getting 306 * the standard TARGETS target that is always supplied for 307 * any selection. 308 * Params: 309 * selectionData = a GtkSelectionData object 310 * targets = location to store an array of targets. The result 311 * stored here must be freed with g_free(). [out][array length=n_atoms][transfer container] 312 * Returns: TRUE if selection_data contains a valid array of targets, otherwise FALSE. 313 */ 314 public static int dataGetTargets(GtkSelectionData* selectionData, out GdkAtom[] targets) 315 { 316 // gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data, GdkAtom **targets, gint *n_atoms); 317 GdkAtom* outtargets = null; 318 int nAtoms; 319 320 auto p = gtk_selection_data_get_targets(selectionData, &outtargets, &nAtoms); 321 322 targets = outtargets[0 .. nAtoms]; 323 return p; 324 } 325 326 /** 327 * Given a GtkSelectionData object holding a list of targets, 328 * determines if any of the targets in targets can be used to 329 * provide a GdkPixbuf. 330 * Since 2.6 331 * Params: 332 * selectionData = a GtkSelectionData object 333 * writable = whether to accept only targets for which GTK+ knows 334 * how to convert a pixbuf into the format 335 * Returns: TRUE if selection_data holds a list of targets, and a suitable target for images is included, otherwise FALSE. 336 */ 337 public static int dataTargetsIncludeImage(GtkSelectionData* selectionData, int writable) 338 { 339 // gboolean gtk_selection_data_targets_include_image (GtkSelectionData *selection_data, gboolean writable); 340 return gtk_selection_data_targets_include_image(selectionData, writable); 341 } 342 343 /** 344 * Given a GtkSelectionData object holding a list of targets, 345 * determines if any of the targets in targets can be used to 346 * provide text. 347 * Params: 348 * selectionData = a GtkSelectionData object 349 * Returns: TRUE if selection_data holds a list of targets, and a suitable target for text is included, otherwise FALSE. 350 */ 351 public static int dataTargetsIncludeText(GtkSelectionData* selectionData) 352 { 353 // gboolean gtk_selection_data_targets_include_text (GtkSelectionData *selection_data); 354 return gtk_selection_data_targets_include_text(selectionData); 355 } 356 357 /** 358 * Given a GtkSelectionData object holding a list of targets, 359 * determines if any of the targets in targets can be used to 360 * provide a list or URIs. 361 * Since 2.10 362 * Params: 363 * selectionData = a GtkSelectionData object 364 * Returns: TRUE if selection_data holds a list of targets, and a suitable target for URI lists is included, otherwise FALSE. 365 */ 366 public static int dataTargetsIncludeUri(GtkSelectionData* selectionData) 367 { 368 // gboolean gtk_selection_data_targets_include_uri (GtkSelectionData *selection_data); 369 return gtk_selection_data_targets_include_uri(selectionData); 370 } 371 372 /** 373 * Given a GtkSelectionData object holding a list of targets, 374 * determines if any of the targets in targets can be used to 375 * provide rich text. 376 * Since 2.10 377 * Params: 378 * selectionData = a GtkSelectionData object 379 * buffer = a GtkTextBuffer 380 * Returns: TRUE if selection_data holds a list of targets, and a suitable target for rich text is included, otherwise FALSE. 381 */ 382 public static int dataTargetsIncludeRichText(GtkSelectionData* selectionData, TextBuffer buffer) 383 { 384 // gboolean gtk_selection_data_targets_include_rich_text (GtkSelectionData *selection_data, GtkTextBuffer *buffer); 385 return gtk_selection_data_targets_include_rich_text(selectionData, (buffer is null) ? null : buffer.getTextBufferStruct()); 386 } 387 388 /** 389 * Retrieves the selection GdkAtom of the selection data. 390 * Since 2.16 391 * Params: 392 * selectionData = a pointer to a GtkSelectionData structure. 393 * Returns: the selection GdkAtom of the selection data. [transfer none] 394 */ 395 public static GdkAtom dataGetSelection(GtkSelectionData* selectionData) 396 { 397 // GdkAtom gtk_selection_data_get_selection (GtkSelectionData *selection_data); 398 return gtk_selection_data_get_selection(selectionData); 399 } 400 401 /** 402 * Retrieves the raw data of the selection. 403 * Since 2.14 404 * Params: 405 * selectionData = a pointer to a GtkSelectionData structure. 406 * Returns: the raw data of the selection. 407 */ 408 public static char* dataGetData(GtkSelectionData* selectionData) 409 { 410 // const guchar * gtk_selection_data_get_data (GtkSelectionData *selection_data); 411 return gtk_selection_data_get_data(selectionData); 412 } 413 414 /** 415 * Retrieves the length of the raw data of the selection. 416 * Since 2.14 417 * Params: 418 * selectionData = a pointer to a GtkSelectionData structure. 419 * Returns: the length of the data of the selection. 420 */ 421 public static int dataGetLength(GtkSelectionData* selectionData) 422 { 423 // gint gtk_selection_data_get_length (GtkSelectionData *selection_data); 424 return gtk_selection_data_get_length(selectionData); 425 } 426 427 /** 428 * Retrieves the data type of the selection. 429 * Since 2.14 430 * Params: 431 * selectionData = a pointer to a GtkSelectionData structure. 432 * Returns: the data type of the selection. [transfer none] 433 */ 434 public static GdkAtom dataGetDataType(GtkSelectionData* selectionData) 435 { 436 // GdkAtom gtk_selection_data_get_data_type (GtkSelectionData *selection_data); 437 return gtk_selection_data_get_data_type(selectionData); 438 } 439 440 /** 441 * Retrieves the display of the selection. 442 * Since 2.14 443 * Params: 444 * selectionData = a pointer to a GtkSelectionData structure. 445 * Returns: the display of the selection. [transfer none] 446 */ 447 public static Display dataGetDisplay(GtkSelectionData* selectionData) 448 { 449 // GdkDisplay * gtk_selection_data_get_display (GtkSelectionData *selection_data); 450 auto p = gtk_selection_data_get_display(selectionData); 451 452 if(p is null) 453 { 454 return null; 455 } 456 457 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 458 } 459 460 /** 461 * Retrieves the format of the selection. 462 * Since 2.14 463 * Params: 464 * selectionData = a pointer to a GtkSelectionData structure. 465 * Returns: the format of the selection. 466 */ 467 public static int dataGetFormat(GtkSelectionData* selectionData) 468 { 469 // gint gtk_selection_data_get_format (GtkSelectionData *selection_data); 470 return gtk_selection_data_get_format(selectionData); 471 } 472 473 /** 474 * Retrieves the target of the selection. 475 * Since 2.14 476 * Params: 477 * selectionData = a pointer to a GtkSelectionData structure. 478 * Returns: the target of the selection. [transfer none] 479 */ 480 public static GdkAtom dataGetTarget(GtkSelectionData* selectionData) 481 { 482 // GdkAtom gtk_selection_data_get_target (GtkSelectionData *selection_data); 483 return gtk_selection_data_get_target(selectionData); 484 } 485 486 /** 487 * Removes all handlers and unsets ownership of all 488 * selections for a widget. Called when widget is being 489 * destroyed. This function will not generally be 490 * called by applications. 491 * Params: 492 * widget = a GtkWidget 493 */ 494 public static void removeAll(Widget widget) 495 { 496 // void gtk_selection_remove_all (GtkWidget *widget); 497 gtk_selection_remove_all((widget is null) ? null : widget.getWidgetStruct()); 498 } 499 500 /** 501 * Warning 502 * gtk_selection_clear has been deprecated since version 2.4 and should not be used in newly-written code. Instead of calling this function, chain up from 503 * your selection-clear-event handler. Calling this function 504 * from any other context is illegal. 505 * The default handler for the "selection-clear-event" 506 * signal. 507 * Since 2.2 508 * Params: 509 * widget = a GtkWidget 510 * event = the event 511 * Returns: TRUE if the event was handled, otherwise false 512 */ 513 public static int clear(Widget widget, GdkEventSelection* event) 514 { 515 // gboolean gtk_selection_clear (GtkWidget *widget, GdkEventSelection *event); 516 return gtk_selection_clear((widget is null) ? null : widget.getWidgetStruct(), event); 517 } 518 519 /** 520 * Makes a copy of a GtkSelectionData structure and its data. 521 * Params: 522 * data = a pointer to a GtkSelectionData structure. 523 * Returns: a pointer to a copy of data. 524 */ 525 public static GtkSelectionData* dataCopy(GtkSelectionData* data) 526 { 527 // GtkSelectionData * gtk_selection_data_copy (GtkSelectionData *data); 528 return gtk_selection_data_copy(data); 529 } 530 531 /** 532 * Frees a GtkSelectionData structure returned from 533 * gtk_selection_data_copy(). 534 * Params: 535 * data = a pointer to a GtkSelectionData structure. 536 */ 537 public static void dataFree(GtkSelectionData* data) 538 { 539 // void gtk_selection_data_free (GtkSelectionData *data); 540 gtk_selection_data_free(data); 541 } 542 }