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