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  = GtkToggleToolButton.html
27  * outPack = gtk
28  * outFile = ToggleToolButton
29  * strct   = GtkToggleToolButton
30  * realStrct=
31  * ctorStrct=GtkToolItem
32  * clss    = ToggleToolButton
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_toggle_tool_button_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.ToolItem
49  * structWrap:
50  * 	- GtkToolItem* -> ToolItem
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gtk.ToggleToolButton;
57 
58 public  import gtkc.gtktypes;
59 
60 private import gtkc.gtk;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import gobject.Signals;
65 public  import gtkc.gdktypes;
66 
67 private import glib.Str;
68 private import gtk.ToolItem;
69 
70 
71 
72 private import gtk.ToolButton;
73 
74 /**
75  * Description
76  *  A GtkToggleToolButton is a GtkToolItem that contains a toggle
77  *  button.
78  *  Use gtk_toggle_tool_button_new() to create a new
79  *  GtkToggleToolButton. Use gtk_toggle_tool_button_new_from_stock() to
80  *  create a new GtkToggleToolButton containing a stock item.
81  */
82 public class ToggleToolButton : ToolButton
83 {
84 	
85 	/** the main Gtk struct */
86 	protected GtkToggleToolButton* gtkToggleToolButton;
87 	
88 	
89 	public GtkToggleToolButton* getToggleToolButtonStruct()
90 	{
91 		return gtkToggleToolButton;
92 	}
93 	
94 	
95 	/** the main Gtk struct as a void* */
96 	protected override void* getStruct()
97 	{
98 		return cast(void*)gtkToggleToolButton;
99 	}
100 	
101 	/**
102 	 * Sets our main struct and passes it to the parent class
103 	 */
104 	public this (GtkToggleToolButton* gtkToggleToolButton)
105 	{
106 		super(cast(GtkToolButton*)gtkToggleToolButton);
107 		this.gtkToggleToolButton = gtkToggleToolButton;
108 	}
109 	
110 	protected override void setStruct(GObject* obj)
111 	{
112 		super.setStruct(obj);
113 		gtkToggleToolButton = cast(GtkToggleToolButton*)obj;
114 	}
115 	
116 	/**
117 	 */
118 	int[string] connectedSignals;
119 	
120 	void delegate(ToggleToolButton)[] onToggledListeners;
121 	/**
122 	 * Emitted whenever the toggle tool button changes state.
123 	 * See Also
124 	 *
125 	 * GtkToolbar, GtkToolButton, GtkSeparatorToolItem
126 	 * The toolbar widget
127 	 *  The parent class of GtkToggleToolButton. The properties
128 	 *  "label_widget", "label", "icon_widget", and "stock_id" on
129 	 *  GtkToolButton determine the label and icon used on
130 	 *  GtkToggleToolButtons.
131 	 *
132 	 * A subclass of GtkToolItem that separates groups of
133 	 *  items on a toolbar.
134 	 *
135 	 */
136 	void addOnToggled(void delegate(ToggleToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
137 	{
138 		if ( !("toggled" in connectedSignals) )
139 		{
140 			Signals.connectData(
141 			getStruct(),
142 			"toggled",
143 			cast(GCallback)&callBackToggled,
144 			cast(void*)this,
145 			null,
146 			connectFlags);
147 			connectedSignals["toggled"] = 1;
148 		}
149 		onToggledListeners ~= dlg;
150 	}
151 	extern(C) static void callBackToggled(GtkToggleToolButton* toggleToolButtonStruct, ToggleToolButton _toggleToolButton)
152 	{
153 		foreach ( void delegate(ToggleToolButton) dlg ; _toggleToolButton.onToggledListeners )
154 		{
155 			dlg(_toggleToolButton);
156 		}
157 	}
158 	
159 	
160 	/**
161 	 * Returns a new GtkToggleToolButton
162 	 * Since 2.4
163 	 * Throws: ConstructionException GTK+ fails to create the object.
164 	 */
165 	public this ()
166 	{
167 		// GtkToolItem * gtk_toggle_tool_button_new (void);
168 		auto p = gtk_toggle_tool_button_new();
169 		if(p is null)
170 		{
171 			throw new ConstructionException("null returned by gtk_toggle_tool_button_new()");
172 		}
173 		this(cast(GtkToggleToolButton*) p);
174 	}
175 	
176 	/**
177 	 * Creates a new GtkToggleToolButton containing the image and text from a
178 	 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK
179 	 * and GTK_STOCK_APPLY.
180 	 * It is an error if stock_id is not a name of a stock item.
181 	 * Since 2.4
182 	 * Params:
183 	 * stockId = the name of the stock item
184 	 * Throws: ConstructionException GTK+ fails to create the object.
185 	 */
186 	public this (string stockId)
187 	{
188 		// GtkToolItem * gtk_toggle_tool_button_new_from_stock  (const gchar *stock_id);
189 		auto p = gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId));
190 		if(p is null)
191 		{
192 			throw new ConstructionException("null returned by gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId))");
193 		}
194 		this(cast(GtkToggleToolButton*) p);
195 	}
196 	
197 	/**
198 	 * Sets the status of the toggle tool button. Set to TRUE if you
199 	 * want the GtkToggleButton to be 'pressed in', and FALSE to raise it.
200 	 * This action causes the toggled signal to be emitted.
201 	 * Since 2.4
202 	 * Params:
203 	 * isActive = whether button should be active
204 	 */
205 	public void setActive(int isActive)
206 	{
207 		// void gtk_toggle_tool_button_set_active (GtkToggleToolButton *button,  gboolean is_active);
208 		gtk_toggle_tool_button_set_active(gtkToggleToolButton, isActive);
209 	}
210 	
211 	/**
212 	 * Queries a GtkToggleToolButton and returns its current state.
213 	 * Returns TRUE if the toggle button is pressed in and FALSE if it is raised.
214 	 * Since 2.4
215 	 * Returns: TRUE if the toggle tool button is pressed in, FALSE if not
216 	 */
217 	public int getActive()
218 	{
219 		// gboolean gtk_toggle_tool_button_get_active (GtkToggleToolButton *button);
220 		return gtk_toggle_tool_button_get_active(gtkToggleToolButton);
221 	}
222 }