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  * Conversion parameters:
26  * inFile  = GtkTextTagTable.html
27  * outPack = gtk
28  * outFile = TextTagTable
29  * strct   = GtkTextTagTable
30  * realStrct=
31  * ctorStrct=
32  * clss    = TextTagTable
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_text_tag_table_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gtk.TextTag
48  * structWrap:
49  * 	- GtkTextTag* -> TextTag
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gtk.TextTagTable;
56 
57 public  import gtkc.gtktypes;
58 
59 private import gtkc.gtk;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import gobject.Signals;
64 public  import gtkc.gdktypes;
65 private import glib.Str;
66 private import gtk.TextTag;
67 
68 
69 private import gobject.ObjectG;
70 
71 /**
72  * You may wish to begin by reading the text widget
73  * conceptual overview which gives an overview of all the objects and
74  * data types related to the text widget and how they work together.
75  *
76  * GtkTextTagTables as GtkBuildable
77  *
78  * The GtkTextTagTable implementation of the GtkBuildable interface
79  * supports adding tags by specifying "tag" as the "type"
80  * attribute of a <child> element.
81  *
82  * $(DDOC_COMMENT example)
83  */
84 public class TextTagTable : ObjectG
85 {
86 	
87 	/** the main Gtk struct */
88 	protected GtkTextTagTable* gtkTextTagTable;
89 	
90 	
91 	/** Get the main Gtk struct */
92 	public GtkTextTagTable* getTextTagTableStruct()
93 	{
94 		return gtkTextTagTable;
95 	}
96 	
97 	
98 	/** the main Gtk struct as a void* */
99 	protected override void* getStruct()
100 	{
101 		return cast(void*)gtkTextTagTable;
102 	}
103 	
104 	/**
105 	 * Sets our main struct and passes it to the parent class
106 	 */
107 	public this (GtkTextTagTable* gtkTextTagTable)
108 	{
109 		super(cast(GObject*)gtkTextTagTable);
110 		this.gtkTextTagTable = gtkTextTagTable;
111 	}
112 	
113 	protected override void setStruct(GObject* obj)
114 	{
115 		super.setStruct(obj);
116 		gtkTextTagTable = cast(GtkTextTagTable*)obj;
117 	}
118 	
119 	/**
120 	 */
121 	int[string] connectedSignals;
122 	
123 	void delegate(TextTag, TextTagTable)[] onTagAddedListeners;
124 	/**
125 	 */
126 	void addOnTagAdded(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
127 	{
128 		if ( !("tag-added" in connectedSignals) )
129 		{
130 			Signals.connectData(
131 			getStruct(),
132 			"tag-added",
133 			cast(GCallback)&callBackTagAdded,
134 			cast(void*)this,
135 			null,
136 			connectFlags);
137 			connectedSignals["tag-added"] = 1;
138 		}
139 		onTagAddedListeners ~= dlg;
140 	}
141 	extern(C) static void callBackTagAdded(GtkTextTagTable* texttagtableStruct, GtkTextTag* tag, TextTagTable _textTagTable)
142 	{
143 		foreach ( void delegate(TextTag, TextTagTable) dlg ; _textTagTable.onTagAddedListeners )
144 		{
145 			dlg(ObjectG.getDObject!(TextTag)(tag), _textTagTable);
146 		}
147 	}
148 	
149 	void delegate(TextTag, gboolean, TextTagTable)[] onTagChangedListeners;
150 	/**
151 	 */
152 	void addOnTagChanged(void delegate(TextTag, gboolean, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
153 	{
154 		if ( !("tag-changed" in connectedSignals) )
155 		{
156 			Signals.connectData(
157 			getStruct(),
158 			"tag-changed",
159 			cast(GCallback)&callBackTagChanged,
160 			cast(void*)this,
161 			null,
162 			connectFlags);
163 			connectedSignals["tag-changed"] = 1;
164 		}
165 		onTagChangedListeners ~= dlg;
166 	}
167 	extern(C) static void callBackTagChanged(GtkTextTagTable* texttagtableStruct, GtkTextTag* tag, gboolean sizeChanged, TextTagTable _textTagTable)
168 	{
169 		foreach ( void delegate(TextTag, gboolean, TextTagTable) dlg ; _textTagTable.onTagChangedListeners )
170 		{
171 			dlg(ObjectG.getDObject!(TextTag)(tag), sizeChanged, _textTagTable);
172 		}
173 	}
174 	
175 	void delegate(TextTag, TextTagTable)[] onTagRemovedListeners;
176 	/**
177 	 */
178 	void addOnTagRemoved(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
179 	{
180 		if ( !("tag-removed" in connectedSignals) )
181 		{
182 			Signals.connectData(
183 			getStruct(),
184 			"tag-removed",
185 			cast(GCallback)&callBackTagRemoved,
186 			cast(void*)this,
187 			null,
188 			connectFlags);
189 			connectedSignals["tag-removed"] = 1;
190 		}
191 		onTagRemovedListeners ~= dlg;
192 	}
193 	extern(C) static void callBackTagRemoved(GtkTextTagTable* texttagtableStruct, GtkTextTag* tag, TextTagTable _textTagTable)
194 	{
195 		foreach ( void delegate(TextTag, TextTagTable) dlg ; _textTagTable.onTagRemovedListeners )
196 		{
197 			dlg(ObjectG.getDObject!(TextTag)(tag), _textTagTable);
198 		}
199 	}
200 	
201 	
202 	/**
203 	 * Creates a new GtkTextTagTable. The table contains no tags by
204 	 * default.
205 	 * Throws: ConstructionException GTK+ fails to create the object.
206 	 */
207 	public this ()
208 	{
209 		// GtkTextTagTable * gtk_text_tag_table_new (void);
210 		auto p = gtk_text_tag_table_new();
211 		if(p is null)
212 		{
213 			throw new ConstructionException("null returned by gtk_text_tag_table_new()");
214 		}
215 		this(cast(GtkTextTagTable*) p);
216 	}
217 	
218 	/**
219 	 * Add a tag to the table. The tag is assigned the highest priority
220 	 * in the table.
221 	 * tag must not be in a tag table already, and may not have
222 	 * the same name as an already-added tag.
223 	 * Params:
224 	 * tag = a GtkTextTag
225 	 */
226 	public void add(TextTag tag)
227 	{
228 		// void gtk_text_tag_table_add (GtkTextTagTable *table,  GtkTextTag *tag);
229 		gtk_text_tag_table_add(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct());
230 	}
231 	
232 	/**
233 	 * Remove a tag from the table. If a GtkTextBuffer has table as its tag table,
234 	 * the tag is removed from the buffer. The table's reference to the tag is
235 	 * removed, so the tag will end up destroyed if you don't have a reference to
236 	 * it.
237 	 * Params:
238 	 * tag = a GtkTextTag
239 	 */
240 	public void remove(TextTag tag)
241 	{
242 		// void gtk_text_tag_table_remove (GtkTextTagTable *table,  GtkTextTag *tag);
243 		gtk_text_tag_table_remove(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct());
244 	}
245 	
246 	/**
247 	 * Look up a named tag.
248 	 * Params:
249 	 * name = name of a tag
250 	 * Returns: The tag, or NULL if none by that name is in the table. [transfer none]
251 	 */
252 	public TextTag lookup(string name)
253 	{
254 		// GtkTextTag * gtk_text_tag_table_lookup (GtkTextTagTable *table,  const gchar *name);
255 		auto p = gtk_text_tag_table_lookup(gtkTextTagTable, Str.toStringz(name));
256 		
257 		if(p is null)
258 		{
259 			return null;
260 		}
261 		
262 		return ObjectG.getDObject!(TextTag)(cast(GtkTextTag*) p);
263 	}
264 	
265 	/**
266 	 * Calls func on each tag in table, with user data data.
267 	 * Note that the table may not be modified while iterating
268 	 * over it (you can't add/remove tags).
269 	 * Params:
270 	 * func = a function to call on each tag. [scope call]
271 	 * data = user data
272 	 */
273 	public void foreac(GtkTextTagTableForeach func, void* data)
274 	{
275 		// void gtk_text_tag_table_foreach (GtkTextTagTable *table,  GtkTextTagTableForeach func,  gpointer data);
276 		gtk_text_tag_table_foreach(gtkTextTagTable, func, data);
277 	}
278 	
279 	/**
280 	 * Returns the size of the table (number of tags)
281 	 * Returns: number of tags in table Signal Details The "tag-added" signal void user_function (GtkTextTagTable *texttagtable, GtkTextTag *tag, gpointer user_data) : Run Last
282 	 */
283 	public int getSize()
284 	{
285 		// gint gtk_text_tag_table_get_size (GtkTextTagTable *table);
286 		return gtk_text_tag_table_get_size(gtkTextTagTable);
287 	}
288 }