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