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.FileChooserWidget;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.Box;
32 private import gtk.FileChooserIF;
33 private import gtk.FileChooserT;
34 private import gtk.Widget;
35 public  import gtkc.gdktypes;
36 private import gtkc.gtk;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * #GtkFileChooserWidget is a widget for choosing files.
42  * It exposes the #GtkFileChooser interface, and you should
43  * use the methods of this interface to interact with the
44  * widget.
45  */
46 public class FileChooserWidget : Box, FileChooserIF
47 {
48 	/** the main Gtk struct */
49 	protected GtkFileChooserWidget* gtkFileChooserWidget;
50 
51 	/** Get the main Gtk struct */
52 	public GtkFileChooserWidget* getFileChooserWidgetStruct()
53 	{
54 		return gtkFileChooserWidget;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gtkFileChooserWidget;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gtkFileChooserWidget = cast(GtkFileChooserWidget*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GtkFileChooserWidget* gtkFileChooserWidget, bool ownedRef = false)
73 	{
74 		this.gtkFileChooserWidget = gtkFileChooserWidget;
75 		super(cast(GtkBox*)gtkFileChooserWidget, ownedRef);
76 	}
77 
78 	// add the FileChooser capabilities
79 	mixin FileChooserT!(GtkFileChooserWidget);
80 
81 	/**
82 	 */
83 
84 	public static GType getType()
85 	{
86 		return gtk_file_chooser_widget_get_type();
87 	}
88 
89 	/**
90 	 * Creates a new #GtkFileChooserWidget.  This is a file chooser widget that can
91 	 * be embedded in custom windows, and it is the same widget that is used by
92 	 * #GtkFileChooserDialog.
93 	 *
94 	 * Params:
95 	 *     action = Open or save mode for the widget
96 	 *
97 	 * Return: a new #GtkFileChooserWidget
98 	 *
99 	 * Since: 2.4
100 	 *
101 	 * Throws: ConstructionException GTK+ fails to create the object.
102 	 */
103 	public this(GtkFileChooserAction action)
104 	{
105 		auto p = gtk_file_chooser_widget_new(action);
106 		
107 		if(p is null)
108 		{
109 			throw new ConstructionException("null returned by new");
110 		}
111 		
112 		this(cast(GtkFileChooserWidget*) p);
113 	}
114 
115 	int[string] connectedSignals;
116 
117 	void delegate(FileChooserWidget)[] onDesktopFolderListeners;
118 	/**
119 	 * The ::desktop-folder signal is a
120 	 * [keybinding signal][GtkBindingSignal]
121 	 * which gets emitted when the user asks for it.
122 	 *
123 	 * This is used to make the file chooser show the user's Desktop
124 	 * folder in the file list.
125 	 *
126 	 * The default binding for this signal is `Alt + D`.
127 	 */
128 	void addOnDesktopFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
129 	{
130 		if ( "desktop-folder" !in connectedSignals )
131 		{
132 			Signals.connectData(
133 				this,
134 				"desktop-folder",
135 				cast(GCallback)&callBackDesktopFolder,
136 				cast(void*)this,
137 				null,
138 				connectFlags);
139 			connectedSignals["desktop-folder"] = 1;
140 		}
141 		onDesktopFolderListeners ~= dlg;
142 	}
143 	extern(C) static void callBackDesktopFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
144 	{
145 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDesktopFolderListeners )
146 		{
147 			dlg(_filechooserwidget);
148 		}
149 	}
150 
151 	void delegate(FileChooserWidget)[] onDownFolderListeners;
152 	/**
153 	 * The ::down-folder signal is a
154 	 * [keybinding signal][GtkBindingSignal]
155 	 * which gets emitted when the user asks for it.
156 	 *
157 	 * This is used to make the file chooser go to a child of the
158 	 * current folder in the file hierarchy.  The subfolder that
159 	 * will be used is displayed in the path bar widget of the file
160 	 * chooser.  For example, if the path bar is showing
161 	 * "/foo/bar/baz", with bar currently displayed, then this will cause
162 	 * the file chooser to switch to the "baz" subfolder.
163 	 *
164 	 * The default binding for this signal is `Alt + Down`.
165 	 */
166 	void addOnDownFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
167 	{
168 		if ( "down-folder" !in connectedSignals )
169 		{
170 			Signals.connectData(
171 				this,
172 				"down-folder",
173 				cast(GCallback)&callBackDownFolder,
174 				cast(void*)this,
175 				null,
176 				connectFlags);
177 			connectedSignals["down-folder"] = 1;
178 		}
179 		onDownFolderListeners ~= dlg;
180 	}
181 	extern(C) static void callBackDownFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
182 	{
183 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDownFolderListeners )
184 		{
185 			dlg(_filechooserwidget);
186 		}
187 	}
188 
189 	void delegate(FileChooserWidget)[] onHomeFolderListeners;
190 	/**
191 	 * The ::home-folder signal is a
192 	 * [keybinding signal][GtkBindingSignal]
193 	 * which gets emitted when the user asks for it.
194 	 *
195 	 * This is used to make the file chooser show the user's home
196 	 * folder in the file list.
197 	 *
198 	 * The default binding for this signal is `Alt + Home`.
199 	 */
200 	void addOnHomeFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
201 	{
202 		if ( "home-folder" !in connectedSignals )
203 		{
204 			Signals.connectData(
205 				this,
206 				"home-folder",
207 				cast(GCallback)&callBackHomeFolder,
208 				cast(void*)this,
209 				null,
210 				connectFlags);
211 			connectedSignals["home-folder"] = 1;
212 		}
213 		onHomeFolderListeners ~= dlg;
214 	}
215 	extern(C) static void callBackHomeFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
216 	{
217 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onHomeFolderListeners )
218 		{
219 			dlg(_filechooserwidget);
220 		}
221 	}
222 
223 	void delegate(string, FileChooserWidget)[] onLocationPopupListeners;
224 	/**
225 	 * The ::location-popup signal is a
226 	 * [keybinding signal][GtkBindingSignal]
227 	 * which gets emitted when the user asks for it.
228 	 *
229 	 * This is used to make the file chooser show a "Location"
230 	 * prompt which the user can use to manually type the name of
231 	 * the file he wishes to select.
232 	 *
233 	 * The default bindings for this signal are
234 	 * `Control + L`
235 	 * with a @path string of "" (the empty
236 	 * string).  It is also bound to `/` with a
237 	 * @path string of "`/`"
238 	 * (a slash):  this lets you type `/` and
239 	 * immediately type a path name.  On Unix systems, this is bound to
240 	 * `~` (tilde) with a @path string
241 	 * of "~" itself for access to home directories.
242 	 *
243 	 * Params:
244 	 *     path = a string that gets put in the text entry for the file
245 	 *         name.
246 	 */
247 	void addOnLocationPopup(void delegate(string, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
248 	{
249 		if ( "location-popup" !in connectedSignals )
250 		{
251 			Signals.connectData(
252 				this,
253 				"location-popup",
254 				cast(GCallback)&callBackLocationPopup,
255 				cast(void*)this,
256 				null,
257 				connectFlags);
258 			connectedSignals["location-popup"] = 1;
259 		}
260 		onLocationPopupListeners ~= dlg;
261 	}
262 	extern(C) static void callBackLocationPopup(GtkFileChooserWidget* filechooserwidgetStruct, char* path, FileChooserWidget _filechooserwidget)
263 	{
264 		foreach ( void delegate(string, FileChooserWidget) dlg; _filechooserwidget.onLocationPopupListeners )
265 		{
266 			dlg(Str.toString(path), _filechooserwidget);
267 		}
268 	}
269 
270 	void delegate(FileChooserWidget)[] onLocationPopupOnPasteListeners;
271 	/**
272 	 * The ::location-popup-on-paste signal is a
273 	 * [keybinding signal][GtkBindingSignal]
274 	 * which gets emitted when the user asks for it.
275 	 *
276 	 * This is used to make the file chooser show a "Location"
277 	 * prompt when the user pastes #GtkFileChooserWidget.
278 	 *
279 	 * The default binding for this signal is `Control + V`.
280 	 */
281 	void addOnLocationPopupOnPaste(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
282 	{
283 		if ( "location-popup-on-paste" !in connectedSignals )
284 		{
285 			Signals.connectData(
286 				this,
287 				"location-popup-on-paste",
288 				cast(GCallback)&callBackLocationPopupOnPaste,
289 				cast(void*)this,
290 				null,
291 				connectFlags);
292 			connectedSignals["location-popup-on-paste"] = 1;
293 		}
294 		onLocationPopupOnPasteListeners ~= dlg;
295 	}
296 	extern(C) static void callBackLocationPopupOnPaste(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
297 	{
298 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationPopupOnPasteListeners )
299 		{
300 			dlg(_filechooserwidget);
301 		}
302 	}
303 
304 	void delegate(FileChooserWidget)[] onLocationTogglePopupListeners;
305 	/**
306 	 * The ::location-toggle-popup signal is a
307 	 * [keybinding signal][GtkBindingSignal]
308 	 * which gets emitted when the user asks for it.
309 	 *
310 	 * This is used to toggle the visibility of a "Location"
311 	 * prompt which the user can use to manually type the name of
312 	 * the file he wishes to select.
313 	 *
314 	 * The default binding for this signal is `Control + L`.
315 	 */
316 	void addOnLocationTogglePopup(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
317 	{
318 		if ( "location-toggle-popup" !in connectedSignals )
319 		{
320 			Signals.connectData(
321 				this,
322 				"location-toggle-popup",
323 				cast(GCallback)&callBackLocationTogglePopup,
324 				cast(void*)this,
325 				null,
326 				connectFlags);
327 			connectedSignals["location-toggle-popup"] = 1;
328 		}
329 		onLocationTogglePopupListeners ~= dlg;
330 	}
331 	extern(C) static void callBackLocationTogglePopup(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
332 	{
333 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationTogglePopupListeners )
334 		{
335 			dlg(_filechooserwidget);
336 		}
337 	}
338 
339 	void delegate(int, FileChooserWidget)[] onQuickBookmarkListeners;
340 	/**
341 	 * The ::quick-bookmark signal is a
342 	 * [keybinding signal][GtkBindingSignal]
343 	 * which gets emitted when the user asks for it.
344 	 *
345 	 * This is used to make the file chooser switch to the bookmark
346 	 * specified in the @bookmark_index parameter.
347 	 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
348 	 * this signal to switch to each of them, respectively.
349 	 *
350 	 * The default binding for this signal is `Alt + 1`, `Alt + 2`,
351 	 * etc. until `Alt + 0`.  Note that in the default binding, that
352 	 * `Alt + 1` is actually defined to switch to the bookmark at index
353 	 * 0, and so on successively; `Alt + 0` is defined to switch to the
354 	 * bookmark at index 10.
355 	 *
356 	 * Params:
357 	 *     bookmarkIndex = the number of the bookmark to switch to
358 	 */
359 	void addOnQuickBookmark(void delegate(int, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
360 	{
361 		if ( "quick-bookmark" !in connectedSignals )
362 		{
363 			Signals.connectData(
364 				this,
365 				"quick-bookmark",
366 				cast(GCallback)&callBackQuickBookmark,
367 				cast(void*)this,
368 				null,
369 				connectFlags);
370 			connectedSignals["quick-bookmark"] = 1;
371 		}
372 		onQuickBookmarkListeners ~= dlg;
373 	}
374 	extern(C) static void callBackQuickBookmark(GtkFileChooserWidget* filechooserwidgetStruct, int bookmarkIndex, FileChooserWidget _filechooserwidget)
375 	{
376 		foreach ( void delegate(int, FileChooserWidget) dlg; _filechooserwidget.onQuickBookmarkListeners )
377 		{
378 			dlg(bookmarkIndex, _filechooserwidget);
379 		}
380 	}
381 
382 	void delegate(FileChooserWidget)[] onRecentShortcutListeners;
383 	/**
384 	 * The ::recent-shortcut signal is a
385 	 * [keybinding signal][GtkBindingSignal]
386 	 * which gets emitted when the user asks for it.
387 	 *
388 	 * This is used to make the file chooser show the Recent location.
389 	 *
390 	 * The default binding for this signal is `Alt + R`.
391 	 */
392 	void addOnRecentShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
393 	{
394 		if ( "recent-shortcut" !in connectedSignals )
395 		{
396 			Signals.connectData(
397 				this,
398 				"recent-shortcut",
399 				cast(GCallback)&callBackRecentShortcut,
400 				cast(void*)this,
401 				null,
402 				connectFlags);
403 			connectedSignals["recent-shortcut"] = 1;
404 		}
405 		onRecentShortcutListeners ~= dlg;
406 	}
407 	extern(C) static void callBackRecentShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
408 	{
409 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onRecentShortcutListeners )
410 		{
411 			dlg(_filechooserwidget);
412 		}
413 	}
414 
415 	void delegate(FileChooserWidget)[] onSearchShortcutListeners;
416 	/**
417 	 * The ::search-shortcut signal is a
418 	 * [keybinding signal][GtkBindingSignal]
419 	 * which gets emitted when the user asks for it.
420 	 *
421 	 * This is used to make the file chooser show the search entry.
422 	 *
423 	 * The default binding for this signal is `Alt + S`.
424 	 */
425 	void addOnSearchShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
426 	{
427 		if ( "search-shortcut" !in connectedSignals )
428 		{
429 			Signals.connectData(
430 				this,
431 				"search-shortcut",
432 				cast(GCallback)&callBackSearchShortcut,
433 				cast(void*)this,
434 				null,
435 				connectFlags);
436 			connectedSignals["search-shortcut"] = 1;
437 		}
438 		onSearchShortcutListeners ~= dlg;
439 	}
440 	extern(C) static void callBackSearchShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
441 	{
442 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onSearchShortcutListeners )
443 		{
444 			dlg(_filechooserwidget);
445 		}
446 	}
447 
448 	void delegate(FileChooserWidget)[] onShowHiddenListeners;
449 	/**
450 	 * The ::show-hidden signal is a
451 	 * [keybinding signal][GtkBindingSignal]
452 	 * which gets emitted when the user asks for it.
453 	 *
454 	 * This is used to make the file chooser display hidden files.
455 	 *
456 	 * The default binding for this signal is `Control + H`.
457 	 */
458 	void addOnShowHidden(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
459 	{
460 		if ( "show-hidden" !in connectedSignals )
461 		{
462 			Signals.connectData(
463 				this,
464 				"show-hidden",
465 				cast(GCallback)&callBackShowHidden,
466 				cast(void*)this,
467 				null,
468 				connectFlags);
469 			connectedSignals["show-hidden"] = 1;
470 		}
471 		onShowHiddenListeners ~= dlg;
472 	}
473 	extern(C) static void callBackShowHidden(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
474 	{
475 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onShowHiddenListeners )
476 		{
477 			dlg(_filechooserwidget);
478 		}
479 	}
480 
481 	void delegate(FileChooserWidget)[] onUpFolderListeners;
482 	/**
483 	 * The ::up-folder signal is a
484 	 * [keybinding signal][GtkBindingSignal]
485 	 * which gets emitted when the user asks for it.
486 	 *
487 	 * This is used to make the file chooser go to the parent of
488 	 * the current folder in the file hierarchy.
489 	 *
490 	 * The default binding for this signal is `Alt + Up`.
491 	 */
492 	void addOnUpFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
493 	{
494 		if ( "up-folder" !in connectedSignals )
495 		{
496 			Signals.connectData(
497 				this,
498 				"up-folder",
499 				cast(GCallback)&callBackUpFolder,
500 				cast(void*)this,
501 				null,
502 				connectFlags);
503 			connectedSignals["up-folder"] = 1;
504 		}
505 		onUpFolderListeners ~= dlg;
506 	}
507 	extern(C) static void callBackUpFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget)
508 	{
509 		foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onUpFolderListeners )
510 		{
511 			dlg(_filechooserwidget);
512 		}
513 	}
514 }