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 = TargetList 29 * strct = GtkTargetList 30 * realStrct= 31 * ctorStrct= 32 * clss = TargetList 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = GBoxed 38 * implements: 39 * prefixes: 40 * - gtk_target_list_ 41 * - gtk_targets_ 42 * - gtk_target_ 43 * omit structs: 44 * omit prefixes: 45 * - gtk_target_entry_ 46 * omit code: 47 * omit signals: 48 * imports: 49 * - gtk.TextBuffer 50 * - gtk.TargetEntry 51 * - gtkc.Loader 52 * - gtkc.paths 53 * structWrap: 54 * - GtkTargetEntry* -> TargetEntry 55 * - GtkTargetList* -> TargetList 56 * - GtkTextBuffer* -> TextBuffer 57 * module aliases: 58 * local aliases: 59 * overrides: 60 */ 61 62 module gtk.TargetList; 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 gtk.TextBuffer; 72 private import gtk.TargetEntry; 73 private import gtkc.Loader; 74 private import gtkc.paths; 75 76 77 78 private import gobject.Boxed; 79 80 /** 81 * The selection mechanism provides the basis for different types 82 * of communication between processes. In particular, drag and drop and 83 * GtkClipboard work via selections. You will very seldom or 84 * never need to use most of the functions in this section directly; 85 * GtkClipboard provides a nicer interface to the same functionality. 86 * 87 * Some of the datatypes defined this section are used in 88 * the GtkClipboard and drag-and-drop API's as well. The 89 * GtkTargetEntry structure and GtkTargetList objects represent 90 * lists of data types that are supported when sending or 91 * receiving data. The GtkSelectionData object is used to 92 * store a chunk of data along with the data type and other 93 * associated information. 94 */ 95 public class TargetList : Boxed 96 { 97 98 /** the main Gtk struct */ 99 protected GtkTargetList* gtkTargetList; 100 101 102 public GtkTargetList* getTargetListStruct() 103 { 104 return gtkTargetList; 105 } 106 107 108 /** the main Gtk struct as a void* */ 109 protected void* getStruct() 110 { 111 return cast(void*)gtkTargetList; 112 } 113 114 /** 115 * Sets our main struct and passes it to the parent class 116 */ 117 public this (GtkTargetList* gtkTargetList) 118 { 119 this.gtkTargetList = gtkTargetList; 120 } 121 122 ~this () 123 { 124 if ( Linker.isLoaded(LIBRARY.GTK) && gtkTargetList !is null ) 125 { 126 gtk_target_list_unref(gtkTargetList); 127 } 128 } 129 130 /** 131 */ 132 133 /** 134 * Creates a new GtkTargetList from an array of GtkTargetEntry. 135 * Params: 136 * targets = Pointer to an array of GtkTargetEntry. [array length=ntargets] 137 * Throws: ConstructionException GTK+ fails to create the object. 138 */ 139 public this (GtkTargetEntry[] targets) 140 { 141 // GtkTargetList * gtk_target_list_new (const GtkTargetEntry *targets, guint ntargets); 142 auto p = gtk_target_list_new(targets.ptr, cast(int) targets.length); 143 if(p is null) 144 { 145 throw new ConstructionException("null returned by gtk_target_list_new(targets.ptr, cast(int) targets.length)"); 146 } 147 this(cast(GtkTargetList*) p); 148 } 149 150 /** 151 * Increases the reference count of a GtkTargetList by one. 152 * Returns: the passed in GtkTargetList. 153 */ 154 public TargetList doref() 155 { 156 // GtkTargetList * gtk_target_list_ref (GtkTargetList *list); 157 auto p = gtk_target_list_ref(gtkTargetList); 158 159 if(p is null) 160 { 161 return null; 162 } 163 164 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 165 } 166 167 /** 168 * Decreases the reference count of a GtkTargetList by one. 169 * If the resulting reference count is zero, frees the list. 170 */ 171 public void unref() 172 { 173 // void gtk_target_list_unref (GtkTargetList *list); 174 gtk_target_list_unref(gtkTargetList); 175 } 176 177 /** 178 * Appends another target to a GtkTargetList. 179 * Params: 180 * target = the interned atom representing the target 181 * flags = the flags for this target 182 * info = an ID that will be passed back to the application 183 */ 184 public void add(GdkAtom target, uint flags, uint info) 185 { 186 // void gtk_target_list_add (GtkTargetList *list, GdkAtom target, guint flags, guint info); 187 gtk_target_list_add(gtkTargetList, target, flags, info); 188 } 189 190 /** 191 * Prepends a table of GtkTargetEntry to a target list. 192 * Params: 193 * targets = the table of GtkTargetEntry. [array length=ntargets] 194 */ 195 public void addTable(GtkTargetEntry[] targets) 196 { 197 // void gtk_target_list_add_table (GtkTargetList *list, const GtkTargetEntry *targets, guint ntargets); 198 gtk_target_list_add_table(gtkTargetList, targets.ptr, cast(int) targets.length); 199 } 200 201 /** 202 * Appends the text targets supported by GtkSelection to 203 * the target list. All targets are added with the same info. 204 * Since 2.6 205 * Params: 206 * info = an ID that will be passed back to the application 207 */ 208 public void addTextTargets(uint info) 209 { 210 // void gtk_target_list_add_text_targets (GtkTargetList *list, guint info); 211 gtk_target_list_add_text_targets(gtkTargetList, info); 212 } 213 214 /** 215 * Appends the image targets supported by GtkSelection to 216 * the target list. All targets are added with the same info. 217 * Since 2.6 218 * Params: 219 * info = an ID that will be passed back to the application 220 * writable = whether to add only targets for which GTK+ knows 221 * how to convert a pixbuf into the format 222 */ 223 public void addImageTargets(uint info, int writable) 224 { 225 // void gtk_target_list_add_image_targets (GtkTargetList *list, guint info, gboolean writable); 226 gtk_target_list_add_image_targets(gtkTargetList, info, writable); 227 } 228 229 /** 230 * Appends the URI targets supported by GtkSelection to 231 * the target list. All targets are added with the same info. 232 * Since 2.6 233 * Params: 234 * info = an ID that will be passed back to the application 235 */ 236 public void addUriTargets(uint info) 237 { 238 // void gtk_target_list_add_uri_targets (GtkTargetList *list, guint info); 239 gtk_target_list_add_uri_targets(gtkTargetList, info); 240 } 241 242 /** 243 * Appends the rich text targets registered with 244 * gtk_text_buffer_register_serialize_format() or 245 * gtk_text_buffer_register_deserialize_format() to the target list. All 246 * targets are added with the same info. 247 * Since 2.10 248 * Params: 249 * info = an ID that will be passed back to the application 250 * deserializable = if TRUE, then deserializable rich text formats 251 * will be added, serializable formats otherwise. 252 * buffer = a GtkTextBuffer. 253 */ 254 public void addRichTextTargets(uint info, int deserializable, TextBuffer buffer) 255 { 256 // void gtk_target_list_add_rich_text_targets (GtkTargetList *list, guint info, gboolean deserializable, GtkTextBuffer *buffer); 257 gtk_target_list_add_rich_text_targets(gtkTargetList, info, deserializable, (buffer is null) ? null : buffer.getTextBufferStruct()); 258 } 259 260 /** 261 * Removes a target from a target list. 262 * Params: 263 * target = the interned atom representing the target 264 */ 265 public void remove(GdkAtom target) 266 { 267 // void gtk_target_list_remove (GtkTargetList *list, GdkAtom target); 268 gtk_target_list_remove(gtkTargetList, target); 269 } 270 271 /** 272 * Looks up a given target in a GtkTargetList. 273 * Params: 274 * target = an interned atom representing the target to search for 275 * info = a pointer to the location to store 276 * application info for target, or NULL. [out][allow-none] 277 * Returns: TRUE if the target was found, otherwise FALSE 278 */ 279 public int find(GdkAtom target, out uint info) 280 { 281 // gboolean gtk_target_list_find (GtkTargetList *list, GdkAtom target, guint *info); 282 return gtk_target_list_find(gtkTargetList, target, &info); 283 } 284 285 /** 286 * This function frees a target table as returned by 287 * gtk_target_table_new_from_list() 288 * Since 2.10 289 * Params: 290 * targets = a GtkTargetEntry array. [array length=n_targets] 291 */ 292 public static void tableFree(GtkTargetEntry[] targets) 293 { 294 // void gtk_target_table_free (GtkTargetEntry *targets, gint n_targets); 295 gtk_target_table_free(targets.ptr, cast(int) targets.length); 296 } 297 298 /** 299 * This function creates an GtkTargetEntry array that contains the 300 * same targets as the passed list. The returned table is newly 301 * allocated and should be freed using gtk_target_table_free() when no 302 * longer needed. 303 * Since 2.10 304 * Returns: the new table. [array length=n_targets][transfer full] 305 */ 306 public GtkTargetEntry[] tableNewFromList() 307 { 308 // GtkTargetEntry * gtk_target_table_new_from_list (GtkTargetList *list, gint *n_targets); 309 int nTargets; 310 auto p = gtk_target_table_new_from_list(gtkTargetList, &nTargets); 311 312 if(p is null) 313 { 314 return null; 315 } 316 317 return p[0 .. nTargets]; 318 } 319 320 /** 321 * Determines if any of the targets in targets can be used to 322 * provide a GdkPixbuf. 323 * Since 2.10 324 * Params: 325 * targets = an array of GdkAtoms. [array length=n_targets] 326 * writable = whether to accept only targets for which GTK+ knows 327 * how to convert a pixbuf into the format 328 * Returns: TRUE if targets include a suitable target for images, otherwise FALSE. 329 */ 330 public static int includeImage(GdkAtom[] targets, int writable) 331 { 332 // gboolean gtk_targets_include_image (GdkAtom *targets, gint n_targets, gboolean writable); 333 return gtk_targets_include_image(targets.ptr, cast(int) targets.length, writable); 334 } 335 336 /** 337 * Determines if any of the targets in targets can be used to 338 * provide text. 339 * Since 2.10 340 * Params: 341 * targets = an array of GdkAtoms. [array length=n_targets] 342 * Returns: TRUE if targets include a suitable target for text, otherwise FALSE. 343 */ 344 public static int includeText(GdkAtom[] targets) 345 { 346 // gboolean gtk_targets_include_text (GdkAtom *targets, gint n_targets); 347 return gtk_targets_include_text(targets.ptr, cast(int) targets.length); 348 } 349 350 /** 351 * Determines if any of the targets in targets can be used to 352 * provide an uri list. 353 * Since 2.10 354 * Params: 355 * targets = an array of GdkAtoms. [array length=n_targets] 356 * Returns: TRUE if targets include a suitable target for uri lists, otherwise FALSE. 357 */ 358 public static int includeUri(GdkAtom[] targets) 359 { 360 // gboolean gtk_targets_include_uri (GdkAtom *targets, gint n_targets); 361 return gtk_targets_include_uri(targets.ptr, cast(int) targets.length); 362 } 363 364 /** 365 * Determines if any of the targets in targets can be used to 366 * provide rich text. 367 * Since 2.10 368 * Params: 369 * targets = an array of GdkAtoms. [array length=n_targets] 370 * buffer = a GtkTextBuffer 371 * Returns: TRUE if targets include a suitable target for rich text, otherwise FALSE. 372 */ 373 public static int includeRichText(GdkAtom[] targets, TextBuffer buffer) 374 { 375 // gboolean gtk_targets_include_rich_text (GdkAtom *targets, gint n_targets, GtkTextBuffer *buffer); 376 return gtk_targets_include_rich_text(targets.ptr, cast(int) targets.length, (buffer is null) ? null : buffer.getTextBufferStruct()); 377 } 378 }