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 	/**
137 	 * Calls @func on each tag in @table, with user data @data.
138 	 * Note that the table may not be modified while iterating
139 	 * over it (you can’t add/remove tags).
140 	 *
141 	 * Params:
142 	 *     func = a function to call on each tag
143 	 *     data = user data
144 	 */
145 	public void foreac(GtkTextTagTableForeach func, void* data)
146 	{
147 		gtk_text_tag_table_foreach(gtkTextTagTable, func, data);
148 	}
149 
150 	/**
151 	 * Returns the size of the table (number of tags)
152 	 *
153 	 * Returns: number of tags in @table
154 	 */
155 	public int getSize()
156 	{
157 		return gtk_text_tag_table_get_size(gtkTextTagTable);
158 	}
159 
160 	/**
161 	 * Look up a named tag.
162 	 *
163 	 * Params:
164 	 *     name = name of a tag
165 	 *
166 	 * Returns: The tag, or %NULL if none by that
167 	 *     name is in the table.
168 	 */
169 	public TextTag lookup(string name)
170 	{
171 		auto p = gtk_text_tag_table_lookup(gtkTextTagTable, Str.toStringz(name));
172 
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 
178 		return ObjectG.getDObject!(TextTag)(cast(GtkTextTag*) p);
179 	}
180 
181 	/**
182 	 * Remove a tag from the table. If a #GtkTextBuffer has @table as its tag table,
183 	 * the tag is removed from the buffer. The table’s reference to the tag is
184 	 * removed, so the tag will end up destroyed if you don’t have a reference to
185 	 * it.
186 	 *
187 	 * Params:
188 	 *     tag = a #GtkTextTag
189 	 */
190 	public void remove(TextTag tag)
191 	{
192 		gtk_text_tag_table_remove(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct());
193 	}
194 
195 	/** */
196 	gulong addOnTagAdded(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
197 	{
198 		return Signals.connect(this, "tag-added", dlg, connectFlags ^ ConnectFlags.SWAPPED);
199 	}
200 
201 	/** */
202 	gulong addOnTagChanged(void delegate(TextTag, bool, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
203 	{
204 		return Signals.connect(this, "tag-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
205 	}
206 
207 	/** */
208 	gulong addOnTagRemoved(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
209 	{
210 		return Signals.connect(this, "tag-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
211 	}
212 }