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