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 * Adds @filter to the list of #GtkRecentFilter objects held by @chooser. 60 * 61 * If no previous filter objects were defined, this function will call 62 * gtk_recent_chooser_set_filter(). 63 * 64 * Params: 65 * filter = a #GtkRecentFilter 66 * 67 * Since: 2.10 68 */ 69 public void addFilter(RecentFilter filter) 70 { 71 gtk_recent_chooser_add_filter(getRecentChooserStruct(), (filter is null) ? null : filter.getRecentFilterStruct()); 72 } 73 74 /** 75 * Gets the #GtkRecentInfo currently selected by @chooser. 76 * 77 * Return: a #GtkRecentInfo. Use gtk_recent_info_unref() when 78 * when you have finished using it. 79 * 80 * Since: 2.10 81 */ 82 public RecentInfo getCurrentItem() 83 { 84 auto p = gtk_recent_chooser_get_current_item(getRecentChooserStruct()); 85 86 if(p is null) 87 { 88 return null; 89 } 90 91 return ObjectG.getDObject!(RecentInfo)(cast(GtkRecentInfo*) p, true); 92 } 93 94 /** 95 * Gets the URI currently selected by @chooser. 96 * 97 * Return: a newly allocated string holding a URI. 98 * 99 * Since: 2.10 100 */ 101 public string getCurrentUri() 102 { 103 auto retStr = gtk_recent_chooser_get_current_uri(getRecentChooserStruct()); 104 105 scope(exit) Str.freeString(retStr); 106 return Str.toString(retStr); 107 } 108 109 /** 110 * Gets the #GtkRecentFilter object currently used by @chooser to affect 111 * the display of the recently used resources. 112 * 113 * Return: a #GtkRecentFilter object. 114 * 115 * Since: 2.10 116 */ 117 public RecentFilter getFilter() 118 { 119 auto p = gtk_recent_chooser_get_filter(getRecentChooserStruct()); 120 121 if(p is null) 122 { 123 return null; 124 } 125 126 return ObjectG.getDObject!(RecentFilter)(cast(GtkRecentFilter*) p); 127 } 128 129 /** 130 * Gets the list of recently used resources in form of #GtkRecentInfo objects. 131 * 132 * The return value of this function is affected by the “sort-type” and 133 * “limit” properties of @chooser. 134 * 135 * Return: A newly allocated 136 * list of #GtkRecentInfo objects. You should 137 * use gtk_recent_info_unref() on every item of the list, and then free 138 * the list itself using g_list_free(). 139 * 140 * Since: 2.10 141 */ 142 public ListG getItems() 143 { 144 auto p = gtk_recent_chooser_get_items(getRecentChooserStruct()); 145 146 if(p is null) 147 { 148 return null; 149 } 150 151 return new ListG(cast(GList*) p, true); 152 } 153 154 /** 155 * Gets the number of items returned by gtk_recent_chooser_get_items() 156 * and gtk_recent_chooser_get_uris(). 157 * 158 * Return: A positive integer, or -1 meaning that all items are 159 * returned. 160 * 161 * Since: 2.10 162 */ 163 public int getLimit() 164 { 165 return gtk_recent_chooser_get_limit(getRecentChooserStruct()); 166 } 167 168 /** 169 * Gets whether only local resources should be shown in the recently used 170 * resources selector. See gtk_recent_chooser_set_local_only() 171 * 172 * Return: %TRUE if only local resources should be shown. 173 * 174 * Since: 2.10 175 */ 176 public bool getLocalOnly() 177 { 178 return gtk_recent_chooser_get_local_only(getRecentChooserStruct()) != 0; 179 } 180 181 /** 182 * Gets whether @chooser can select multiple items. 183 * 184 * Return: %TRUE if @chooser can select more than one item. 185 * 186 * Since: 2.10 187 */ 188 public bool getSelectMultiple() 189 { 190 return gtk_recent_chooser_get_select_multiple(getRecentChooserStruct()) != 0; 191 } 192 193 /** 194 * Retrieves whether @chooser should show an icon near the resource. 195 * 196 * Return: %TRUE if the icons should be displayed, %FALSE otherwise. 197 * 198 * Since: 2.10 199 */ 200 public bool getShowIcons() 201 { 202 return gtk_recent_chooser_get_show_icons(getRecentChooserStruct()) != 0; 203 } 204 205 /** 206 * Retrieves whether @chooser should show the recently used resources that 207 * were not found. 208 * 209 * Return: %TRUE if the resources not found should be displayed, and 210 * %FALSE otheriwse. 211 * 212 * Since: 2.10 213 */ 214 public bool getShowNotFound() 215 { 216 return gtk_recent_chooser_get_show_not_found(getRecentChooserStruct()) != 0; 217 } 218 219 /** 220 * Returns whether @chooser should display recently used resources 221 * registered as private. 222 * 223 * Return: %TRUE if the recent chooser should show private items, 224 * %FALSE otherwise. 225 * 226 * Since: 2.10 227 */ 228 public bool getShowPrivate() 229 { 230 return gtk_recent_chooser_get_show_private(getRecentChooserStruct()) != 0; 231 } 232 233 /** 234 * Gets whether @chooser should display tooltips containing the full path 235 * of a recently user resource. 236 * 237 * Return: %TRUE if the recent chooser should show tooltips, 238 * %FALSE otherwise. 239 * 240 * Since: 2.10 241 */ 242 public bool getShowTips() 243 { 244 return gtk_recent_chooser_get_show_tips(getRecentChooserStruct()) != 0; 245 } 246 247 /** 248 * Gets the value set by gtk_recent_chooser_set_sort_type(). 249 * 250 * Return: the sorting order of the @chooser. 251 * 252 * Since: 2.10 253 */ 254 public GtkRecentSortType getSortType() 255 { 256 return gtk_recent_chooser_get_sort_type(getRecentChooserStruct()); 257 } 258 259 /** 260 * Gets the URI of the recently used resources. 261 * 262 * The return value of this function is affected by the “sort-type” and “limit” 263 * properties of @chooser. 264 * 265 * Since the returned array is %NULL terminated, @length may be %NULL. 266 * 267 * Return: A newly allocated, %NULL-terminated array of strings. Use 268 * g_strfreev() to free it. 269 * 270 * Since: 2.10 271 */ 272 public string[] getUris() 273 { 274 size_t length; 275 276 auto retStr = gtk_recent_chooser_get_uris(getRecentChooserStruct(), &length); 277 278 scope(exit) Str.freeStringArray(retStr); 279 return Str.toStringArray(retStr, 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 }