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.ModelButton;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Button;
30 private import gtk.Widget;
31 private import gtkc.gtk;
32 public  import gtkc.gtktypes;
33 
34 
35 /**
36  * GtkModelButton is a button class that can use a #GAction as its model.
37  * In contrast to #GtkToggleButton or #GtkRadioButton, which can also
38  * be backed by a #GAction via the #GtkActionable:action-name property,
39  * GtkModelButton will adapt its appearance according to the kind of
40  * action it is backed by, and appear either as a plain, check or
41  * radio button.
42  * 
43  * Model buttons are used when popovers from a menu model with
44  * gtk_popover_new_from_model(); they can also be used manually in
45  * a #GtkPopoverMenu.
46  * 
47  * When the action is specified via the #GtkActionable:action-name
48  * and #GtkActionable:action-target properties, the role of the button
49  * (i.e. whether it is a plain, check or radio button) is determined by
50  * the type of the action and doesn't have to be explicitly specified
51  * with the #GtkModelButton:role property.
52  * 
53  * The content of the button is specified by the #GtkModelButton:text
54  * and #GtkModelButton:icon properties.
55  * 
56  * The appearance of model buttons can be influenced with the
57  * #GtkModelButton:centered and #GtkModelButton:iconic properties.
58  * 
59  * Model buttons have built-in support for submenus in #GtkPopoverMenu.
60  * To make a GtkModelButton that opens a submenu when activated, set
61  * the #GtkModelButton:menu-name property. To make a button that goes
62  * back to the parent menu, you should set the #GtkModelButton:inverted
63  * property to place the submenu indicator at the opposite side.
64  * 
65  * # Example
66  * 
67  * |[
68  * <object class="GtkPopoverMenu">
69  * <child>
70  * <object class="GtkBox">
71  * <property name="visible">True</property>
72  * <property name="margin">10</property>
73  * <child>
74  * <object class="GtkModelButton">
75  * <property name="visible">True</property>
76  * <property name="action-name">view.cut</property>
77  * <property name="text" translatable="yes">Cut</property>
78  * </object>
79  * </child>
80  * <child>
81  * <object class="GtkModelButton">
82  * <property name="visible">True</property>
83  * <property name="action-name">view.copy</property>
84  * <property name="text" translatable="yes">Copy</property>
85  * </object>
86  * </child>
87  * <child>
88  * <object class="GtkModelButton">
89  * <property name="visible">True</property>
90  * <property name="action-name">view.paste</property>
91  * <property name="text" translatable="yes">Paste</property>
92  * </object>
93  * </child>
94  * </object>
95  * </child>
96  * </object>
97  * ]|
98  * 
99  * # CSS nodes
100  * 
101  * |[<!-- language="plain" -->
102  * modelbutton
103  * ├── <child>
104  * ╰── check
105  * ]|
106  * 
107  * |[<!-- language="plain" -->
108  * modelbutton
109  * ├── <child>
110  * ╰── radio
111  * ]|
112  * 
113  * |[<!-- language="plain" -->
114  * modelbutton
115  * ├── <child>
116  * ╰── arrow
117  * ]|
118  * 
119  * GtkModelButton has a main CSS node with name modelbutton, and a subnode,
120  * which will have the name check, radio or arrow, depending on the role
121  * of the button and whether it has a menu name set.
122  * 
123  * The subnode is positioned before or after the content nodes and gets the
124  * .left or .right style class, depending on where it is located.
125  * 
126  * |[<!-- language="plain" -->
127  * button.model
128  * ├── <child>
129  * ╰── check
130  * ]|
131  * 
132  * Iconic model buttons (see #GtkModelButton:iconic) change the name of
133  * their main node to button and add a .model style class to it. The indicator
134  * subnode is invisible in this case.
135  */
136 public class ModelButton : Button
137 {
138 	/** the main Gtk struct */
139 	protected GtkModelButton* gtkModelButton;
140 
141 	/** Get the main Gtk struct */
142 	public GtkModelButton* getModelButtonStruct()
143 	{
144 		return gtkModelButton;
145 	}
146 
147 	/** the main Gtk struct as a void* */
148 	protected override void* getStruct()
149 	{
150 		return cast(void*)gtkModelButton;
151 	}
152 
153 	protected override void setStruct(GObject* obj)
154 	{
155 		gtkModelButton = cast(GtkModelButton*)obj;
156 		super.setStruct(obj);
157 	}
158 
159 	/**
160 	 * Sets our main struct and passes it to the parent class.
161 	 */
162 	public this (GtkModelButton* gtkModelButton, bool ownedRef = false)
163 	{
164 		this.gtkModelButton = gtkModelButton;
165 		super(cast(GtkButton*)gtkModelButton, ownedRef);
166 	}
167 
168 
169 	/** */
170 	public static GType getType()
171 	{
172 		return gtk_model_button_get_type();
173 	}
174 
175 	/**
176 	 * Creates a new GtkModelButton.
177 	 *
178 	 * Return: the newly created #GtkModelButton widget
179 	 *
180 	 * Since: 3.16
181 	 *
182 	 * Throws: ConstructionException GTK+ fails to create the object.
183 	 */
184 	public this()
185 	{
186 		auto p = gtk_model_button_new();
187 		
188 		if(p is null)
189 		{
190 			throw new ConstructionException("null returned by new");
191 		}
192 		
193 		this(cast(GtkModelButton*) p);
194 	}
195 }