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