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