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