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