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.FontButton;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtk.FontChooserIF;
33 private import gtk.FontChooserT;
34 private import gtk.Widget;
35 private import gtk.c.functions;
36 public  import gtk.c.types;
37 private import std.algorithm;
38 
39 
40 /**
41  * The `GtkFontButton` allows to open a font chooser dialog to change
42  * the font.
43  * 
44  * ![An example GtkFontButton](font-button.png)
45  * 
46  * It is suitable widget for selecting a font in a preference dialog.
47  * 
48  * # CSS nodes
49  * 
50  * ```
51  * fontbutton
52  * ╰── button.font
53  * ╰── [content]
54  * ```
55  * 
56  * `GtkFontButton` has a single CSS node with name fontbutton which
57  * contains a button node with the .font style class.
58  */
59 public class FontButton : Widget, FontChooserIF
60 {
61 	/** the main Gtk struct */
62 	protected GtkFontButton* gtkFontButton;
63 
64 	/** Get the main Gtk struct */
65 	public GtkFontButton* getFontButtonStruct(bool transferOwnership = false)
66 	{
67 		if (transferOwnership)
68 			ownedRef = false;
69 		return gtkFontButton;
70 	}
71 
72 	/** the main Gtk struct as a void* */
73 	protected override void* getStruct()
74 	{
75 		return cast(void*)gtkFontButton;
76 	}
77 
78 	/**
79 	 * Sets our main struct and passes it to the parent class.
80 	 */
81 	public this (GtkFontButton* gtkFontButton, bool ownedRef = false)
82 	{
83 		this.gtkFontButton = gtkFontButton;
84 		super(cast(GtkWidget*)gtkFontButton, ownedRef);
85 	}
86 
87 	// add the FontChooser capabilities
88 	mixin FontChooserT!(GtkFontButton);
89 
90 
91 	/** */
92 	public static GType getType()
93 	{
94 		return gtk_font_button_get_type();
95 	}
96 
97 	/**
98 	 * Creates a new font picker widget.
99 	 *
100 	 * Returns: a new font picker widget.
101 	 *
102 	 * Throws: ConstructionException GTK+ fails to create the object.
103 	 */
104 	public this()
105 	{
106 		auto __p = gtk_font_button_new();
107 
108 		if(__p is null)
109 		{
110 			throw new ConstructionException("null returned by new");
111 		}
112 
113 		this(cast(GtkFontButton*) __p);
114 	}
115 
116 	/**
117 	 * Creates a new font picker widget showing the given font.
118 	 *
119 	 * Params:
120 	 *     fontname = Name of font to display in font chooser dialog
121 	 *
122 	 * Returns: a new font picker widget.
123 	 *
124 	 * Throws: ConstructionException GTK+ fails to create the object.
125 	 */
126 	public this(string fontname)
127 	{
128 		auto __p = gtk_font_button_new_with_font(Str.toStringz(fontname));
129 
130 		if(__p is null)
131 		{
132 			throw new ConstructionException("null returned by new_with_font");
133 		}
134 
135 		this(cast(GtkFontButton*) __p);
136 	}
137 
138 	/**
139 	 * Gets whether the dialog is modal.
140 	 *
141 	 * Returns: %TRUE if the dialog is modal
142 	 */
143 	public bool getModal()
144 	{
145 		return gtk_font_button_get_modal(gtkFontButton) != 0;
146 	}
147 
148 	/**
149 	 * Retrieves the title of the font chooser dialog.
150 	 *
151 	 * Returns: an internal copy of the title string
152 	 *     which must not be freed.
153 	 */
154 	public string getTitle()
155 	{
156 		return Str.toString(gtk_font_button_get_title(gtkFontButton));
157 	}
158 
159 	/**
160 	 * Returns whether the selected font is used in the label.
161 	 *
162 	 * Returns: whether the selected font is used in the label.
163 	 */
164 	public bool getUseFont()
165 	{
166 		return gtk_font_button_get_use_font(gtkFontButton) != 0;
167 	}
168 
169 	/**
170 	 * Returns whether the selected size is used in the label.
171 	 *
172 	 * Returns: whether the selected size is used in the label.
173 	 */
174 	public bool getUseSize()
175 	{
176 		return gtk_font_button_get_use_size(gtkFontButton) != 0;
177 	}
178 
179 	/**
180 	 * Sets whether the dialog should be modal.
181 	 *
182 	 * Params:
183 	 *     modal = %TRUE to make the dialog modal
184 	 */
185 	public void setModal(bool modal)
186 	{
187 		gtk_font_button_set_modal(gtkFontButton, modal);
188 	}
189 
190 	/**
191 	 * Sets the title for the font chooser dialog.
192 	 *
193 	 * Params:
194 	 *     title = a string containing the font chooser dialog title
195 	 */
196 	public void setTitle(string title)
197 	{
198 		gtk_font_button_set_title(gtkFontButton, Str.toStringz(title));
199 	}
200 
201 	/**
202 	 * If @use_font is %TRUE, the font name will be written
203 	 * using the selected font.
204 	 *
205 	 * Params:
206 	 *     useFont = If %TRUE, font name will be written using font chosen.
207 	 */
208 	public void setUseFont(bool useFont)
209 	{
210 		gtk_font_button_set_use_font(gtkFontButton, useFont);
211 	}
212 
213 	/**
214 	 * If @use_size is %TRUE, the font name will be written using
215 	 * the selected size.
216 	 *
217 	 * Params:
218 	 *     useSize = If %TRUE, font name will be written using the
219 	 *         selected size.
220 	 */
221 	public void setUseSize(bool useSize)
222 	{
223 		gtk_font_button_set_use_size(gtkFontButton, useSize);
224 	}
225 
226 	/**
227 	 * Emitted when the user selects a font.
228 	 *
229 	 * When handling this signal, use [method@Gtk.FontChooser.get_font]
230 	 * to find out which font was just selected.
231 	 *
232 	 * Note that this signal is only emitted when the user changes the font.
233 	 * If you need to react to programmatic font changes as well, use
234 	 * the notify::font signal.
235 	 */
236 	gulong addOnFontSet(void delegate(FontButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
237 	{
238 		return Signals.connect(this, "font-set", dlg, connectFlags ^ ConnectFlags.SWAPPED);
239 	}
240 }