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