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