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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegtk.RecentChooserT;
26 27 publicimportglib.ErrorG;
28 publicimportglib.GException;
29 publicimportglib.ListG;
30 publicimportglib.ListSG;
31 publicimportglib.Str;
32 publicimportgobject.ObjectG;
33 publicimportgobject.Signals;
34 publicimportgtk.RecentFilter;
35 publicimportgtk.RecentInfo;
36 publicimportgtk.c.functions;
37 publicimportgtk.c.types;
38 publicimportgtkc.gtktypes;
39 publicimportstd.algorithm;
40 41 42 /**
43 * #GtkRecentChooser is an interface that can be implemented by widgets
44 * displaying the list of recently used files. In GTK+, the main objects
45 * that implement this interface are #GtkRecentChooserWidget,
46 * #GtkRecentChooserDialog and #GtkRecentChooserMenu.
47 *
48 * Recently used files are supported since GTK+ 2.10.
49 */50 publictemplateRecentChooserT(TStruct)
51 {
52 /** Get the main Gtk struct */53 publicGtkRecentChooser* getRecentChooserStruct(booltransferOwnership = false)
54 {
55 if (transferOwnership)
56 ownedRef = false;
57 returncast(GtkRecentChooser*)getStruct();
58 }
59 60 61 /**
62 * Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
63 *
64 * If no previous filter objects were defined, this function will call
65 * gtk_recent_chooser_set_filter().
66 *
67 * Params:
68 * filter = a #GtkRecentFilter
69 *
70 * Since: 2.10
71 */72 publicvoidaddFilter(RecentFilterfilter)
73 {
74 gtk_recent_chooser_add_filter(getRecentChooserStruct(), (filterisnull) ? null : filter.getRecentFilterStruct());
75 }
76 77 /**
78 * Gets the #GtkRecentInfo currently selected by @chooser.
79 *
80 * Returns: a #GtkRecentInfo. Use gtk_recent_info_unref() when
81 * when you have finished using it.
82 *
83 * Since: 2.10
84 */85 publicRecentInfogetCurrentItem()
86 {
87 autop = gtk_recent_chooser_get_current_item(getRecentChooserStruct());
88 89 if(pisnull)
90 {
91 returnnull;
92 }
93 94 returnObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p, true);
95 }
96 97 /**
98 * Gets the URI currently selected by @chooser.
99 *
100 * Returns: a newly allocated string holding a URI.
101 *
102 * Since: 2.10
103 */104 publicstringgetCurrentUri()
105 {
106 autoretStr = gtk_recent_chooser_get_current_uri(getRecentChooserStruct());
107 108 scope(exit) Str.freeString(retStr);
109 returnStr.toString(retStr);
110 }
111 112 /**
113 * Gets the #GtkRecentFilter object currently used by @chooser to affect
114 * the display of the recently used resources.
115 *
116 * Returns: a #GtkRecentFilter object.
117 *
118 * Since: 2.10
119 */120 publicRecentFiltergetFilter()
121 {
122 autop = gtk_recent_chooser_get_filter(getRecentChooserStruct());
123 124 if(pisnull)
125 {
126 returnnull;
127 }
128 129 returnObjectG.getDObject!(RecentFilter)(cast(GtkRecentFilter*) p);
130 }
131 132 /**
133 * Gets the list of recently used resources in form of #GtkRecentInfo objects.
134 *
135 * The return value of this function is affected by the “sort-type” and
136 * “limit” properties of @chooser.
137 *
138 * Returns: A newly allocated
139 * list of #GtkRecentInfo objects. You should
140 * use gtk_recent_info_unref() on every item of the list, and then free
141 * the list itself using g_list_free().
142 *
143 * Since: 2.10
144 */145 publicListGgetItems()
146 {
147 autop = gtk_recent_chooser_get_items(getRecentChooserStruct());
148 149 if(pisnull)
150 {
151 returnnull;
152 }
153 154 returnnewListG(cast(GList*) p, true);
155 }
156 157 /**
158 * Gets the number of items returned by gtk_recent_chooser_get_items()
159 * and gtk_recent_chooser_get_uris().
160 *
161 * Returns: A positive integer, or -1 meaning that all items are
162 * returned.
163 *
164 * Since: 2.10
165 */166 publicintgetLimit()
167 {
168 returngtk_recent_chooser_get_limit(getRecentChooserStruct());
169 }
170 171 /**
172 * Gets whether only local resources should be shown in the recently used
173 * resources selector. See gtk_recent_chooser_set_local_only()
174 *
175 * Returns: %TRUE if only local resources should be shown.
176 *
177 * Since: 2.10
178 */179 publicboolgetLocalOnly()
180 {
181 returngtk_recent_chooser_get_local_only(getRecentChooserStruct()) != 0;
182 }
183 184 /**
185 * Gets whether @chooser can select multiple items.
186 *
187 * Returns: %TRUE if @chooser can select more than one item.
188 *
189 * Since: 2.10
190 */191 publicboolgetSelectMultiple()
192 {
193 returngtk_recent_chooser_get_select_multiple(getRecentChooserStruct()) != 0;
194 }
195 196 /**
197 * Retrieves whether @chooser should show an icon near the resource.
198 *
199 * Returns: %TRUE if the icons should be displayed, %FALSE otherwise.
200 *
201 * Since: 2.10
202 */203 publicboolgetShowIcons()
204 {
205 returngtk_recent_chooser_get_show_icons(getRecentChooserStruct()) != 0;
206 }
207 208 /**
209 * Retrieves whether @chooser should show the recently used resources that
210 * were not found.
211 *
212 * Returns: %TRUE if the resources not found should be displayed, and
213 * %FALSE otheriwse.
214 *
215 * Since: 2.10
216 */217 publicboolgetShowNotFound()
218 {
219 returngtk_recent_chooser_get_show_not_found(getRecentChooserStruct()) != 0;
220 }
221 222 /**
223 * Returns whether @chooser should display recently used resources
224 * registered as private.
225 *
226 * Returns: %TRUE if the recent chooser should show private items,
227 * %FALSE otherwise.
228 *
229 * Since: 2.10
230 */231 publicboolgetShowPrivate()
232 {
233 returngtk_recent_chooser_get_show_private(getRecentChooserStruct()) != 0;
234 }
235 236 /**
237 * Gets whether @chooser should display tooltips containing the full path
238 * of a recently user resource.
239 *
240 * Returns: %TRUE if the recent chooser should show tooltips,
241 * %FALSE otherwise.
242 *
243 * Since: 2.10
244 */245 publicboolgetShowTips()
246 {
247 returngtk_recent_chooser_get_show_tips(getRecentChooserStruct()) != 0;
248 }
249 250 /**
251 * Gets the value set by gtk_recent_chooser_set_sort_type().
252 *
253 * Returns: the sorting order of the @chooser.
254 *
255 * Since: 2.10
256 */257 publicGtkRecentSortTypegetSortType()
258 {
259 returngtk_recent_chooser_get_sort_type(getRecentChooserStruct());
260 }
261 262 /**
263 * Gets the URI of the recently used resources.
264 *
265 * The return value of this function is affected by the “sort-type” and “limit”
266 * properties of @chooser.
267 *
268 * Since the returned array is %NULL terminated, @length may be %NULL.
269 *
270 * Returns: A newly allocated, %NULL-terminated array of strings. Use
271 * g_strfreev() to free it.
272 *
273 * Since: 2.10
274 */275 publicstring[] getUris()
276 {
277 size_tlength;
278 279 autoretStr = gtk_recent_chooser_get_uris(getRecentChooserStruct(), &length);
280 281 scope(exit) Str.freeStringArray(retStr);
282 returnStr.toStringArray(retStr, length);
283 }
284 285 /**
286 * Gets the #GtkRecentFilter objects held by @chooser.
287 *
288 * Returns: A singly linked list
289 * of #GtkRecentFilter objects. You
290 * should just free the returned list using g_slist_free().
291 *
292 * Since: 2.10
293 */294 publicListSGlistFilters()
295 {
296 autop = gtk_recent_chooser_list_filters(getRecentChooserStruct());
297 298 if(pisnull)
299 {
300 returnnull;
301 }
302 303 returnnewListSG(cast(GSList*) p);
304 }
305 306 /**
307 * Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
308 *
309 * Params:
310 * filter = a #GtkRecentFilter
311 *
312 * Since: 2.10
313 */314 publicvoidremoveFilter(RecentFilterfilter)
315 {
316 gtk_recent_chooser_remove_filter(getRecentChooserStruct(), (filterisnull) ? null : filter.getRecentFilterStruct());
317 }
318 319 /**
320 * Selects all the items inside @chooser, if the @chooser supports
321 * multiple selection.
322 *
323 * Since: 2.10
324 */325 publicvoidselectAll()
326 {
327 gtk_recent_chooser_select_all(getRecentChooserStruct());
328 }
329 330 /**
331 * Selects @uri inside @chooser.
332 *
333 * Params:
334 * uri = a URI
335 *
336 * Returns: %TRUE if @uri was found.
337 *
338 * Since: 2.10
339 *
340 * Throws: GException on failure.
341 */342 publicboolselectUri(stringuri)
343 {
344 GError* err = null;
345 346 autop = gtk_recent_chooser_select_uri(getRecentChooserStruct(), Str.toStringz(uri), &err) != 0;
347 348 if (err !isnull)
349 {
350 thrownewGException( newErrorG(err) );
351 }
352 353 returnp;
354 }
355 356 /**
357 * Sets @uri as the current URI for @chooser.
358 *
359 * Params:
360 * uri = a URI
361 *
362 * Returns: %TRUE if the URI was found.
363 *
364 * Since: 2.10
365 *
366 * Throws: GException on failure.
367 */368 publicboolsetCurrentUri(stringuri)
369 {
370 GError* err = null;
371 372 autop = gtk_recent_chooser_set_current_uri(getRecentChooserStruct(), Str.toStringz(uri), &err) != 0;
373 374 if (err !isnull)
375 {
376 thrownewGException( newErrorG(err) );
377 }
378 379 returnp;
380 }
381 382 /**
383 * Sets @filter as the current #GtkRecentFilter object used by @chooser
384 * to affect the displayed recently used resources.
385 *
386 * Params:
387 * filter = a #GtkRecentFilter
388 *
389 * Since: 2.10
390 */391 publicvoidsetFilter(RecentFilterfilter)
392 {
393 gtk_recent_chooser_set_filter(getRecentChooserStruct(), (filterisnull) ? null : filter.getRecentFilterStruct());
394 }
395 396 /**
397 * Sets the number of items that should be returned by
398 * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
399 *
400 * Params:
401 * limit = a positive integer, or -1 for all items
402 *
403 * Since: 2.10
404 */405 publicvoidsetLimit(intlimit)
406 {
407 gtk_recent_chooser_set_limit(getRecentChooserStruct(), limit);
408 }
409 410 /**
411 * Sets whether only local resources, that is resources using the file:// URI
412 * scheme, should be shown in the recently used resources selector. If
413 * @local_only is %TRUE (the default) then the shown resources are guaranteed
414 * to be accessible through the operating system native file system.
415 *
416 * Params:
417 * localOnly = %TRUE if only local files can be shown
418 *
419 * Since: 2.10
420 */421 publicvoidsetLocalOnly(boollocalOnly)
422 {
423 gtk_recent_chooser_set_local_only(getRecentChooserStruct(), localOnly);
424 }
425 426 /**
427 * Sets whether @chooser can select multiple items.
428 *
429 * Params:
430 * selectMultiple = %TRUE if @chooser can select more than one item
431 *
432 * Since: 2.10
433 */434 publicvoidsetSelectMultiple(boolselectMultiple)
435 {
436 gtk_recent_chooser_set_select_multiple(getRecentChooserStruct(), selectMultiple);
437 }
438 439 /**
440 * Sets whether @chooser should show an icon near the resource when
441 * displaying it.
442 *
443 * Params:
444 * showIcons = whether to show an icon near the resource
445 *
446 * Since: 2.10
447 */448 publicvoidsetShowIcons(boolshowIcons)
449 {
450 gtk_recent_chooser_set_show_icons(getRecentChooserStruct(), showIcons);
451 }
452 453 /**
454 * Sets whether @chooser should display the recently used resources that
455 * it didn’t find. This only applies to local resources.
456 *
457 * Params:
458 * showNotFound = whether to show the local items we didn’t find
459 *
460 * Since: 2.10
461 */462 publicvoidsetShowNotFound(boolshowNotFound)
463 {
464 gtk_recent_chooser_set_show_not_found(getRecentChooserStruct(), showNotFound);
465 }
466 467 /**
468 * Whether to show recently used resources marked registered as private.
469 *
470 * Params:
471 * showPrivate = %TRUE to show private items, %FALSE otherwise
472 *
473 * Since: 2.10
474 */475 publicvoidsetShowPrivate(boolshowPrivate)
476 {
477 gtk_recent_chooser_set_show_private(getRecentChooserStruct(), showPrivate);
478 }
479 480 /**
481 * Sets whether to show a tooltips containing the full path of each
482 * recently used resource in a #GtkRecentChooser widget.
483 *
484 * Params:
485 * showTips = %TRUE if tooltips should be shown
486 *
487 * Since: 2.10
488 */489 publicvoidsetShowTips(boolshowTips)
490 {
491 gtk_recent_chooser_set_show_tips(getRecentChooserStruct(), showTips);
492 }
493 494 /**
495 * Sets the comparison function used when sorting to be @sort_func. If
496 * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
497 * the chooser will sort using this function.
498 *
499 * To the comparison function will be passed two #GtkRecentInfo structs and
500 * @sort_data; @sort_func should return a positive integer if the first
501 * item comes before the second, zero if the two items are equal and
502 * a negative integer if the first item comes after the second.
503 *
504 * Params:
505 * sortFunc = the comparison function
506 * sortData = user data to pass to @sort_func, or %NULL
507 * dataDestroy = destroy notifier for @sort_data, or %NULL
508 *
509 * Since: 2.10
510 */511 publicvoidsetSortFunc(GtkRecentSortFuncsortFunc, void* sortData, GDestroyNotifydataDestroy)
512 {
513 gtk_recent_chooser_set_sort_func(getRecentChooserStruct(), sortFunc, sortData, dataDestroy);
514 }
515 516 /**
517 * Changes the sorting order of the recently used resources list displayed by
518 * @chooser.
519 *
520 * Params:
521 * sortType = sort order that the chooser should use
522 *
523 * Since: 2.10
524 */525 publicvoidsetSortType(GtkRecentSortTypesortType)
526 {
527 gtk_recent_chooser_set_sort_type(getRecentChooserStruct(), sortType);
528 }
529 530 /**
531 * Unselects all the items inside @chooser.
532 *
533 * Since: 2.10
534 */535 publicvoidunselectAll()
536 {
537 gtk_recent_chooser_unselect_all(getRecentChooserStruct());
538 }
539 540 /**
541 * Unselects @uri inside @chooser.
542 *
543 * Params:
544 * uri = a URI
545 *
546 * Since: 2.10
547 */548 publicvoidunselectUri(stringuri)
549 {
550 gtk_recent_chooser_unselect_uri(getRecentChooserStruct(), Str.toStringz(uri));
551 }
552 553 /**
554 * This signal is emitted when the user "activates" a recent item
555 * in the recent chooser. This can happen by double-clicking on an item
556 * in the recently used resources list, or by pressing
557 * `Enter`.
558 *
559 * Since: 2.10
560 */561 gulongaddOnItemActivated(voiddelegate(RecentChooserIF) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
562 {
563 returnSignals.connect(this, "item-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED);
564 }
565 566 /**
567 * This signal is emitted when there is a change in the set of
568 * selected recently used resources. This can happen when a user
569 * modifies the selection with the mouse or the keyboard, or when
570 * explicitly calling functions to change the selection.
571 *
572 * Since: 2.10
573 */574 gulongaddOnSelectionChanged(voiddelegate(RecentChooserIF) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
575 {
576 returnSignals.connect(this, "selection-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
577 }
578 }