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