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