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  = GtkRecentChooser.html
27  * outPack = gtk
28  * outFile = RecentChooserT
29  * strct   = GtkRecentChooser
30  * realStrct=
31  * ctorStrct=
32  * clss    = RecentChooserT
33  * interf  = RecentChooserIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gtk_recent_chooser_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- glib.ListG
51  * 	- glib.ListSG
52  * 	- gtk.RecentInfo
53  * 	- gtk.RecentFilter
54  * structWrap:
55  * 	- GList* -> ListG
56  * 	- GSList* -> ListSG
57  * 	- GtkRecentFilter* -> RecentFilter
58  * 	- GtkRecentInfo* -> RecentInfo
59  * module aliases:
60  * local aliases:
61  * 	- getShowNumbers -> recentChooserGetShowNumbers
62  * 	- setShowNumbers -> recentChooserSetShowNumbers
63  * overrides:
64  */
65 
66 module gtk.RecentChooserT;
67 
68 public  import gtkc.gtktypes;
69 
70 public import gtkc.gtk;
71 public import glib.ConstructionException;
72 public import gobject.ObjectG;
73 
74 public import gobject.Signals;
75 public  import gtkc.gdktypes;
76 public import glib.Str;
77 public import glib.ErrorG;
78 public import glib.GException;
79 public import glib.ListG;
80 public import glib.ListSG;
81 public import gtk.RecentInfo;
82 public import gtk.RecentFilter;
83 
84 
85 
86 /**
87  * GtkRecentChooser is an interface that can be implemented by widgets
88  * displaying the list of recently used files. In GTK+, the main objects
89  * that implement this interface are GtkRecentChooserWidget,
90  * GtkRecentChooserDialog and GtkRecentChooserMenu.
91  *
92  * Recently used files are supported since GTK+ 2.10.
93  */
94 public template RecentChooserT(TStruct)
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GtkRecentChooser* gtkRecentChooser;
99 	
100 	
101 	/** Get the main Gtk struct */
102 	public GtkRecentChooser* getRecentChooserTStruct()
103 	{
104 		return cast(GtkRecentChooser*)getStruct();
105 	}
106 	
107 	
108 	/**
109 	 */
110 	int[string] connectedSignals;
111 	
112 	void delegate(RecentChooserIF)[] _onItemActivatedListeners;
113 	@property void delegate(RecentChooserIF)[] onItemActivatedListeners()
114 	{
115 		return  _onItemActivatedListeners;
116 	}
117 	/**
118 	 * This signal is emitted when the user "activates" a recent item
119 	 * in the recent chooser. This can happen by double-clicking on an item
120 	 * in the recently used resources list, or by pressing
121 	 * Enter.
122 	 * Since 2.10
123 	 */
124 	void addOnItemActivated(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
125 	{
126 		if ( !("item-activated" in connectedSignals) )
127 		{
128 			Signals.connectData(
129 			getStruct(),
130 			"item-activated",
131 			cast(GCallback)&callBackItemActivated,
132 			cast(void*)cast(RecentChooserIF)this,
133 			null,
134 			connectFlags);
135 			connectedSignals["item-activated"] = 1;
136 		}
137 		_onItemActivatedListeners ~= dlg;
138 	}
139 	extern(C) static void callBackItemActivated(GtkRecentChooser* chooserStruct, RecentChooserIF _recentChooserIF)
140 	{
141 		foreach ( void delegate(RecentChooserIF) dlg ; _recentChooserIF.onItemActivatedListeners )
142 		{
143 			dlg(_recentChooserIF);
144 		}
145 	}
146 	
147 	void delegate(RecentChooserIF)[] _onSelectionChangedListeners;
148 	@property void delegate(RecentChooserIF)[] onSelectionChangedListeners()
149 	{
150 		return  _onSelectionChangedListeners;
151 	}
152 	/**
153 	 * This signal is emitted when there is a change in the set of
154 	 * selected recently used resources. This can happen when a user
155 	 * modifies the selection with the mouse or the keyboard, or when
156 	 * explicitely calling functions to change the selection.
157 	 * Since 2.10
158 	 * See Also
159 	 * GtkRecentManager, GtkRecentChooserDialog,
160 	 *  GtkRecentChooserWidget, GtkRecentChooserMenu
161 	 */
162 	void addOnSelectionChanged(void delegate(RecentChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
163 	{
164 		if ( !("selection-changed" in connectedSignals) )
165 		{
166 			Signals.connectData(
167 			getStruct(),
168 			"selection-changed",
169 			cast(GCallback)&callBackSelectionChanged,
170 			cast(void*)cast(RecentChooserIF)this,
171 			null,
172 			connectFlags);
173 			connectedSignals["selection-changed"] = 1;
174 		}
175 		_onSelectionChangedListeners ~= dlg;
176 	}
177 	extern(C) static void callBackSelectionChanged(GtkRecentChooser* chooserStruct, RecentChooserIF _recentChooserIF)
178 	{
179 		foreach ( void delegate(RecentChooserIF) dlg ; _recentChooserIF.onSelectionChangedListeners )
180 		{
181 			dlg(_recentChooserIF);
182 		}
183 	}
184 	
185 	
186 	/**
187 	 * Whether to show recently used resources marked registered as private.
188 	 * Since 2.10
189 	 * Params:
190 	 * showPrivate = TRUE to show private items, FALSE otherwise
191 	 */
192 	public void setShowPrivate(int showPrivate)
193 	{
194 		// void gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,  gboolean show_private);
195 		gtk_recent_chooser_set_show_private(getRecentChooserTStruct(), showPrivate);
196 	}
197 	
198 	/**
199 	 * Returns whether chooser should display recently used resources
200 	 * registered as private.
201 	 * Since 2.10
202 	 * Returns: TRUE if the recent chooser should show private items, FALSE otherwise.
203 	 */
204 	public int getShowPrivate()
205 	{
206 		// gboolean gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser);
207 		return gtk_recent_chooser_get_show_private(getRecentChooserTStruct());
208 	}
209 	
210 	/**
211 	 * Sets whether chooser should display the recently used resources that
212 	 * it didn't find. This only applies to local resources.
213 	 * Since 2.10
214 	 * Params:
215 	 * showNotFound = whether to show the local items we didn't find
216 	 */
217 	public void setShowNotFound(int showNotFound)
218 	{
219 		// void gtk_recent_chooser_set_show_not_found  (GtkRecentChooser *chooser,  gboolean show_not_found);
220 		gtk_recent_chooser_set_show_not_found(getRecentChooserTStruct(), showNotFound);
221 	}
222 	
223 	/**
224 	 * Retrieves whether chooser should show the recently used resources that
225 	 * were not found.
226 	 * Since 2.10
227 	 * Returns: TRUE if the resources not found should be displayed, and FALSE otheriwse.
228 	 */
229 	public int getShowNotFound()
230 	{
231 		// gboolean gtk_recent_chooser_get_show_not_found  (GtkRecentChooser *chooser);
232 		return gtk_recent_chooser_get_show_not_found(getRecentChooserTStruct());
233 	}
234 	
235 	/**
236 	 * Sets whether chooser should show an icon near the resource when
237 	 * displaying it.
238 	 * Since 2.10
239 	 * Params:
240 	 * showIcons = whether to show an icon near the resource
241 	 */
242 	public void setShowIcons(int showIcons)
243 	{
244 		// void gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,  gboolean show_icons);
245 		gtk_recent_chooser_set_show_icons(getRecentChooserTStruct(), showIcons);
246 	}
247 	
248 	/**
249 	 * Retrieves whether chooser should show an icon near the resource.
250 	 * Since 2.10
251 	 * Returns: TRUE if the icons should be displayed, FALSE otherwise.
252 	 */
253 	public int getShowIcons()
254 	{
255 		// gboolean gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser);
256 		return gtk_recent_chooser_get_show_icons(getRecentChooserTStruct());
257 	}
258 	
259 	/**
260 	 * Sets whether chooser can select multiple items.
261 	 * Since 2.10
262 	 * Params:
263 	 * selectMultiple = TRUE if chooser can select more than one item
264 	 */
265 	public void setSelectMultiple(int selectMultiple)
266 	{
267 		// void gtk_recent_chooser_set_select_multiple  (GtkRecentChooser *chooser,  gboolean select_multiple);
268 		gtk_recent_chooser_set_select_multiple(getRecentChooserTStruct(), selectMultiple);
269 	}
270 	
271 	/**
272 	 * Gets whether chooser can select multiple items.
273 	 * Since 2.10
274 	 * Returns: TRUE if chooser can select more than one item.
275 	 */
276 	public int getSelectMultiple()
277 	{
278 		// gboolean gtk_recent_chooser_get_select_multiple  (GtkRecentChooser *chooser);
279 		return gtk_recent_chooser_get_select_multiple(getRecentChooserTStruct());
280 	}
281 	
282 	/**
283 	 * Sets whether only local resources, that is resources using the file:// URI
284 	 * scheme, should be shown in the recently used resources selector. If
285 	 * local_only is TRUE (the default) then the shown resources are guaranteed
286 	 * to be accessible through the operating system native file system.
287 	 * Since 2.10
288 	 * Params:
289 	 * localOnly = TRUE if only local files can be shown
290 	 */
291 	public void setLocalOnly(int localOnly)
292 	{
293 		// void gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,  gboolean local_only);
294 		gtk_recent_chooser_set_local_only(getRecentChooserTStruct(), localOnly);
295 	}
296 	
297 	/**
298 	 * Gets whether only local resources should be shown in the recently used
299 	 * resources selector. See gtk_recent_chooser_set_local_only()
300 	 * Since 2.10
301 	 * Returns: TRUE if only local resources should be shown.
302 	 */
303 	public int getLocalOnly()
304 	{
305 		// gboolean gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser);
306 		return gtk_recent_chooser_get_local_only(getRecentChooserTStruct());
307 	}
308 	
309 	/**
310 	 * Sets the number of items that should be returned by
311 	 * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
312 	 * Since 2.10
313 	 * Params:
314 	 * limit = a positive integer, or -1 for all items
315 	 */
316 	public void setLimit(int limit)
317 	{
318 		// void gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,  gint limit);
319 		gtk_recent_chooser_set_limit(getRecentChooserTStruct(), limit);
320 	}
321 	
322 	/**
323 	 * Gets the number of items returned by gtk_recent_chooser_get_items()
324 	 * and gtk_recent_chooser_get_uris().
325 	 * Since 2.10
326 	 * Returns: A positive integer, or -1 meaning that all items are returned.
327 	 */
328 	public int getLimit()
329 	{
330 		// gint gtk_recent_chooser_get_limit (GtkRecentChooser *chooser);
331 		return gtk_recent_chooser_get_limit(getRecentChooserTStruct());
332 	}
333 	
334 	/**
335 	 * Sets whether to show a tooltips containing the full path of each
336 	 * recently used resource in a GtkRecentChooser widget.
337 	 * Since 2.10
338 	 * Params:
339 	 * showTips = TRUE if tooltips should be shown
340 	 */
341 	public void setShowTips(int showTips)
342 	{
343 		// void gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,  gboolean show_tips);
344 		gtk_recent_chooser_set_show_tips(getRecentChooserTStruct(), showTips);
345 	}
346 	
347 	/**
348 	 * Gets whether chooser should display tooltips containing the full path
349 	 * of a recently user resource.
350 	 * Since 2.10
351 	 * Returns: TRUE if the recent chooser should show tooltips, FALSE otherwise.
352 	 */
353 	public int getShowTips()
354 	{
355 		// gboolean gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser);
356 		return gtk_recent_chooser_get_show_tips(getRecentChooserTStruct());
357 	}
358 	
359 	/**
360 	 * Changes the sorting order of the recently used resources list displayed by
361 	 * chooser.
362 	 * Since 2.10
363 	 * Params:
364 	 * sortType = sort order that the chooser should use
365 	 */
366 	public void setSortType(GtkRecentSortType sortType)
367 	{
368 		// void gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,  GtkRecentSortType sort_type);
369 		gtk_recent_chooser_set_sort_type(getRecentChooserTStruct(), sortType);
370 	}
371 	
372 	/**
373 	 * Gets the value set by gtk_recent_chooser_set_sort_type().
374 	 * Since 2.10
375 	 * Returns: the sorting order of the chooser.
376 	 */
377 	public GtkRecentSortType getSortType()
378 	{
379 		// GtkRecentSortType gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser);
380 		return gtk_recent_chooser_get_sort_type(getRecentChooserTStruct());
381 	}
382 	
383 	/**
384 	 * Sets the comparison function used when sorting to be sort_func. If
385 	 * the chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then
386 	 * the chooser will sort using this function.
387 	 * To the comparison function will be passed two GtkRecentInfo structs and
388 	 * sort_data; sort_func should return a positive integer if the first
389 	 * item comes before the second, zero if the two items are equal and
390 	 * a negative integer if the first item comes after the second.
391 	 * Since 2.10
392 	 * Params:
393 	 * sortFunc = the comparison function
394 	 * sortData = user data to pass to sort_func, or NULL. [allow-none]
395 	 * dataDestroy = destroy notifier for sort_data, or NULL. [allow-none]
396 	 */
397 	public void setSortFunc(GtkRecentSortFunc sortFunc, void* sortData, GDestroyNotify dataDestroy)
398 	{
399 		// void gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,  GtkRecentSortFunc sort_func,  gpointer sort_data,  GDestroyNotify data_destroy);
400 		gtk_recent_chooser_set_sort_func(getRecentChooserTStruct(), sortFunc, sortData, dataDestroy);
401 	}
402 	
403 	/**
404 	 * Sets uri as the current URI for chooser.
405 	 * Since 2.10
406 	 * Params:
407 	 * uri = a URI
408 	 * Returns: TRUE if the URI was found.
409 	 * Throws: GException on failure.
410 	 */
411 	public int setCurrentUri(string uri)
412 	{
413 		// gboolean gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,  const gchar *uri,  GError **error);
414 		GError* err = null;
415 		
416 		auto p = gtk_recent_chooser_set_current_uri(getRecentChooserTStruct(), Str.toStringz(uri), &err);
417 		
418 		if (err !is null)
419 		{
420 			throw new GException( new ErrorG(err) );
421 		}
422 		
423 		return p;
424 	}
425 	
426 	/**
427 	 * Gets the URI currently selected by chooser.
428 	 * Since 2.10
429 	 * Returns: a newly allocated string holding a URI.
430 	 */
431 	public string getCurrentUri()
432 	{
433 		// gchar * gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser);
434 		return Str.toString(gtk_recent_chooser_get_current_uri(getRecentChooserTStruct()));
435 	}
436 	
437 	/**
438 	 * Gets the GtkRecentInfo currently selected by chooser.
439 	 * Since 2.10
440 	 * Returns: a GtkRecentInfo. Use gtk_recent_info_unref() when when you have finished using it.
441 	 */
442 	public RecentInfo getCurrentItem()
443 	{
444 		// GtkRecentInfo * gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser);
445 		auto p = gtk_recent_chooser_get_current_item(getRecentChooserTStruct());
446 		
447 		if(p is null)
448 		{
449 			return null;
450 		}
451 		
452 		return ObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p);
453 	}
454 	
455 	/**
456 	 * Selects uri inside chooser.
457 	 * Since 2.10
458 	 * Params:
459 	 * uri = a URI
460 	 * Returns: TRUE if uri was found.
461 	 * Throws: GException on failure.
462 	 */
463 	public int selectUri(string uri)
464 	{
465 		// gboolean gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,  const gchar *uri,  GError **error);
466 		GError* err = null;
467 		
468 		auto p = gtk_recent_chooser_select_uri(getRecentChooserTStruct(), Str.toStringz(uri), &err);
469 		
470 		if (err !is null)
471 		{
472 			throw new GException( new ErrorG(err) );
473 		}
474 		
475 		return p;
476 	}
477 	
478 	/**
479 	 * Unselects uri inside chooser.
480 	 * Since 2.10
481 	 * Params:
482 	 * uri = a URI
483 	 */
484 	public void unselectUri(string uri)
485 	{
486 		// void gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,  const gchar *uri);
487 		gtk_recent_chooser_unselect_uri(getRecentChooserTStruct(), Str.toStringz(uri));
488 	}
489 	
490 	/**
491 	 * Selects all the items inside chooser, if the chooser supports
492 	 * multiple selection.
493 	 * Since 2.10
494 	 */
495 	public void selectAll()
496 	{
497 		// void gtk_recent_chooser_select_all (GtkRecentChooser *chooser);
498 		gtk_recent_chooser_select_all(getRecentChooserTStruct());
499 	}
500 	
501 	/**
502 	 * Unselects all the items inside chooser.
503 	 * Since 2.10
504 	 */
505 	public void unselectAll()
506 	{
507 		// void gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser);
508 		gtk_recent_chooser_unselect_all(getRecentChooserTStruct());
509 	}
510 	
511 	/**
512 	 * Gets the list of recently used resources in form of GtkRecentInfo objects.
513 	 * The return value of this function is affected by the "sort-type" and
514 	 * "limit" properties of chooser.
515 	 * Since 2.10
516 	 * Returns: A newly allocated list of GtkRecentInfo objects. You should use gtk_recent_info_unref() on every item of the list, and then free the list itself using g_list_free(). [element-type GtkRecentInfo][transfer full]
517 	 */
518 	public ListG getItems()
519 	{
520 		// GList * gtk_recent_chooser_get_items (GtkRecentChooser *chooser);
521 		auto p = gtk_recent_chooser_get_items(getRecentChooserTStruct());
522 		
523 		if(p is null)
524 		{
525 			return null;
526 		}
527 		
528 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
529 	}
530 	
531 	/**
532 	 * Gets the URI of the recently used resources.
533 	 * The return value of this function is affected by the "sort-type" and "limit"
534 	 * properties of chooser.
535 	 * Since the returned array is NULL terminated, length may be NULL.
536 	 * Since 2.10
537 	 * Returns: A newly allocated, NULL-terminated array of strings. Use g_strfreev() to free it. [array length=length zero-terminated=1][transfer full]
538 	 */
539 	public string[] getUris()
540 	{
541 		// gchar ** gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,  gsize *length);
542 		gsize length;
543 		auto p = gtk_recent_chooser_get_uris(getRecentChooserTStruct(), &length);
544 		
545 		string[] strArray = null;
546 		foreach ( cstr; p[0 .. length] )
547 		{
548 			strArray ~= Str.toString(cstr);
549 		}
550 		
551 		return strArray;
552 	}
553 	
554 	/**
555 	 * Adds filter to the list of GtkRecentFilter objects held by chooser.
556 	 * If no previous filter objects were defined, this function will call
557 	 * gtk_recent_chooser_set_filter().
558 	 * Since 2.10
559 	 * Params:
560 	 * filter = a GtkRecentFilter
561 	 */
562 	public void addFilter(RecentFilter filter)
563 	{
564 		// void gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,  GtkRecentFilter *filter);
565 		gtk_recent_chooser_add_filter(getRecentChooserTStruct(), (filter is null) ? null : filter.getRecentFilterStruct());
566 	}
567 	
568 	/**
569 	 * Removes filter from the list of GtkRecentFilter objects held by chooser.
570 	 * Since 2.10
571 	 * Params:
572 	 * filter = a GtkRecentFilter
573 	 */
574 	public void removeFilter(RecentFilter filter)
575 	{
576 		// void gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,  GtkRecentFilter *filter);
577 		gtk_recent_chooser_remove_filter(getRecentChooserTStruct(), (filter is null) ? null : filter.getRecentFilterStruct());
578 	}
579 	
580 	/**
581 	 * Gets the GtkRecentFilter objects held by chooser.
582 	 * Since 2.10
583 	 * Returns: A singly linked list of GtkRecentFilter objects. You should just free the returned list using g_slist_free(). [element-type GtkRecentFilter][transfer container]
584 	 */
585 	public ListSG listFilters()
586 	{
587 		// GSList * gtk_recent_chooser_list_filters (GtkRecentChooser *chooser);
588 		auto p = gtk_recent_chooser_list_filters(getRecentChooserTStruct());
589 		
590 		if(p is null)
591 		{
592 			return null;
593 		}
594 		
595 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
596 	}
597 	
598 	/**
599 	 * Sets filter as the current GtkRecentFilter object used by chooser
600 	 * to affect the displayed recently used resources.
601 	 * Since 2.10
602 	 * Params:
603 	 * filter = a GtkRecentFilter. [allow-none]
604 	 */
605 	public void setFilter(RecentFilter filter)
606 	{
607 		// void gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,  GtkRecentFilter *filter);
608 		gtk_recent_chooser_set_filter(getRecentChooserTStruct(), (filter is null) ? null : filter.getRecentFilterStruct());
609 	}
610 	
611 	/**
612 	 * Gets the GtkRecentFilter object currently used by chooser to affect
613 	 * the display of the recently used resources.
614 	 * Since 2.10
615 	 * Returns: a GtkRecentFilter object. [transfer none]
616 	 */
617 	public RecentFilter getFilter()
618 	{
619 		// GtkRecentFilter * gtk_recent_chooser_get_filter (GtkRecentChooser *chooser);
620 		auto p = gtk_recent_chooser_get_filter(getRecentChooserTStruct());
621 		
622 		if(p is null)
623 		{
624 			return null;
625 		}
626 		
627 		return ObjectG.getDObject!(RecentFilter)(cast(GtkRecentFilter*) p);
628 	}
629 }