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 protected override void setStruct(GObject* obj) 63 { 64 atkRelation = cast(AtkRelation*)obj; 65 super.setStruct(obj); 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (AtkRelation* atkRelation, bool ownedRef = false) 72 { 73 this.atkRelation = atkRelation; 74 super(cast(GObject*)atkRelation, ownedRef); 75 } 76 77 78 /** */ 79 public static GType getType() 80 { 81 return atk_relation_get_type(); 82 } 83 84 /** 85 * Create a new relation for the specified key and the specified list 86 * of targets. See also atk_object_add_relationship(). 87 * 88 * Params: 89 * targets = an array of pointers to 90 * #AtkObjects 91 * relationship = an #AtkRelationType with which to create the new 92 * #AtkRelation 93 * 94 * Returns: a pointer to a new #AtkRelation 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(ObjectAtk[] targets, AtkRelationType relationship) 99 { 100 AtkObject*[] targetsArray = new AtkObject*[targets.length]; 101 for ( int i = 0; i < targets.length; i++ ) 102 { 103 targetsArray[i] = targets[i].getObjectAtkStruct(); 104 } 105 106 auto p = atk_relation_new(targetsArray.ptr, cast(int)targets.length, relationship); 107 108 if(p is null) 109 { 110 throw new ConstructionException("null returned by new"); 111 } 112 113 this(cast(AtkRelation*) p, true); 114 } 115 116 /** 117 * Adds the specified AtkObject to the target for the relation, if it is 118 * not already present. See also atk_object_add_relationship(). 119 * 120 * Params: 121 * target = an #AtkObject 122 * 123 * Since: 1.9 124 */ 125 public void addTarget(ObjectAtk target) 126 { 127 atk_relation_add_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct()); 128 } 129 130 /** 131 * Gets the type of @relation 132 * 133 * Returns: the type of @relation 134 */ 135 public AtkRelationType getRelationType() 136 { 137 return atk_relation_get_relation_type(atkRelation); 138 } 139 140 /** 141 * Gets the target list of @relation 142 * 143 * Returns: the target list of @relation 144 */ 145 public PtrArray getTarget() 146 { 147 auto p = atk_relation_get_target(atkRelation); 148 149 if(p is null) 150 { 151 return null; 152 } 153 154 return new PtrArray(cast(GPtrArray*) p); 155 } 156 157 /** 158 * Remove the specified AtkObject from the target for the relation. 159 * 160 * Params: 161 * target = an #AtkObject 162 * 163 * Returns: TRUE if the removal is successful. 164 */ 165 public bool removeTarget(ObjectAtk target) 166 { 167 return atk_relation_remove_target(atkRelation, (target is null) ? null : target.getObjectAtkStruct()) != 0; 168 } 169 170 /** 171 * Get the #AtkRelationType type corresponding to a relation name. 172 * 173 * Params: 174 * name = a string which is the (non-localized) name of an ATK relation type. 175 * 176 * Returns: the #AtkRelationType enumerated type corresponding to the specified name, 177 * or #ATK_RELATION_NULL if no matching relation type is found. 178 */ 179 public static AtkRelationType typeForName(string name) 180 { 181 return atk_relation_type_for_name(Str.toStringz(name)); 182 } 183 184 /** 185 * Gets the description string describing the #AtkRelationType @type. 186 * 187 * Params: 188 * type = The #AtkRelationType whose name is required 189 * 190 * Returns: the string describing the AtkRelationType 191 */ 192 public static string typeGetName(AtkRelationType type) 193 { 194 return Str.toString(atk_relation_type_get_name(type)); 195 } 196 197 /** 198 * Associate @name with a new #AtkRelationType 199 * 200 * Params: 201 * name = a name string 202 * 203 * Returns: an #AtkRelationType associated with @name 204 */ 205 public static AtkRelationType typeRegister(string name) 206 { 207 return atk_relation_type_register(Str.toStringz(name)); 208 } 209 }