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  = AtkRelation.html
27  * outPack = atk
28  * outFile = Relation
29  * strct   = AtkRelation
30  * realStrct=
31  * ctorStrct=
32  * clss    = Relation
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- atk_relation_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- atk.ObjectAtk
47  * 	- glib.PtrArray
48  * 	- glib.Str
49  * structWrap:
50  * 	- AtkObject* -> ObjectAtk
51  * 	- GPtrArray* -> PtrArray
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module atk.Relation;
58 
59 public  import gtkc.atktypes;
60 
61 private import gtkc.atk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 
66 private import atk.ObjectAtk;
67 private import glib.PtrArray;
68 private import glib.Str;
69 
70 
71 
72 private import gobject.ObjectG;
73 
74 /**
75  * An AtkRelation describes a relation between an object and one or
76  * more other objects. The actual relations that an object has with
77  * other objects are defined as an AtkRelationSet, which is a set of
78  * AtkRelations.
79  */
80 public class Relation : ObjectG
81 {
82 	
83 	/** the main Gtk struct */
84 	protected AtkRelation* atkRelation;
85 	
86 	
87 	public AtkRelation* getRelationStruct()
88 	{
89 		return atkRelation;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected override void* getStruct()
95 	{
96 		return cast(void*)atkRelation;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (AtkRelation* atkRelation)
103 	{
104 		super(cast(GObject*)atkRelation);
105 		this.atkRelation = atkRelation;
106 	}
107 	
108 	protected override void setStruct(GObject* obj)
109 	{
110 		super.setStruct(obj);
111 		atkRelation = cast(AtkRelation*)obj;
112 	}
113 	
114 	/**
115 	 */
116 	
117 	/**
118 	 * Associate name with a new AtkRelationType
119 	 * Params:
120 	 * name = a name string
121 	 * Returns: an AtkRelationType associated with name
122 	 */
123 	public static AtkRelationType typeRegister(string name)
124 	{
125 		// AtkRelationType atk_relation_type_register (const gchar *name);
126 		return atk_relation_type_register(Str.toStringz(name));
127 	}
128 	
129 	/**
130 	 * Gets the description string describing the AtkRelationType type.
131 	 * Params:
132 	 * type = The AtkRelationType whose name is required
133 	 * Returns: the string describing the AtkRelationType
134 	 */
135 	public static string typeGetName(AtkRelationType type)
136 	{
137 		// const gchar * atk_relation_type_get_name (AtkRelationType type);
138 		return Str.toString(atk_relation_type_get_name(type));
139 	}
140 	
141 	/**
142 	 * Get the AtkRelationType type corresponding to a relation name.
143 	 * Params:
144 	 * name = a string which is the (non-localized) name of an ATK relation type.
145 	 * Returns: the AtkRelationType enumerated type corresponding to the specified name, or ATK_RELATION_NULL if no matching relation type is found.
146 	 */
147 	public static AtkRelationType typeForName(string name)
148 	{
149 		// AtkRelationType atk_relation_type_for_name (const gchar *name);
150 		return atk_relation_type_for_name(Str.toStringz(name));
151 	}
152 	
153 	/**
154 	 * Create a new relation for the specified key and the specified list
155 	 * of targets. See also atk_object_add_relationship().
156 	 * Params:
157 	 * targets = an array of pointers to
158 	 * AtkObjects. [array length=n_targets]
159 	 * relationship = an AtkRelationType with which to create the new
160 	 * AtkRelation
161 	 * Throws: ConstructionException GTK+ fails to create the object.
162 	 */
163 	public this (ObjectAtk[] targets, AtkRelationType relationship)
164 	{
165 		// AtkRelation * atk_relation_new (AtkObject **targets,  gint n_targets,  AtkRelationType relationship);
166 		
167 		AtkObject*[] targetsArray = new AtkObject*[targets.length];
168 		for ( int i = 0; i < targets.length ; i++ )
169 		{
170 			targetsArray[i] = targets[i].getObjectAtkStruct();
171 		}
172 		
173 		auto p = atk_relation_new(targetsArray.ptr, cast(int) targets.length, relationship);
174 		if(p is null)
175 		{
176 			throw new ConstructionException("null returned by atk_relation_new(targetsArray.ptr, cast(int) targets.length, relationship)");
177 		}
178 		this(cast(AtkRelation*) p);
179 	}
180 	
181 	/**
182 	 * Gets the type of relation
183 	 * Returns: the type of relation
184 	 */
185 	public AtkRelationType getRelationType()
186 	{
187 		// AtkRelationType atk_relation_get_relation_type (AtkRelation *relation);
188 		return atk_relation_get_relation_type(atkRelation);
189 	}
190 	
191 	/**
192 	 * Gets the target list of relation
193 	 * Returns: the target list of relation. [transfer none][element-type Atk.Object]
194 	 */
195 	public PtrArray getTarget()
196 	{
197 		// GPtrArray * atk_relation_get_target (AtkRelation *relation);
198 		auto p = atk_relation_get_target(atkRelation);
199 		
200 		if(p is null)
201 		{
202 			return null;
203 		}
204 		
205 		return ObjectG.getDObject!(PtrArray)(cast(GPtrArray*) p);
206 	}
207 	
208 	/**
209 	 * Adds the specified AtkObject to the target for the relation, if it is
210 	 * not already present. See also atk_object_add_relationship().
211 	 * Since 1.9
212 	 * Params:
213 	 * target = an AtkObject
214 	 */
215 	public void addTarget(ObjectAtk target)
216 	{
217 		// void atk_relation_add_target (AtkRelation *relation,  AtkObject *target);
218 		atk_relation_add_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct());
219 	}
220 	
221 	/**
222 	 * Remove the specified AtkObject from the target for the relation.
223 	 * Params:
224 	 * target = an AtkObject
225 	 * Returns: TRUE if the removal is successful.
226 	 */
227 	public int removeTarget(ObjectAtk target)
228 	{
229 		// gboolean atk_relation_remove_target (AtkRelation *relation,  AtkObject *target);
230 		return atk_relation_remove_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct());
231 	}
232 }