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