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