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