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