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 gtk.c.functions; 32 public import gtk.c.types; 33 public import gtkc.gtktypes; 34 private import gtkd.Loader; 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(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gtkTargetList; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected void* getStruct() 58 { 59 return cast(void*)gtkTargetList; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkTargetList* gtkTargetList, bool ownedRef = false) 66 { 67 this.gtkTargetList = gtkTargetList; 68 this.ownedRef = ownedRef; 69 } 70 71 ~this () 72 { 73 if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef ) 74 gtk_target_list_unref(gtkTargetList); 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 * 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 */ 167 public void addTable(TargetEntry[] targets) 168 { 169 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 170 for ( int i = 0; i < targets.length; i++ ) 171 { 172 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 173 } 174 175 gtk_target_list_add_table(gtkTargetList, targetsArray.ptr, cast(uint)targets.length); 176 } 177 178 /** 179 * Appends the text targets supported by #GtkSelectionData to 180 * the target list. All targets are added with the same @info. 181 * 182 * Params: 183 * info = an ID that will be passed back to the application 184 * 185 * Since: 2.6 186 */ 187 public void addTextTargets(uint info) 188 { 189 gtk_target_list_add_text_targets(gtkTargetList, info); 190 } 191 192 /** 193 * Appends the URI targets supported by #GtkSelectionData to 194 * the target list. All targets are added with the same @info. 195 * 196 * Params: 197 * info = an ID that will be passed back to the application 198 * 199 * Since: 2.6 200 */ 201 public void addUriTargets(uint info) 202 { 203 gtk_target_list_add_uri_targets(gtkTargetList, info); 204 } 205 206 /** 207 * Looks up a given target in a #GtkTargetList. 208 * 209 * Params: 210 * target = an interned atom representing the target to search for 211 * info = a pointer to the location to store 212 * application info for target, or %NULL 213 * 214 * Returns: %TRUE if the target was found, otherwise %FALSE 215 */ 216 public bool find(GdkAtom target, out uint info) 217 { 218 return gtk_target_list_find(gtkTargetList, target, &info) != 0; 219 } 220 221 /** 222 * Increases the reference count of a #GtkTargetList by one. 223 * 224 * Returns: the passed in #GtkTargetList. 225 */ 226 public TargetList doref() 227 { 228 auto p = gtk_target_list_ref(gtkTargetList); 229 230 if(p is null) 231 { 232 return null; 233 } 234 235 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p, true); 236 } 237 238 /** 239 * Removes a target from a target list. 240 * 241 * Params: 242 * target = the interned atom representing the target 243 */ 244 public void remove(GdkAtom target) 245 { 246 gtk_target_list_remove(gtkTargetList, target); 247 } 248 249 /** 250 * Decreases the reference count of a #GtkTargetList by one. 251 * If the resulting reference count is zero, frees the list. 252 */ 253 public void unref() 254 { 255 gtk_target_list_unref(gtkTargetList); 256 } 257 258 /** 259 * This function frees a target table as returned by 260 * gtk_target_table_new_from_list() 261 * 262 * Params: 263 * targets = a #GtkTargetEntry array 264 * 265 * Since: 2.10 266 */ 267 public static void targetTableFree(TargetEntry[] targets) 268 { 269 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 270 for ( int i = 0; i < targets.length; i++ ) 271 { 272 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 273 } 274 275 gtk_target_table_free(targetsArray.ptr, cast(int)targets.length); 276 } 277 278 /** 279 * This function creates an #GtkTargetEntry array that contains the 280 * same targets as the passed %list. The returned table is newly 281 * allocated and should be freed using gtk_target_table_free() when no 282 * longer needed. 283 * 284 * Params: 285 * list = a #GtkTargetList 286 * 287 * Returns: the new table. 288 * 289 * Since: 2.10 290 */ 291 public static TargetEntry[] targetTableNewFromList(TargetList list) 292 { 293 int nTargets; 294 295 auto p = gtk_target_table_new_from_list((list is null) ? null : list.getTargetListStruct(), &nTargets); 296 297 if(p is null) 298 { 299 return null; 300 } 301 302 TargetEntry[] arr = new TargetEntry[nTargets]; 303 for(int i = 0; i < nTargets; i++) 304 { 305 arr[i] = ObjectG.getDObject!(TargetEntry)(cast(GtkTargetEntry*) &p[i]); 306 } 307 308 return arr; 309 } 310 311 /** 312 * Determines if any of the targets in @targets can be used to 313 * provide a #GdkPixbuf. 314 * 315 * Params: 316 * targets = an array of #GdkAtoms 317 * writable = whether to accept only targets for which GTK+ knows 318 * how to convert a pixbuf into the format 319 * 320 * Returns: %TRUE if @targets include a suitable target for images, 321 * otherwise %FALSE. 322 * 323 * Since: 2.10 324 */ 325 public static bool includeImage(GdkAtom[] targets, bool writable) 326 { 327 return gtk_targets_include_image(targets.ptr, cast(int)targets.length, writable) != 0; 328 } 329 330 /** 331 * Determines if any of the targets in @targets can be used to 332 * provide rich text. 333 * 334 * Params: 335 * targets = an array of #GdkAtoms 336 * buffer = a #GtkTextBuffer 337 * 338 * Returns: %TRUE if @targets include a suitable target for rich text, 339 * otherwise %FALSE. 340 * 341 * Since: 2.10 342 */ 343 public static bool includeRichTex(GdkAtom[] targets, TextBuffer buffer) 344 { 345 return gtk_targets_include_rich_text(targets.ptr, cast(int)targets.length, (buffer is null) ? null : buffer.getTextBufferStruct()) != 0; 346 } 347 348 /** 349 * Determines if any of the targets in @targets can be used to 350 * provide text. 351 * 352 * Params: 353 * targets = an array of #GdkAtoms 354 * 355 * Returns: %TRUE if @targets include a suitable target for text, 356 * otherwise %FALSE. 357 * 358 * Since: 2.10 359 */ 360 public static bool includeText(GdkAtom[] targets) 361 { 362 return gtk_targets_include_text(targets.ptr, cast(int)targets.length) != 0; 363 } 364 365 /** 366 * Determines if any of the targets in @targets can be used to 367 * provide an uri list. 368 * 369 * Params: 370 * targets = an array of #GdkAtoms 371 * 372 * Returns: %TRUE if @targets include a suitable target for uri lists, 373 * otherwise %FALSE. 374 * 375 * Since: 2.10 376 */ 377 public static bool includeUri(GdkAtom[] targets) 378 { 379 return gtk_targets_include_uri(targets.ptr, cast(int)targets.length) != 0; 380 } 381 }