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  = GtkFileChooserButton.html
27  * outPack = gtk
28  * outFile = FileChooserButton
29  * strct   = GtkFileChooserButton
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileChooserButton
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- FileChooserIF
40  * prefixes:
41  * 	- gtk_file_chooser_button_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.Widget
49  * 	- gtk.FileChooserT
50  * 	- gtk.FileChooserIF
51  * structWrap:
52  * 	- GtkWidget* -> Widget
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.FileChooserButton;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 private import glib.Str;
69 private import gtk.Widget;
70 private import gtk.FileChooserT;
71 private import gtk.FileChooserIF;
72 
73 
74 private import gtk.Box;
75 
76 /**
77  * The GtkFileChooserButton is a widget that lets the user select a
78  * file. It implements the GtkFileChooser interface. Visually, it is a
79  * file name with a button to bring up a GtkFileChooserDialog.
80  * The user can then use that dialog to change the file associated with
81  * that button. This widget does not support setting the
82  * "select-multiple" property to TRUE.
83  *
84  * $(DDOC_COMMENT example)
85  *
86  * The GtkFileChooserButton supports the GtkFileChooserActions
87  * GTK_FILE_CHOOSER_ACTION_OPEN and GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
88  *
89  * Important
90  *
91  * The GtkFileChooserButton will ellipsize the label,
92  * and will thus request little horizontal space. To give the button
93  * more space, you should call gtk_widget_get_preferred_size(),
94  * gtk_file_chooser_button_set_width_chars(), or pack the button in
95  * such a way that other interface elements give space to the widget.
96  */
97 public class FileChooserButton : Box, FileChooserIF
98 {
99 	
100 	/** the main Gtk struct */
101 	protected GtkFileChooserButton* gtkFileChooserButton;
102 	
103 	
104 	/** Get the main Gtk struct */
105 	public GtkFileChooserButton* getFileChooserButtonStruct()
106 	{
107 		return gtkFileChooserButton;
108 	}
109 	
110 	
111 	/** the main Gtk struct as a void* */
112 	protected override void* getStruct()
113 	{
114 		return cast(void*)gtkFileChooserButton;
115 	}
116 	
117 	/**
118 	 * Sets our main struct and passes it to the parent class
119 	 */
120 	public this (GtkFileChooserButton* gtkFileChooserButton)
121 	{
122 		super(cast(GtkBox*)gtkFileChooserButton);
123 		this.gtkFileChooserButton = gtkFileChooserButton;
124 	}
125 	
126 	protected override void setStruct(GObject* obj)
127 	{
128 		super.setStruct(obj);
129 		gtkFileChooserButton = cast(GtkFileChooserButton*)obj;
130 	}
131 	
132 	// add the FileChooser capabilities
133 	mixin FileChooserT!(GtkFileChooserButton);
134 	
135 	/**
136 	 */
137 	int[string] connectedSignals;
138 	
139 	void delegate(FileChooserButton)[] onFileSetListeners;
140 	/**
141 	 * The ::file-set signal is emitted when the user selects a file.
142 	 * Note that this signal is only emitted when the user
143 	 * changes the file.
144 	 * Since 2.12
145 	 * See Also
146 	 * GtkFileChooserDialog
147 	 */
148 	void addOnFileSet(void delegate(FileChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
149 	{
150 		if ( !("file-set" in connectedSignals) )
151 		{
152 			Signals.connectData(
153 			getStruct(),
154 			"file-set",
155 			cast(GCallback)&callBackFileSet,
156 			cast(void*)this,
157 			null,
158 			connectFlags);
159 			connectedSignals["file-set"] = 1;
160 		}
161 		onFileSetListeners ~= dlg;
162 	}
163 	extern(C) static void callBackFileSet(GtkFileChooserButton* widgetStruct, FileChooserButton _fileChooserButton)
164 	{
165 		foreach ( void delegate(FileChooserButton) dlg ; _fileChooserButton.onFileSetListeners )
166 		{
167 			dlg(_fileChooserButton);
168 		}
169 	}
170 	
171 	
172 	/**
173 	 * Creates a new file-selecting button widget.
174 	 * Since 2.6
175 	 * Params:
176 	 * title = the title of the browse dialog.
177 	 * action = the open mode for the widget.
178 	 * Throws: ConstructionException GTK+ fails to create the object.
179 	 */
180 	public this (string title, GtkFileChooserAction action)
181 	{
182 		// GtkWidget * gtk_file_chooser_button_new (const gchar *title,  GtkFileChooserAction action);
183 		auto p = gtk_file_chooser_button_new(Str.toStringz(title), action);
184 		if(p is null)
185 		{
186 			throw new ConstructionException("null returned by gtk_file_chooser_button_new(Str.toStringz(title), action)");
187 		}
188 		this(cast(GtkFileChooserButton*) p);
189 	}
190 	
191 	/**
192 	 * Creates a GtkFileChooserButton widget which uses dialog as its
193 	 * file-picking window.
194 	 * Note that dialog must be a GtkDialog (or subclass) which
195 	 * implements the GtkFileChooser interface and must not have
196 	 * GTK_DIALOG_DESTROY_WITH_PARENT set.
197 	 * Also note that the dialog needs to have its confirmative button
198 	 * added with response GTK_RESPONSE_ACCEPT or GTK_RESPONSE_OK in
199 	 * order for the button to take over the file selected in the dialog.
200 	 * Since 2.6
201 	 * Params:
202 	 * dialog = the widget to use as dialog
203 	 * Throws: ConstructionException GTK+ fails to create the object.
204 	 */
205 	public this (Widget dialog)
206 	{
207 		// GtkWidget * gtk_file_chooser_button_new_with_dialog  (GtkWidget *dialog);
208 		auto p = gtk_file_chooser_button_new_with_dialog((dialog is null) ? null : dialog.getWidgetStruct());
209 		if(p is null)
210 		{
211 			throw new ConstructionException("null returned by gtk_file_chooser_button_new_with_dialog((dialog is null) ? null : dialog.getWidgetStruct())");
212 		}
213 		this(cast(GtkFileChooserButton*) p);
214 	}
215 	
216 	/**
217 	 * Retrieves the title of the browse dialog used by button. The returned value
218 	 * should not be modified or freed.
219 	 * Since 2.6
220 	 * Returns: a pointer to the browse dialog's title.
221 	 */
222 	public string getTitle()
223 	{
224 		// const gchar * gtk_file_chooser_button_get_title (GtkFileChooserButton *button);
225 		return Str.toString(gtk_file_chooser_button_get_title(gtkFileChooserButton));
226 	}
227 	
228 	/**
229 	 * Modifies the title of the browse dialog used by button.
230 	 * Since 2.6
231 	 * Params:
232 	 * title = the new browse dialog title.
233 	 */
234 	public void setTitle(string title)
235 	{
236 		// void gtk_file_chooser_button_set_title (GtkFileChooserButton *button,  const gchar *title);
237 		gtk_file_chooser_button_set_title(gtkFileChooserButton, Str.toStringz(title));
238 	}
239 	
240 	/**
241 	 * Retrieves the width in characters of the button widget's entry and/or label.
242 	 * Since 2.6
243 	 * Returns: an integer width (in characters) that the button will use to size itself.
244 	 */
245 	public int getWidthChars()
246 	{
247 		// gint gtk_file_chooser_button_get_width_chars  (GtkFileChooserButton *button);
248 		return gtk_file_chooser_button_get_width_chars(gtkFileChooserButton);
249 	}
250 	
251 	/**
252 	 * Sets the width (in characters) that button will use to n_chars.
253 	 * Since 2.6
254 	 * Params:
255 	 * nChars = the new width, in characters.
256 	 */
257 	public void setWidthChars(int nChars)
258 	{
259 		// void gtk_file_chooser_button_set_width_chars  (GtkFileChooserButton *button,  gint n_chars);
260 		gtk_file_chooser_button_set_width_chars(gtkFileChooserButton, nChars);
261 	}
262 	
263 	/**
264 	 * Returns whether the button grabs focus when it is clicked with the mouse.
265 	 * See gtk_file_chooser_button_set_focus_on_click().
266 	 * Since 2.10
267 	 * Returns: TRUE if the button grabs focus when it is clicked with the mouse.
268 	 */
269 	public int getFocusOnClick()
270 	{
271 		// gboolean gtk_file_chooser_button_get_focus_on_click  (GtkFileChooserButton *button);
272 		return gtk_file_chooser_button_get_focus_on_click(gtkFileChooserButton);
273 	}
274 	
275 	/**
276 	 * Sets whether the button will grab focus when it is clicked with the mouse.
277 	 * Making mouse clicks not grab focus is useful in places like toolbars where
278 	 * you don't want the keyboard focus removed from the main area of the
279 	 * application.
280 	 * Since 2.10
281 	 * Params:
282 	 * focusOnClick = whether the button grabs focus when clicked with the mouse
283 	 */
284 	public void setFocusOnClick(int focusOnClick)
285 	{
286 		// void gtk_file_chooser_button_set_focus_on_click  (GtkFileChooserButton *button,  gboolean focus_on_click);
287 		gtk_file_chooser_button_set_focus_on_click(gtkFileChooserButton, focusOnClick);
288 	}
289 }