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  = GtkAccelLabel.html
27  * outPack = gtk
28  * outFile = AccelLabel
29  * strct   = GtkAccelLabel
30  * realStrct=
31  * ctorStrct=
32  * clss    = AccelLabel
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_accel_label_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gobject.Closure
48  * 	- gtk.Widget
49  * structWrap:
50  * 	- GClosure* -> Closure
51  * 	- GtkWidget* -> Widget
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.AccelLabel;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import glib.Str;
66 private import gobject.Closure;
67 private import gtk.Widget;
68 
69 
70 private import gtk.Label;
71 
72 /**
73  * The GtkAccelLabel widget is a subclass of GtkLabel that also displays an
74  * accelerator key on the right of the label text, e.g. 'Ctl+S'.
75  * It is commonly used in menus to show the keyboard short-cuts for commands.
76  *
77  * The accelerator key to display is not set explicitly.
78  * Instead, the GtkAccelLabel displays the accelerators which have been added to
79  * a particular widget. This widget is set by calling
80  * gtk_accel_label_set_accel_widget().
81  *
82  * For example, a GtkMenuItem widget may have an accelerator added to emit the
83  * "activate" signal when the 'Ctl+S' key combination is pressed.
84  * A GtkAccelLabel is created and added to the GtkMenuItem, and
85  * gtk_accel_label_set_accel_widget() is called with the GtkMenuItem as the
86  * second argument. The GtkAccelLabel will now display 'Ctl+S' after its label.
87  *
88  * Note that creating a GtkMenuItem with gtk_menu_item_new_with_label() (or
89  * one of the similar functions for GtkCheckMenuItem and GtkRadioMenuItem)
90  * automatically adds a GtkAccelLabel to the GtkMenuItem and calls
91  * gtk_accel_label_set_accel_widget() to set it up for you.
92  *
93  * A GtkAccelLabel will only display accelerators which have GTK_ACCEL_VISIBLE
94  * set (see GtkAccelFlags).
95  * A GtkAccelLabel can display multiple accelerators and even signal names,
96  * though it is almost always used to display just one accelerator key.
97  *
98  * $(DDOC_COMMENT example)
99  */
100 public class AccelLabel : Label
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GtkAccelLabel* gtkAccelLabel;
105 	
106 	
107 	/** Get the main Gtk struct */
108 	public GtkAccelLabel* getAccelLabelStruct()
109 	{
110 		return gtkAccelLabel;
111 	}
112 	
113 	
114 	/** the main Gtk struct as a void* */
115 	protected override void* getStruct()
116 	{
117 		return cast(void*)gtkAccelLabel;
118 	}
119 	
120 	/**
121 	 * Sets our main struct and passes it to the parent class
122 	 */
123 	public this (GtkAccelLabel* gtkAccelLabel)
124 	{
125 		super(cast(GtkLabel*)gtkAccelLabel);
126 		this.gtkAccelLabel = gtkAccelLabel;
127 	}
128 	
129 	protected override void setStruct(GObject* obj)
130 	{
131 		super.setStruct(obj);
132 		gtkAccelLabel = cast(GtkAccelLabel*)obj;
133 	}
134 	
135 	/**
136 	 */
137 	
138 	/**
139 	 * Creates a new GtkAccelLabel.
140 	 * Params:
141 	 * string = the label string. Must be non-NULL.
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this (string string)
145 	{
146 		// GtkWidget * gtk_accel_label_new (const gchar *string);
147 		auto p = gtk_accel_label_new(Str.toStringz(string));
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by gtk_accel_label_new(Str.toStringz(string))");
151 		}
152 		this(cast(GtkAccelLabel*) p);
153 	}
154 	
155 	/**
156 	 * Sets the closure to be monitored by this accelerator label. The closure
157 	 * must be connected to an accelerator group; see gtk_accel_group_connect().
158 	 * Params:
159 	 * accelClosure = the closure to monitor for accelerator changes.
160 	 */
161 	public void setAccelClosure(Closure accelClosure)
162 	{
163 		// void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label,  GClosure *accel_closure);
164 		gtk_accel_label_set_accel_closure(gtkAccelLabel, (accelClosure is null) ? null : accelClosure.getClosureStruct());
165 	}
166 	
167 	/**
168 	 * Fetches the widget monitored by this accelerator label. See
169 	 * gtk_accel_label_set_accel_widget().
170 	 * Returns: the object monitored by the accelerator label, or NULL. [transfer none]
171 	 */
172 	public Widget getAccelWidget()
173 	{
174 		// GtkWidget * gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label);
175 		auto p = gtk_accel_label_get_accel_widget(gtkAccelLabel);
176 		
177 		if(p is null)
178 		{
179 			return null;
180 		}
181 		
182 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
183 	}
184 	
185 	/**
186 	 * Sets the widget to be monitored by this accelerator label.
187 	 * Params:
188 	 * accelWidget = the widget to be monitored.
189 	 */
190 	public void setAccelWidget(Widget accelWidget)
191 	{
192 		// void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label,  GtkWidget *accel_widget);
193 		gtk_accel_label_set_accel_widget(gtkAccelLabel, (accelWidget is null) ? null : accelWidget.getWidgetStruct());
194 	}
195 	
196 	/**
197 	 * Returns the width needed to display the accelerator key(s).
198 	 * This is used by menus to align all of the GtkMenuItem widgets, and shouldn't
199 	 * be needed by applications.
200 	 * Returns: the width needed to display the accelerator key(s).
201 	 */
202 	public uint getAccelWidth()
203 	{
204 		// guint gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label);
205 		return gtk_accel_label_get_accel_width(gtkAccelLabel);
206 	}
207 	
208 	/**
209 	 * Manually sets a keyval and modifier mask as the accelerator rendered
210 	 * by accel_label.
211 	 * If a keyval and modifier are explicitly set then these values are
212 	 * used regardless of any associated accel closure or widget.
213 	 * Providing an accelerator_key of 0 removes the manual setting.
214 	 * Params:
215 	 * acceleratorKey = a keyval, or 0
216 	 * acceleratorMods = the modifier mask for the accel
217 	 * Since 3.6
218 	 */
219 	public void setAccel(uint acceleratorKey, GdkModifierType acceleratorMods)
220 	{
221 		// void gtk_accel_label_set_accel (GtkAccelLabel *accel_label,  guint accelerator_key,  GdkModifierType accelerator_mods);
222 		gtk_accel_label_set_accel(gtkAccelLabel, acceleratorKey, acceleratorMods);
223 	}
224 	
225 	/**
226 	 * Recreates the string representing the accelerator keys.
227 	 * This should not be needed since the string is automatically updated whenever
228 	 * accelerators are added or removed from the associated widget.
229 	 * Returns: always returns FALSE.
230 	 */
231 	public int refetch()
232 	{
233 		// gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label);
234 		return gtk_accel_label_refetch(gtkAccelLabel);
235 	}
236 }