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 atk.RelationSet;
26 
27 private import atk.ObjectAtk;
28 private import atk.Relation;
29 private import glib.ConstructionException;
30 private import gobject.ObjectG;
31 private import gtkc.atk;
32 public  import gtkc.atktypes;
33 
34 
35 /**
36  * The AtkRelationSet held by an object establishes its relationships
37  * with objects beyond the normal "parent/child" hierarchical
38  * relationships that all user interface objects have.
39  * AtkRelationSets establish whether objects are labelled or
40  * controlled by other components, share group membership with other
41  * components (for instance within a radio-button group), or share
42  * content which "flows" between them, among other types of possible
43  * relationships.
44  */
45 public class RelationSet : ObjectG
46 {
47 	/** the main Gtk struct */
48 	protected AtkRelationSet* atkRelationSet;
49 
50 	/** Get the main Gtk struct */
51 	public AtkRelationSet* getRelationSetStruct()
52 	{
53 		return atkRelationSet;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)atkRelationSet;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		atkRelationSet = cast(AtkRelationSet*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (AtkRelationSet* atkRelationSet, bool ownedRef = false)
72 	{
73 		this.atkRelationSet = atkRelationSet;
74 		super(cast(GObject*)atkRelationSet, ownedRef);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return atk_relation_set_get_type();
82 	}
83 
84 	/**
85 	 * Creates a new empty relation set.
86 	 *
87 	 * Return: a new #AtkRelationSet
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this()
92 	{
93 		auto p = atk_relation_set_new();
94 		
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 		
100 		this(cast(AtkRelationSet*) p, true);
101 	}
102 
103 	/**
104 	 * Add a new relation to the current relation set if it is not already
105 	 * present.
106 	 * This function ref's the AtkRelation so the caller of this function
107 	 * should unref it to ensure that it will be destroyed when the AtkRelationSet
108 	 * is destroyed.
109 	 *
110 	 * Params:
111 	 *     relation = an #AtkRelation
112 	 */
113 	public void add(Relation relation)
114 	{
115 		atk_relation_set_add(atkRelationSet, (relation is null) ? null : relation.getRelationStruct());
116 	}
117 
118 	/**
119 	 * Add a new relation of the specified type with the specified target to
120 	 * the current relation set if the relation set does not contain a relation
121 	 * of that type. If it is does contain a relation of that typea the target
122 	 * is added to the relation.
123 	 *
124 	 * Params:
125 	 *     relationship = an #AtkRelationType
126 	 *     target = an #AtkObject
127 	 *
128 	 * Since: 1.9
129 	 */
130 	public void addRelationByType(AtkRelationType relationship, ObjectAtk target)
131 	{
132 		atk_relation_set_add_relation_by_type(atkRelationSet, relationship, (target is null) ? null : target.getObjectAtkStruct());
133 	}
134 
135 	/**
136 	 * Determines whether the relation set contains a relation that matches the
137 	 * specified type.
138 	 *
139 	 * Params:
140 	 *     relationship = an #AtkRelationType
141 	 *
142 	 * Return: %TRUE if @relationship is the relationship type of a relation
143 	 *     in @set, %FALSE otherwise
144 	 */
145 	public bool contains(AtkRelationType relationship)
146 	{
147 		return atk_relation_set_contains(atkRelationSet, relationship) != 0;
148 	}
149 
150 	/**
151 	 * Determines whether the relation set contains a relation that
152 	 * matches the specified pair formed by type @relationship and object
153 	 * @target.
154 	 *
155 	 * Params:
156 	 *     relationship = an #AtkRelationType
157 	 *     target = an #AtkObject
158 	 *
159 	 * Return: %TRUE if @set contains a relation with the relationship
160 	 *     type @relationship with an object @target, %FALSE otherwise
161 	 */
162 	public bool containsTarget(AtkRelationType relationship, ObjectAtk target)
163 	{
164 		return atk_relation_set_contains_target(atkRelationSet, relationship, (target is null) ? null : target.getObjectAtkStruct()) != 0;
165 	}
166 
167 	/**
168 	 * Determines the number of relations in a relation set.
169 	 *
170 	 * Return: an integer representing the number of relations in the set.
171 	 */
172 	public int getNRelations()
173 	{
174 		return atk_relation_set_get_n_relations(atkRelationSet);
175 	}
176 
177 	/**
178 	 * Determines the relation at the specified position in the relation set.
179 	 *
180 	 * Params:
181 	 *     i = a gint representing a position in the set, starting from 0.
182 	 *
183 	 * Return: a #AtkRelation, which is the relation at
184 	 *     position i in the set.
185 	 */
186 	public Relation getRelation(int i)
187 	{
188 		auto p = atk_relation_set_get_relation(atkRelationSet, i);
189 		
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 		
195 		return ObjectG.getDObject!(Relation)(cast(AtkRelation*) p);
196 	}
197 
198 	/**
199 	 * Finds a relation that matches the specified type.
200 	 *
201 	 * Params:
202 	 *     relationship = an #AtkRelationType
203 	 *
204 	 * Return: an #AtkRelation, which is a relation matching the
205 	 *     specified type.
206 	 */
207 	public Relation getRelationByType(AtkRelationType relationship)
208 	{
209 		auto p = atk_relation_set_get_relation_by_type(atkRelationSet, relationship);
210 		
211 		if(p is null)
212 		{
213 			return null;
214 		}
215 		
216 		return ObjectG.getDObject!(Relation)(cast(AtkRelation*) p);
217 	}
218 
219 	/**
220 	 * Removes a relation from the relation set.
221 	 * This function unref's the #AtkRelation so it will be deleted unless there
222 	 * is another reference to it.
223 	 *
224 	 * Params:
225 	 *     relation = an #AtkRelation
226 	 */
227 	public void remove(Relation relation)
228 	{
229 		atk_relation_set_remove(atkRelationSet, (relation is null) ? null : relation.getRelationStruct());
230 	}
231 }