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