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.TargetEntry;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtkc.gtk;
31 public  import gtkc.gtktypes;
32 private import gtkd.Loader;
33 
34 
35 /**
36  * A #GtkTargetEntry represents a single type of
37  * data than can be supplied for by a widget for a selection
38  * or for supplied or received during drag-and-drop.
39  */
40 public class TargetEntry
41 {
42 	/** the main Gtk struct */
43 	protected GtkTargetEntry* gtkTargetEntry;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GtkTargetEntry* getTargetEntryStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkTargetEntry;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gtkTargetEntry;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkTargetEntry* gtkTargetEntry, bool ownedRef = false)
64 	{
65 		this.gtkTargetEntry = gtkTargetEntry;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 	~this ()
70 	{
71 		if (  Linker.isLoaded(LIBRARY_GTK) && ownedRef )
72 			gtk_target_entry_free(gtkTargetEntry);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_target_entry_get_type();
80 	}
81 
82 	/**
83 	 * Makes a new #GtkTargetEntry.
84 	 *
85 	 * Params:
86 	 *     target = String identifier for target
87 	 *     flags = Set of flags, see #GtkTargetFlags
88 	 *     info = an ID that will be passed back to the application
89 	 *
90 	 * Returns: a pointer to a new #GtkTargetEntry.
91 	 *     Free with gtk_target_entry_free()
92 	 *
93 	 * Throws: ConstructionException GTK+ fails to create the object.
94 	 */
95 	public this(string target, uint flags, uint info)
96 	{
97 		auto p = gtk_target_entry_new(Str.toStringz(target), flags, info);
98 		
99 		if(p is null)
100 		{
101 			throw new ConstructionException("null returned by new");
102 		}
103 		
104 		this(cast(GtkTargetEntry*) p);
105 	}
106 
107 	/**
108 	 * Makes a copy of a #GtkTargetEntry and its data.
109 	 *
110 	 * Returns: a pointer to a copy of @data.
111 	 *     Free with gtk_target_entry_free()
112 	 */
113 	public TargetEntry copy()
114 	{
115 		auto p = gtk_target_entry_copy(gtkTargetEntry);
116 		
117 		if(p is null)
118 		{
119 			return null;
120 		}
121 		
122 		return ObjectG.getDObject!(TargetEntry)(cast(GtkTargetEntry*) p, true);
123 	}
124 
125 	/**
126 	 * Frees a #GtkTargetEntry returned from
127 	 * gtk_target_entry_new() or gtk_target_entry_copy().
128 	 */
129 	public void free()
130 	{
131 		gtk_target_entry_free(gtkTargetEntry);
132 		ownedRef = false;
133 	}
134 }