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