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.ToggleToolButton;
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.ToolButton;
32 private import gtk.ToolItem;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 public  import gtkc.gtktypes;
36 private import std.algorithm;
37 
38 
39 /**
40  * A #GtkToggleToolButton is a #GtkToolItem that contains a toggle
41  * button.
42  * 
43  * Use gtk_toggle_tool_button_new() to create a new GtkToggleToolButton.
44  * 
45  * # CSS nodes
46  * 
47  * GtkToggleToolButton has a single CSS node with name togglebutton.
48  */
49 public class ToggleToolButton : ToolButton
50 {
51 	/** the main Gtk struct */
52 	protected GtkToggleToolButton* gtkToggleToolButton;
53 
54 	/** Get the main Gtk struct */
55 	public GtkToggleToolButton* getToggleToolButtonStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return gtkToggleToolButton;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gtkToggleToolButton;
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkToggleToolButton* gtkToggleToolButton, bool ownedRef = false)
72 	{
73 		this.gtkToggleToolButton = gtkToggleToolButton;
74 		super(cast(GtkToolButton*)gtkToggleToolButton, ownedRef);
75 	}
76 
77 	/**
78 	 * Creates a new GtkToggleToolButton containing the image and text
79 	 * from a stock item.
80 	 */
81 	public this(StockID stockId)
82 	{
83 		this(cast(string)stockId);
84 	}
85 
86 	/**
87 	 */
88 
89 	/** */
90 	public static GType getType()
91 	{
92 		return gtk_toggle_tool_button_get_type();
93 	}
94 
95 	/**
96 	 * Returns a new #GtkToggleToolButton
97 	 *
98 	 * Returns: a newly created #GtkToggleToolButton
99 	 *
100 	 * Since: 2.4
101 	 *
102 	 * Throws: ConstructionException GTK+ fails to create the object.
103 	 */
104 	public this()
105 	{
106 		auto p = gtk_toggle_tool_button_new();
107 
108 		if(p is null)
109 		{
110 			throw new ConstructionException("null returned by new");
111 		}
112 
113 		this(cast(GtkToggleToolButton*) p);
114 	}
115 
116 	/**
117 	 * Creates a new #GtkToggleToolButton containing the image and text from a
118 	 * stock item. Some stock ids have preprocessor macros like #GTK_STOCK_OK
119 	 * and #GTK_STOCK_APPLY.
120 	 *
121 	 * It is an error if @stock_id is not a name of a stock item.
122 	 *
123 	 * Deprecated: Use gtk_toggle_tool_button_new() instead.
124 	 *
125 	 * Params:
126 	 *     stockId = the name of the stock item
127 	 *
128 	 * Returns: A new #GtkToggleToolButton
129 	 *
130 	 * Since: 2.4
131 	 *
132 	 * Throws: ConstructionException GTK+ fails to create the object.
133 	 */
134 	public this(string stockId)
135 	{
136 		auto p = gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId));
137 
138 		if(p is null)
139 		{
140 			throw new ConstructionException("null returned by new_from_stock");
141 		}
142 
143 		this(cast(GtkToggleToolButton*) p);
144 	}
145 
146 	/**
147 	 * Queries a #GtkToggleToolButton and returns its current state.
148 	 * Returns %TRUE if the toggle button is pressed in and %FALSE if it is raised.
149 	 *
150 	 * Returns: %TRUE if the toggle tool button is pressed in, %FALSE if not
151 	 *
152 	 * Since: 2.4
153 	 */
154 	public bool getActive()
155 	{
156 		return gtk_toggle_tool_button_get_active(gtkToggleToolButton) != 0;
157 	}
158 
159 	/**
160 	 * Sets the status of the toggle tool button. Set to %TRUE if you
161 	 * want the GtkToggleButton to be “pressed in”, and %FALSE to raise it.
162 	 * This action causes the toggled signal to be emitted.
163 	 *
164 	 * Params:
165 	 *     isActive = whether @button should be active
166 	 *
167 	 * Since: 2.4
168 	 */
169 	public void setActive(bool isActive)
170 	{
171 		gtk_toggle_tool_button_set_active(gtkToggleToolButton, isActive);
172 	}
173 
174 	/**
175 	 * Emitted whenever the toggle tool button changes state.
176 	 */
177 	gulong addOnToggled(void delegate(ToggleToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
178 	{
179 		return Signals.connect(this, "toggled", dlg, connectFlags ^ ConnectFlags.SWAPPED);
180 	}
181 }