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  = GtkFontButton.html
27  * outPack = gtk
28  * outFile = FontButton
29  * strct   = GtkFontButton
30  * realStrct=
31  * ctorStrct=
32  * clss    = FontButton
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_font_button_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * structWrap:
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gtk.FontButton;
55 
56 public  import gtkc.gtktypes;
57 
58 private import gtkc.gtk;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 private import gobject.Signals;
63 public  import gtkc.gdktypes;
64 
65 private import glib.Str;
66 
67 
68 
69 private import gtk.Button;
70 
71 /**
72  * Description
73  * The GtkFontButton is a button which displays the currently selected font an allows to open a font selection
74  * dialog to change the font. It is suitable widget for selecting a font in a preference dialog.
75  */
76 public class FontButton : Button
77 {
78 	
79 	/** the main Gtk struct */
80 	protected GtkFontButton* gtkFontButton;
81 	
82 	
83 	public GtkFontButton* getFontButtonStruct()
84 	{
85 		return gtkFontButton;
86 	}
87 	
88 	
89 	/** the main Gtk struct as a void* */
90 	protected override void* getStruct()
91 	{
92 		return cast(void*)gtkFontButton;
93 	}
94 	
95 	/**
96 	 * Sets our main struct and passes it to the parent class
97 	 */
98 	public this (GtkFontButton* gtkFontButton)
99 	{
100 		super(cast(GtkButton*)gtkFontButton);
101 		this.gtkFontButton = gtkFontButton;
102 	}
103 	
104 	protected override void setStruct(GObject* obj)
105 	{
106 		super.setStruct(obj);
107 		gtkFontButton = cast(GtkFontButton*)obj;
108 	}
109 	
110 	/**
111 	 */
112 	int[string] connectedSignals;
113 	
114 	void delegate(FontButton)[] onFontSetListeners;
115 	/**
116 	 * The ::font-set signal is emitted when the user selects a font.
117 	 * When handling this signal, use gtk_font_button_get_font_name()
118 	 * to find out which font was just selected.
119 	 * Note that this signal is only emitted when the user
120 	 * changes the font. If you need to react to programmatic font changes
121 	 * as well, use the notify::font-name signal.
122 	 * Since 2.4
123 	 * See Also
124 	 * GtkFontSelectionDialog, GtkColorButton.
125 	 */
126 	void addOnFontSet(void delegate(FontButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
127 	{
128 		if ( !("font-set" in connectedSignals) )
129 		{
130 			Signals.connectData(
131 			getStruct(),
132 			"font-set",
133 			cast(GCallback)&callBackFontSet,
134 			cast(void*)this,
135 			null,
136 			connectFlags);
137 			connectedSignals["font-set"] = 1;
138 		}
139 		onFontSetListeners ~= dlg;
140 	}
141 	extern(C) static void callBackFontSet(GtkFontButton* widgetStruct, FontButton _fontButton)
142 	{
143 		foreach ( void delegate(FontButton) dlg ; _fontButton.onFontSetListeners )
144 		{
145 			dlg(_fontButton);
146 		}
147 	}
148 	
149 	
150 	/**
151 	 * Creates a new font picker widget.
152 	 * Since 2.4
153 	 * Throws: ConstructionException GTK+ fails to create the object.
154 	 */
155 	public this ()
156 	{
157 		// GtkWidget * gtk_font_button_new (void);
158 		auto p = gtk_font_button_new();
159 		if(p is null)
160 		{
161 			throw new ConstructionException("null returned by gtk_font_button_new()");
162 		}
163 		this(cast(GtkFontButton*) p);
164 	}
165 	
166 	/**
167 	 * Creates a new font picker widget.
168 	 * Since 2.4
169 	 * Params:
170 	 * fontname = Name of font to display in font selection dialog
171 	 * Throws: ConstructionException GTK+ fails to create the object.
172 	 */
173 	public this (string fontname)
174 	{
175 		// GtkWidget * gtk_font_button_new_with_font (const gchar *fontname);
176 		auto p = gtk_font_button_new_with_font(Str.toStringz(fontname));
177 		if(p is null)
178 		{
179 			throw new ConstructionException("null returned by gtk_font_button_new_with_font(Str.toStringz(fontname))");
180 		}
181 		this(cast(GtkFontButton*) p);
182 	}
183 	
184 	/**
185 	 * Sets or updates the currently-displayed font in font picker dialog.
186 	 * Since 2.4
187 	 * Params:
188 	 * fontname = Name of font to display in font selection dialog
189 	 * Returns: Return value of gtk_font_selection_dialog_set_font_name() if the font selection dialog exists, otherwise FALSE.
190 	 */
191 	public int setFontName(string fontname)
192 	{
193 		// gboolean gtk_font_button_set_font_name (GtkFontButton *font_button,  const gchar *fontname);
194 		return gtk_font_button_set_font_name(gtkFontButton, Str.toStringz(fontname));
195 	}
196 	
197 	/**
198 	 * Retrieves the name of the currently selected font. This name includes
199 	 * style and size information as well. If you want to render something
200 	 * with the font, use this string with pango_font_description_from_string() .
201 	 * If you're interested in peeking certain values (family name,
202 	 * style, size, weight) just query these properties from the
203 	 * PangoFontDescription object.
204 	 * Since 2.4
205 	 * Returns: an internal copy of the font name which must not be freed.
206 	 */
207 	public string getFontName()
208 	{
209 		// const gchar * gtk_font_button_get_font_name (GtkFontButton *font_button);
210 		return Str.toString(gtk_font_button_get_font_name(gtkFontButton));
211 	}
212 	
213 	/**
214 	 * If show_style is TRUE, the font style will be displayed along with name of the selected font.
215 	 * Since 2.4
216 	 * Params:
217 	 * showStyle = TRUE if font style should be displayed in label.
218 	 */
219 	public void setShowStyle(int showStyle)
220 	{
221 		// void gtk_font_button_set_show_style (GtkFontButton *font_button,  gboolean show_style);
222 		gtk_font_button_set_show_style(gtkFontButton, showStyle);
223 	}
224 	
225 	/**
226 	 * Returns whether the name of the font style will be shown in the label.
227 	 * Since 2.4
228 	 * Returns: whether the font style will be shown in the label.
229 	 */
230 	public int getShowStyle()
231 	{
232 		// gboolean gtk_font_button_get_show_style (GtkFontButton *font_button);
233 		return gtk_font_button_get_show_style(gtkFontButton);
234 	}
235 	
236 	/**
237 	 * If show_size is TRUE, the font size will be displayed along with the name of the selected font.
238 	 * Since 2.4
239 	 * Params:
240 	 * showSize = TRUE if font size should be displayed in dialog.
241 	 */
242 	public void setShowSize(int showSize)
243 	{
244 		// void gtk_font_button_set_show_size (GtkFontButton *font_button,  gboolean show_size);
245 		gtk_font_button_set_show_size(gtkFontButton, showSize);
246 	}
247 	
248 	/**
249 	 * Returns whether the font size will be shown in the label.
250 	 * Since 2.4
251 	 * Returns: whether the font size will be shown in the label.
252 	 */
253 	public int getShowSize()
254 	{
255 		// gboolean gtk_font_button_get_show_size (GtkFontButton *font_button);
256 		return gtk_font_button_get_show_size(gtkFontButton);
257 	}
258 	
259 	/**
260 	 * If use_font is TRUE, the font name will be written using the selected font.
261 	 * Since 2.4
262 	 * Params:
263 	 * useFont = If TRUE, font name will be written using font chosen.
264 	 */
265 	public void setUseFont(int useFont)
266 	{
267 		// void gtk_font_button_set_use_font (GtkFontButton *font_button,  gboolean use_font);
268 		gtk_font_button_set_use_font(gtkFontButton, useFont);
269 	}
270 	
271 	/**
272 	 * Returns whether the selected font is used in the label.
273 	 * Since 2.4
274 	 * Returns: whether the selected font is used in the label.
275 	 */
276 	public int getUseFont()
277 	{
278 		// gboolean gtk_font_button_get_use_font (GtkFontButton *font_button);
279 		return gtk_font_button_get_use_font(gtkFontButton);
280 	}
281 	
282 	/**
283 	 * If use_size is TRUE, the font name will be written using the selected size.
284 	 * Since 2.4
285 	 * Params:
286 	 * useSize = If TRUE, font name will be written using the selected size.
287 	 */
288 	public void setUseSize(int useSize)
289 	{
290 		// void gtk_font_button_set_use_size (GtkFontButton *font_button,  gboolean use_size);
291 		gtk_font_button_set_use_size(gtkFontButton, useSize);
292 	}
293 	
294 	/**
295 	 * Returns whether the selected size is used in the label.
296 	 * Since 2.4
297 	 * Returns: whether the selected size is used in the label.
298 	 */
299 	public int getUseSize()
300 	{
301 		// gboolean gtk_font_button_get_use_size (GtkFontButton *font_button);
302 		return gtk_font_button_get_use_size(gtkFontButton);
303 	}
304 	
305 	/**
306 	 * Sets the title for the font selection dialog.
307 	 * Since 2.4
308 	 * Params:
309 	 * title = a string containing the font selection dialog title
310 	 */
311 	public void setTitle(string title)
312 	{
313 		// void gtk_font_button_set_title (GtkFontButton *font_button,  const gchar *title);
314 		gtk_font_button_set_title(gtkFontButton, Str.toStringz(title));
315 	}
316 	
317 	/**
318 	 * Retrieves the title of the font selection dialog.
319 	 * Since 2.4
320 	 * Returns: an internal copy of the title string which must not be freed.
321 	 */
322 	public string getTitle()
323 	{
324 		// const gchar * gtk_font_button_get_title (GtkFontButton *font_button);
325 		return Str.toString(gtk_font_button_get_title(gtkFontButton));
326 	}
327 }