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.Relation; 26 27 private import atk.ObjectAtk; 28 private import atk.c.functions; 29 public import atk.c.types; 30 private import glib.ConstructionException; 31 private import glib.PtrArray; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 public import gtkc.atktypes; 35 36 37 /** 38 * An AtkRelation describes a relation between an object and one or 39 * more other objects. The actual relations that an object has with 40 * other objects are defined as an AtkRelationSet, which is a set of 41 * AtkRelations. 42 */ 43 public class Relation : ObjectG 44 { 45 /** the main Gtk struct */ 46 protected AtkRelation* atkRelation; 47 48 /** Get the main Gtk struct */ 49 public AtkRelation* getRelationStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return atkRelation; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)atkRelation; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (AtkRelation* atkRelation, bool ownedRef = false) 66 { 67 this.atkRelation = atkRelation; 68 super(cast(GObject*)atkRelation, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return atk_relation_get_type(); 76 } 77 78 /** 79 * Create a new relation for the specified key and the specified list 80 * of targets. See also atk_object_add_relationship(). 81 * 82 * Params: 83 * targets = an array of pointers to 84 * #AtkObjects 85 * relationship = an #AtkRelationType with which to create the new 86 * #AtkRelation 87 * 88 * Returns: a pointer to a new #AtkRelation 89 * 90 * Throws: ConstructionException GTK+ fails to create the object. 91 */ 92 public this(ObjectAtk[] targets, AtkRelationType relationship) 93 { 94 AtkObject*[] targetsArray = new AtkObject*[targets.length]; 95 for ( int i = 0; i < targets.length; i++ ) 96 { 97 targetsArray[i] = targets[i].getObjectAtkStruct(); 98 } 99 100 auto p = atk_relation_new(targetsArray.ptr, cast(int)targets.length, relationship); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(AtkRelation*) p, true); 108 } 109 110 /** 111 * Adds the specified AtkObject to the target for the relation, if it is 112 * not already present. See also atk_object_add_relationship(). 113 * 114 * Params: 115 * target = an #AtkObject 116 * 117 * Since: 1.9 118 */ 119 public void addTarget(ObjectAtk target) 120 { 121 atk_relation_add_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct()); 122 } 123 124 /** 125 * Gets the type of @relation 126 * 127 * Returns: the type of @relation 128 */ 129 public AtkRelationType getRelationType() 130 { 131 return atk_relation_get_relation_type(atkRelation); 132 } 133 134 /** 135 * Gets the target list of @relation 136 * 137 * Returns: the target list of @relation 138 */ 139 public PtrArray getTarget() 140 { 141 auto p = atk_relation_get_target(atkRelation); 142 143 if(p is null) 144 { 145 return null; 146 } 147 148 return new PtrArray(cast(GPtrArray*) p); 149 } 150 151 /** 152 * Remove the specified AtkObject from the target for the relation. 153 * 154 * Params: 155 * target = an #AtkObject 156 * 157 * Returns: TRUE if the removal is successful. 158 */ 159 public bool removeTarget(ObjectAtk target) 160 { 161 return atk_relation_remove_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct()) != 0; 162 } 163 164 /** 165 * Get the #AtkRelationType type corresponding to a relation name. 166 * 167 * Params: 168 * name = a string which is the (non-localized) name of an ATK relation type. 169 * 170 * Returns: the #AtkRelationType enumerated type corresponding to the specified name, 171 * or #ATK_RELATION_NULL if no matching relation type is found. 172 */ 173 public static AtkRelationType typeForName(string name) 174 { 175 return atk_relation_type_for_name(Str.toStringz(name)); 176 } 177 178 /** 179 * Gets the description string describing the #AtkRelationType @type. 180 * 181 * Params: 182 * type = The #AtkRelationType whose name is required 183 * 184 * Returns: the string describing the AtkRelationType 185 */ 186 public static string typeGetName(AtkRelationType type) 187 { 188 return Str.toString(atk_relation_type_get_name(type)); 189 } 190 191 /** 192 * Associate @name with a new #AtkRelationType 193 * 194 * Params: 195 * name = a name string 196 * 197 * Returns: an #AtkRelationType associated with @name 198 */ 199 public static AtkRelationType typeRegister(string name) 200 { 201 return atk_relation_type_register(Str.toStringz(name)); 202 } 203 }