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  * Description
76  * An AtkRelation describes a relation between an object and one or more
77  * other objects. The actual relations that an object has with other objects
78  * are defined as an AtkRelationSet, which is a set of 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 AtkObjects
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]
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 }