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