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 gtk.TextTagTable; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.BuildableIF; 32 private import gtk.BuildableT; 33 private import gtk.TextTag; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 public import gtkc.gtktypes; 37 private import std.algorithm; 38 39 40 /** 41 * You may wish to begin by reading the 42 * [text widget conceptual overview][TextWidget] 43 * which gives an overview of all the objects and 44 * data types related to the text widget and how they work together. 45 * 46 * # GtkTextTagTables as GtkBuildable 47 * 48 * The GtkTextTagTable implementation of the GtkBuildable interface 49 * supports adding tags by specifying “tag” as the “type” attribute 50 * of a <child> element. 51 * 52 * An example of a UI definition fragment specifying tags: 53 * |[ 54 * <object class="GtkTextTagTable"> 55 * <child type="tag"> 56 * <object class="GtkTextTag"/> 57 * </child> 58 * </object> 59 * ]| 60 */ 61 public class TextTagTable : ObjectG, BuildableIF 62 { 63 /** the main Gtk struct */ 64 protected GtkTextTagTable* gtkTextTagTable; 65 66 /** Get the main Gtk struct */ 67 public GtkTextTagTable* getTextTagTableStruct(bool transferOwnership = false) 68 { 69 if (transferOwnership) 70 ownedRef = false; 71 return gtkTextTagTable; 72 } 73 74 /** the main Gtk struct as a void* */ 75 protected override void* getStruct() 76 { 77 return cast(void*)gtkTextTagTable; 78 } 79 80 /** 81 * Sets our main struct and passes it to the parent class. 82 */ 83 public this (GtkTextTagTable* gtkTextTagTable, bool ownedRef = false) 84 { 85 this.gtkTextTagTable = gtkTextTagTable; 86 super(cast(GObject*)gtkTextTagTable, ownedRef); 87 } 88 89 // add the Buildable capabilities 90 mixin BuildableT!(GtkTextTagTable); 91 92 93 /** */ 94 public static GType getType() 95 { 96 return gtk_text_tag_table_get_type(); 97 } 98 99 /** 100 * Creates a new #GtkTextTagTable. The table contains no tags by 101 * default. 102 * 103 * Returns: a new #GtkTextTagTable 104 * 105 * Throws: ConstructionException GTK+ fails to create the object. 106 */ 107 public this() 108 { 109 auto p = gtk_text_tag_table_new(); 110 111 if(p is null) 112 { 113 throw new ConstructionException("null returned by new"); 114 } 115 116 this(cast(GtkTextTagTable*) p, true); 117 } 118 119 /** 120 * Add a tag to the table. The tag is assigned the highest priority 121 * in the table. 122 * 123 * @tag must not be in a tag table already, and may not have 124 * the same name as an already-added tag. 125 * 126 * Params: 127 * tag = a #GtkTextTag 128 * 129 * Returns: %TRUE on success. 130 */ 131 public bool add(TextTag tag) 132 { 133 return gtk_text_tag_table_add(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct()) != 0; 134 } 135 136 alias foreac = foreach_; 137 /** 138 * Calls @func on each tag in @table, with user data @data. 139 * Note that the table may not be modified while iterating 140 * over it (you can’t add/remove tags). 141 * 142 * Params: 143 * func = a function to call on each tag 144 * data = user data 145 */ 146 public void foreach_(GtkTextTagTableForeach func, void* data) 147 { 148 gtk_text_tag_table_foreach(gtkTextTagTable, func, data); 149 } 150 151 /** 152 * Returns the size of the table (number of tags) 153 * 154 * Returns: number of tags in @table 155 */ 156 public int getSize() 157 { 158 return gtk_text_tag_table_get_size(gtkTextTagTable); 159 } 160 161 /** 162 * Look up a named tag. 163 * 164 * Params: 165 * name = name of a tag 166 * 167 * Returns: The tag, or %NULL if none by that 168 * name is in the table. 169 */ 170 public TextTag lookup(string name) 171 { 172 auto p = gtk_text_tag_table_lookup(gtkTextTagTable, Str.toStringz(name)); 173 174 if(p is null) 175 { 176 return null; 177 } 178 179 return ObjectG.getDObject!(TextTag)(cast(GtkTextTag*) p); 180 } 181 182 /** 183 * Remove a tag from the table. If a #GtkTextBuffer has @table as its tag table, 184 * the tag is removed from the buffer. The table’s reference to the tag is 185 * removed, so the tag will end up destroyed if you don’t have a reference to 186 * it. 187 * 188 * Params: 189 * tag = a #GtkTextTag 190 */ 191 public void remove(TextTag tag) 192 { 193 gtk_text_tag_table_remove(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct()); 194 } 195 196 /** */ 197 gulong addOnTagAdded(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 198 { 199 return Signals.connect(this, "tag-added", dlg, connectFlags ^ ConnectFlags.SWAPPED); 200 } 201 202 /** */ 203 gulong addOnTagChanged(void delegate(TextTag, bool, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 204 { 205 return Signals.connect(this, "tag-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 206 } 207 208 /** */ 209 gulong addOnTagRemoved(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 210 { 211 return Signals.connect(this, "tag-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 212 } 213 }