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