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