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.IconView; 26 27 private import cairo.Surface; 28 private import glib.ConstructionException; 29 private import glib.ListG; 30 private import glib.MemorySlice; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.CellArea; 34 private import gtk.CellLayoutIF; 35 private import gtk.CellLayoutT; 36 private import gtk.CellRenderer; 37 private import gtk.Container; 38 private import gtk.ScrollableIF; 39 private import gtk.ScrollableT; 40 private import gtk.TargetEntry; 41 private import gtk.Tooltip; 42 private import gtk.TreeIter; 43 private import gtk.TreeModelIF; 44 private import gtk.TreePath; 45 private import gtk.Widget; 46 private import gtk.c.functions; 47 public import gtk.c.types; 48 public import gtkc.gtktypes; 49 private import std.algorithm; 50 51 52 /** 53 * #GtkIconView provides an alternative view on a #GtkTreeModel. 54 * It displays the model as a grid of icons with labels. Like 55 * #GtkTreeView, it allows to select one or multiple items 56 * (depending on the selection mode, see gtk_icon_view_set_selection_mode()). 57 * In addition to selection with the arrow keys, #GtkIconView supports 58 * rubberband selection, which is controlled by dragging the pointer. 59 * 60 * Note that if the tree model is backed by an actual tree store (as 61 * opposed to a flat list where the mapping to icons is obvious), 62 * #GtkIconView will only display the first level of the tree and 63 * ignore the tree’s branches. 64 * 65 * # CSS nodes 66 * 67 * |[<!-- language="plain" --> 68 * iconview.view 69 * ╰── [rubberband] 70 * ]| 71 * 72 * GtkIconView has a single CSS node with name iconview and style class .view. 73 * For rubberband selection, a subnode with name rubberband is used. 74 */ 75 public class IconView : Container, CellLayoutIF, ScrollableIF 76 { 77 /** the main Gtk struct */ 78 protected GtkIconView* gtkIconView; 79 80 /** Get the main Gtk struct */ 81 public GtkIconView* getIconViewStruct(bool transferOwnership = false) 82 { 83 if (transferOwnership) 84 ownedRef = false; 85 return gtkIconView; 86 } 87 88 /** the main Gtk struct as a void* */ 89 protected override void* getStruct() 90 { 91 return cast(void*)gtkIconView; 92 } 93 94 protected override void setStruct(GObject* obj) 95 { 96 gtkIconView = cast(GtkIconView*)obj; 97 super.setStruct(obj); 98 } 99 100 /** 101 * Sets our main struct and passes it to the parent class. 102 */ 103 public this (GtkIconView* gtkIconView, bool ownedRef = false) 104 { 105 this.gtkIconView = gtkIconView; 106 super(cast(GtkContainer*)gtkIconView, ownedRef); 107 } 108 109 // add the CellLayout capabilities 110 mixin CellLayoutT!(GtkIconView); 111 112 // add the Scrollable capabilities 113 mixin ScrollableT!(GtkIconView); 114 115 116 /** */ 117 public static GType getType() 118 { 119 return gtk_icon_view_get_type(); 120 } 121 122 /** 123 * Creates a new #GtkIconView widget 124 * 125 * Returns: A newly created #GtkIconView widget 126 * 127 * Since: 2.6 128 * 129 * Throws: ConstructionException GTK+ fails to create the object. 130 */ 131 public this() 132 { 133 auto p = gtk_icon_view_new(); 134 135 if(p is null) 136 { 137 throw new ConstructionException("null returned by new"); 138 } 139 140 this(cast(GtkIconView*) p); 141 } 142 143 /** 144 * Creates a new #GtkIconView widget using the 145 * specified @area to layout cells inside the icons. 146 * 147 * Params: 148 * area = the #GtkCellArea to use to layout cells 149 * 150 * Returns: A newly created #GtkIconView widget 151 * 152 * Since: 3.0 153 * 154 * Throws: ConstructionException GTK+ fails to create the object. 155 */ 156 public this(CellArea area) 157 { 158 auto p = gtk_icon_view_new_with_area((area is null) ? null : area.getCellAreaStruct()); 159 160 if(p is null) 161 { 162 throw new ConstructionException("null returned by new_with_area"); 163 } 164 165 this(cast(GtkIconView*) p); 166 } 167 168 /** 169 * Creates a new #GtkIconView widget with the model @model. 170 * 171 * Params: 172 * model = The model. 173 * 174 * Returns: A newly created #GtkIconView widget. 175 * 176 * Since: 2.6 177 * 178 * Throws: ConstructionException GTK+ fails to create the object. 179 */ 180 public this(TreeModelIF model) 181 { 182 auto p = gtk_icon_view_new_with_model((model is null) ? null : model.getTreeModelStruct()); 183 184 if(p is null) 185 { 186 throw new ConstructionException("null returned by new_with_model"); 187 } 188 189 this(cast(GtkIconView*) p); 190 } 191 192 /** 193 * Converts widget coordinates to coordinates for the bin_window, 194 * as expected by e.g. gtk_icon_view_get_path_at_pos(). 195 * 196 * Params: 197 * wx = X coordinate relative to the widget 198 * wy = Y coordinate relative to the widget 199 * bx = return location for bin_window X coordinate 200 * by = return location for bin_window Y coordinate 201 * 202 * Since: 2.12 203 */ 204 public void convertWidgetToBinWindowCoords(int wx, int wy, out int bx, out int by) 205 { 206 gtk_icon_view_convert_widget_to_bin_window_coords(gtkIconView, wx, wy, &bx, &by); 207 } 208 209 /** 210 * Creates a #cairo_surface_t representation of the item at @path. 211 * This image is used for a drag icon. 212 * 213 * Params: 214 * path = a #GtkTreePath in @icon_view 215 * 216 * Returns: a newly-allocated surface of the drag icon. 217 * 218 * Since: 2.8 219 */ 220 public Surface createDragIcon(TreePath path) 221 { 222 auto p = gtk_icon_view_create_drag_icon(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return new Surface(cast(cairo_surface_t*) p); 230 } 231 232 /** 233 * Turns @icon_view into a drop destination for automatic DND. Calling this 234 * method sets #GtkIconView:reorderable to %FALSE. 235 * 236 * Params: 237 * targets = the table of targets that the drag will 238 * support 239 * actions = the bitmask of possible actions for a drag to this 240 * widget 241 * 242 * Since: 2.8 243 */ 244 public void enableModelDragDest(TargetEntry[] targets, GdkDragAction actions) 245 { 246 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 247 for ( int i = 0; i < targets.length; i++ ) 248 { 249 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 250 } 251 252 gtk_icon_view_enable_model_drag_dest(gtkIconView, targetsArray.ptr, cast(int)targets.length, actions); 253 } 254 255 /** 256 * Turns @icon_view into a drag source for automatic DND. Calling this 257 * method sets #GtkIconView:reorderable to %FALSE. 258 * 259 * Params: 260 * startButtonMask = Mask of allowed buttons to start drag 261 * targets = the table of targets that the drag will 262 * support 263 * actions = the bitmask of possible actions for a drag from this 264 * widget 265 * 266 * Since: 2.8 267 */ 268 public void enableModelDragSource(GdkModifierType startButtonMask, TargetEntry[] targets, GdkDragAction actions) 269 { 270 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 271 for ( int i = 0; i < targets.length; i++ ) 272 { 273 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 274 } 275 276 gtk_icon_view_enable_model_drag_source(gtkIconView, startButtonMask, targetsArray.ptr, cast(int)targets.length, actions); 277 } 278 279 /** 280 * Gets the setting set by gtk_icon_view_set_activate_on_single_click(). 281 * 282 * Returns: %TRUE if item-activated will be emitted on a single click 283 * 284 * Since: 3.8 285 */ 286 public bool getActivateOnSingleClick() 287 { 288 return gtk_icon_view_get_activate_on_single_click(gtkIconView) != 0; 289 } 290 291 /** 292 * Fills the bounding rectangle in widget coordinates for the cell specified by 293 * @path and @cell. If @cell is %NULL the main cell area is used. 294 * 295 * This function is only valid if @icon_view is realized. 296 * 297 * Params: 298 * path = a #GtkTreePath 299 * cell = a #GtkCellRenderer or %NULL 300 * rect = rectangle to fill with cell rect 301 * 302 * Returns: %FALSE if there is no such item, %TRUE otherwise 303 * 304 * Since: 3.6 305 */ 306 public bool getCellRect(TreePath path, CellRenderer cell, out GdkRectangle rect) 307 { 308 return gtk_icon_view_get_cell_rect(gtkIconView, (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct(), &rect) != 0; 309 } 310 311 /** 312 * Returns the value of the ::column-spacing property. 313 * 314 * Returns: the space between columns 315 * 316 * Since: 2.6 317 */ 318 public int getColumnSpacing() 319 { 320 return gtk_icon_view_get_column_spacing(gtkIconView); 321 } 322 323 /** 324 * Returns the value of the ::columns property. 325 * 326 * Returns: the number of columns, or -1 327 * 328 * Since: 2.6 329 */ 330 public int getColumns() 331 { 332 return gtk_icon_view_get_columns(gtkIconView); 333 } 334 335 /** 336 * Fills in @path and @cell with the current cursor path and cell. 337 * If the cursor isn’t currently set, then *@path will be %NULL. 338 * If no cell currently has focus, then *@cell will be %NULL. 339 * 340 * The returned #GtkTreePath must be freed with gtk_tree_path_free(). 341 * 342 * Params: 343 * path = Return location for the current 344 * cursor path, or %NULL 345 * cell = Return location the current 346 * focus cell, or %NULL 347 * 348 * Returns: %TRUE if the cursor is set. 349 * 350 * Since: 2.8 351 */ 352 public bool getCursor(out TreePath path, out CellRenderer cell) 353 { 354 GtkTreePath* outpath = null; 355 GtkCellRenderer* outcell = null; 356 357 auto p = gtk_icon_view_get_cursor(gtkIconView, &outpath, &outcell) != 0; 358 359 path = ObjectG.getDObject!(TreePath)(outpath); 360 cell = ObjectG.getDObject!(CellRenderer)(outcell); 361 362 return p; 363 } 364 365 /** 366 * Determines the destination item for a given position. 367 * 368 * Params: 369 * dragX = the position to determine the destination item for 370 * dragY = the position to determine the destination item for 371 * path = Return location for the path of the item, 372 * or %NULL. 373 * pos = Return location for the drop position, or %NULL 374 * 375 * Returns: whether there is an item at the given position. 376 * 377 * Since: 2.8 378 */ 379 public bool getDestItemAtPos(int dragX, int dragY, out TreePath path, out GtkIconViewDropPosition pos) 380 { 381 GtkTreePath* outpath = null; 382 383 auto p = gtk_icon_view_get_dest_item_at_pos(gtkIconView, dragX, dragY, &outpath, &pos) != 0; 384 385 path = ObjectG.getDObject!(TreePath)(outpath); 386 387 return p; 388 } 389 390 /** 391 * Gets information about the item that is highlighted for feedback. 392 * 393 * Params: 394 * path = Return location for the path of 395 * the highlighted item, or %NULL. 396 * pos = Return location for the drop position, or %NULL 397 * 398 * Since: 2.8 399 */ 400 public void getDragDestItem(out TreePath path, out GtkIconViewDropPosition pos) 401 { 402 GtkTreePath* outpath = null; 403 404 gtk_icon_view_get_drag_dest_item(gtkIconView, &outpath, &pos); 405 406 path = ObjectG.getDObject!(TreePath)(outpath); 407 } 408 409 /** 410 * Finds the path at the point (@x, @y), relative to bin_window coordinates. 411 * In contrast to gtk_icon_view_get_path_at_pos(), this function also 412 * obtains the cell at the specified position. The returned path should 413 * be freed with gtk_tree_path_free(). 414 * See gtk_icon_view_convert_widget_to_bin_window_coords() for converting 415 * widget coordinates to bin_window coordinates. 416 * 417 * Params: 418 * x = The x position to be identified 419 * y = The y position to be identified 420 * path = Return location for the path, or %NULL 421 * cell = Return location for the renderer 422 * responsible for the cell at (@x, @y), or %NULL 423 * 424 * Returns: %TRUE if an item exists at the specified position 425 * 426 * Since: 2.8 427 */ 428 public bool getItemAtPos(int x, int y, out TreePath path, out CellRenderer cell) 429 { 430 GtkTreePath* outpath = null; 431 GtkCellRenderer* outcell = null; 432 433 auto p = gtk_icon_view_get_item_at_pos(gtkIconView, x, y, &outpath, &outcell) != 0; 434 435 path = ObjectG.getDObject!(TreePath)(outpath); 436 cell = ObjectG.getDObject!(CellRenderer)(outcell); 437 438 return p; 439 } 440 441 /** 442 * Gets the column in which the item @path is currently 443 * displayed. Column numbers start at 0. 444 * 445 * Params: 446 * path = the #GtkTreePath of the item 447 * 448 * Returns: The column in which the item is displayed 449 * 450 * Since: 2.22 451 */ 452 public int getItemColumn(TreePath path) 453 { 454 return gtk_icon_view_get_item_column(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 455 } 456 457 /** 458 * Returns the value of the ::item-orientation property which determines 459 * whether the labels are drawn beside the icons instead of below. 460 * 461 * Returns: the relative position of texts and icons 462 * 463 * Since: 2.6 464 */ 465 public GtkOrientation getItemOrientation() 466 { 467 return gtk_icon_view_get_item_orientation(gtkIconView); 468 } 469 470 /** 471 * Returns the value of the ::item-padding property. 472 * 473 * Returns: the padding around items 474 * 475 * Since: 2.18 476 */ 477 public int getItemPadding() 478 { 479 return gtk_icon_view_get_item_padding(gtkIconView); 480 } 481 482 /** 483 * Gets the row in which the item @path is currently 484 * displayed. Row numbers start at 0. 485 * 486 * Params: 487 * path = the #GtkTreePath of the item 488 * 489 * Returns: The row in which the item is displayed 490 * 491 * Since: 2.22 492 */ 493 public int getItemRow(TreePath path) 494 { 495 return gtk_icon_view_get_item_row(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 496 } 497 498 /** 499 * Returns the value of the ::item-width property. 500 * 501 * Returns: the width of a single item, or -1 502 * 503 * Since: 2.6 504 */ 505 public int getItemWidth() 506 { 507 return gtk_icon_view_get_item_width(gtkIconView); 508 } 509 510 /** 511 * Returns the value of the ::margin property. 512 * 513 * Returns: the space at the borders 514 * 515 * Since: 2.6 516 */ 517 public int getMargin() 518 { 519 return gtk_icon_view_get_margin(gtkIconView); 520 } 521 522 /** 523 * Returns the column with markup text for @icon_view. 524 * 525 * Returns: the markup column, or -1 if it’s unset. 526 * 527 * Since: 2.6 528 */ 529 public int getMarkupColumn() 530 { 531 return gtk_icon_view_get_markup_column(gtkIconView); 532 } 533 534 /** 535 * Returns the model the #GtkIconView is based on. Returns %NULL if the 536 * model is unset. 537 * 538 * Returns: A #GtkTreeModel, or %NULL if none is 539 * currently being used. 540 * 541 * Since: 2.6 542 */ 543 public TreeModelIF getModel() 544 { 545 auto p = gtk_icon_view_get_model(gtkIconView); 546 547 if(p is null) 548 { 549 return null; 550 } 551 552 return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) p); 553 } 554 555 /** 556 * Finds the path at the point (@x, @y), relative to bin_window coordinates. 557 * See gtk_icon_view_get_item_at_pos(), if you are also interested in 558 * the cell at the specified position. 559 * See gtk_icon_view_convert_widget_to_bin_window_coords() for converting 560 * widget coordinates to bin_window coordinates. 561 * 562 * Params: 563 * x = The x position to be identified 564 * y = The y position to be identified 565 * 566 * Returns: The #GtkTreePath corresponding 567 * to the icon or %NULL if no icon exists at that position. 568 * 569 * Since: 2.6 570 */ 571 public TreePath getPathAtPos(int x, int y) 572 { 573 auto p = gtk_icon_view_get_path_at_pos(gtkIconView, x, y); 574 575 if(p is null) 576 { 577 return null; 578 } 579 580 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p, true); 581 } 582 583 /** 584 * Returns the column with pixbufs for @icon_view. 585 * 586 * Returns: the pixbuf column, or -1 if it’s unset. 587 * 588 * Since: 2.6 589 */ 590 public int getPixbufColumn() 591 { 592 return gtk_icon_view_get_pixbuf_column(gtkIconView); 593 } 594 595 /** 596 * Retrieves whether the user can reorder the list via drag-and-drop. 597 * See gtk_icon_view_set_reorderable(). 598 * 599 * Returns: %TRUE if the list can be reordered. 600 * 601 * Since: 2.8 602 */ 603 public bool getReorderable() 604 { 605 return gtk_icon_view_get_reorderable(gtkIconView) != 0; 606 } 607 608 /** 609 * Returns the value of the ::row-spacing property. 610 * 611 * Returns: the space between rows 612 * 613 * Since: 2.6 614 */ 615 public int getRowSpacing() 616 { 617 return gtk_icon_view_get_row_spacing(gtkIconView); 618 } 619 620 /** 621 * Creates a list of paths of all selected items. Additionally, if you are 622 * planning on modifying the model after calling this function, you may 623 * want to convert the returned list into a list of #GtkTreeRowReferences. 624 * To do this, you can use gtk_tree_row_reference_new(). 625 * 626 * To free the return value, use: 627 * |[<!-- language="C" --> 628 * g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); 629 * ]| 630 * 631 * Returns: A #GList containing a #GtkTreePath for each selected row. 632 * 633 * Since: 2.6 634 */ 635 public ListG getSelectedItems() 636 { 637 auto p = gtk_icon_view_get_selected_items(gtkIconView); 638 639 if(p is null) 640 { 641 return null; 642 } 643 644 return new ListG(cast(GList*) p, true); 645 } 646 647 /** 648 * Gets the selection mode of the @icon_view. 649 * 650 * Returns: the current selection mode 651 * 652 * Since: 2.6 653 */ 654 public GtkSelectionMode getSelectionMode() 655 { 656 return gtk_icon_view_get_selection_mode(gtkIconView); 657 } 658 659 /** 660 * Returns the value of the ::spacing property. 661 * 662 * Returns: the space between cells 663 * 664 * Since: 2.6 665 */ 666 public int getSpacing() 667 { 668 return gtk_icon_view_get_spacing(gtkIconView); 669 } 670 671 /** 672 * Returns the column with text for @icon_view. 673 * 674 * Returns: the text column, or -1 if it’s unset. 675 * 676 * Since: 2.6 677 */ 678 public int getTextColumn() 679 { 680 return gtk_icon_view_get_text_column(gtkIconView); 681 } 682 683 /** 684 * Returns the column of @icon_view’s model which is being used for 685 * displaying tooltips on @icon_view’s rows. 686 * 687 * Returns: the index of the tooltip column that is currently being 688 * used, or -1 if this is disabled. 689 * 690 * Since: 2.12 691 */ 692 public int getTooltipColumn() 693 { 694 return gtk_icon_view_get_tooltip_column(gtkIconView); 695 } 696 697 /** 698 * This function is supposed to be used in a #GtkWidget::query-tooltip 699 * signal handler for #GtkIconView. The @x, @y and @keyboard_tip values 700 * which are received in the signal handler, should be passed to this 701 * function without modification. 702 * 703 * The return value indicates whether there is an icon view item at the given 704 * coordinates (%TRUE) or not (%FALSE) for mouse tooltips. For keyboard 705 * tooltips the item returned will be the cursor item. When %TRUE, then any of 706 * @model, @path and @iter which have been provided will be set to point to 707 * that row and the corresponding model. @x and @y will always be converted 708 * to be relative to @icon_view’s bin_window if @keyboard_tooltip is %FALSE. 709 * 710 * Params: 711 * x = the x coordinate (relative to widget coordinates) 712 * y = the y coordinate (relative to widget coordinates) 713 * keyboardTip = whether this is a keyboard tooltip or not 714 * model = a pointer to receive a 715 * #GtkTreeModel or %NULL 716 * path = a pointer to receive a #GtkTreePath or %NULL 717 * iter = a pointer to receive a #GtkTreeIter or %NULL 718 * 719 * Returns: whether or not the given tooltip context points to a item 720 * 721 * Since: 2.12 722 */ 723 public bool getTooltipContext(ref int x, ref int y, bool keyboardTip, out TreeModelIF model, out TreePath path, out TreeIter iter) 724 { 725 GtkTreeModel* outmodel = null; 726 GtkTreePath* outpath = null; 727 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 728 729 auto p = gtk_icon_view_get_tooltip_context(gtkIconView, &x, &y, keyboardTip, &outmodel, &outpath, outiter) != 0; 730 731 model = ObjectG.getDObject!(TreeModelIF)(outmodel); 732 path = ObjectG.getDObject!(TreePath)(outpath); 733 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 734 735 return p; 736 } 737 738 /** 739 * Sets @start_path and @end_path to be the first and last visible path. 740 * Note that there may be invisible paths in between. 741 * 742 * Both paths should be freed with gtk_tree_path_free() after use. 743 * 744 * Params: 745 * startPath = Return location for start of region, 746 * or %NULL 747 * endPath = Return location for end of region, or %NULL 748 * 749 * Returns: %TRUE, if valid paths were placed in @start_path and @end_path 750 * 751 * Since: 2.8 752 */ 753 public bool getVisibleRange(out TreePath startPath, out TreePath endPath) 754 { 755 GtkTreePath* outstartPath = null; 756 GtkTreePath* outendPath = null; 757 758 auto p = gtk_icon_view_get_visible_range(gtkIconView, &outstartPath, &outendPath) != 0; 759 760 startPath = ObjectG.getDObject!(TreePath)(outstartPath); 761 endPath = ObjectG.getDObject!(TreePath)(outendPath); 762 763 return p; 764 } 765 766 /** 767 * Activates the item determined by @path. 768 * 769 * Params: 770 * path = The #GtkTreePath to be activated 771 * 772 * Since: 2.6 773 */ 774 public void itemActivated(TreePath path) 775 { 776 gtk_icon_view_item_activated(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 777 } 778 779 /** 780 * Returns %TRUE if the icon pointed to by @path is currently 781 * selected. If @path does not point to a valid location, %FALSE is returned. 782 * 783 * Params: 784 * path = A #GtkTreePath to check selection on. 785 * 786 * Returns: %TRUE if @path is selected. 787 * 788 * Since: 2.6 789 */ 790 public bool pathIsSelected(TreePath path) 791 { 792 return gtk_icon_view_path_is_selected(gtkIconView, (path is null) ? null : path.getTreePathStruct()) != 0; 793 } 794 795 /** 796 * Moves the alignments of @icon_view to the position specified by @path. 797 * @row_align determines where the row is placed, and @col_align determines 798 * where @column is placed. Both are expected to be between 0.0 and 1.0. 799 * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means 800 * center. 801 * 802 * If @use_align is %FALSE, then the alignment arguments are ignored, and the 803 * tree does the minimum amount of work to scroll the item onto the screen. 804 * This means that the item will be scrolled to the edge closest to its current 805 * position. If the item is currently visible on the screen, nothing is done. 806 * 807 * This function only works if the model is set, and @path is a valid row on 808 * the model. If the model changes before the @icon_view is realized, the 809 * centered path will be modified to reflect this change. 810 * 811 * Params: 812 * path = The path of the item to move to. 813 * useAlign = whether to use alignment arguments, or %FALSE. 814 * rowAlign = The vertical alignment of the item specified by @path. 815 * colAlign = The horizontal alignment of the item specified by @path. 816 * 817 * Since: 2.8 818 */ 819 public void scrollToPath(TreePath path, bool useAlign, float rowAlign, float colAlign) 820 { 821 gtk_icon_view_scroll_to_path(gtkIconView, (path is null) ? null : path.getTreePathStruct(), useAlign, rowAlign, colAlign); 822 } 823 824 /** 825 * Selects all the icons. @icon_view must has its selection mode set 826 * to #GTK_SELECTION_MULTIPLE. 827 * 828 * Since: 2.6 829 */ 830 public void selectAll() 831 { 832 gtk_icon_view_select_all(gtkIconView); 833 } 834 835 /** 836 * Selects the row at @path. 837 * 838 * Params: 839 * path = The #GtkTreePath to be selected. 840 * 841 * Since: 2.6 842 */ 843 public void selectPath(TreePath path) 844 { 845 gtk_icon_view_select_path(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 846 } 847 848 /** 849 * Calls a function for each selected icon. Note that the model or 850 * selection cannot be modified from within this function. 851 * 852 * Params: 853 * func = The function to call for each selected icon. 854 * data = User data to pass to the function. 855 * 856 * Since: 2.6 857 */ 858 public void selectedForeach(GtkIconViewForeachFunc func, void* data) 859 { 860 gtk_icon_view_selected_foreach(gtkIconView, func, data); 861 } 862 863 /** 864 * Causes the #GtkIconView::item-activated signal to be emitted on 865 * a single click instead of a double click. 866 * 867 * Params: 868 * single = %TRUE to emit item-activated on a single click 869 * 870 * Since: 3.8 871 */ 872 public void setActivateOnSingleClick(bool single) 873 { 874 gtk_icon_view_set_activate_on_single_click(gtkIconView, single); 875 } 876 877 /** 878 * Sets the ::column-spacing property which specifies the space 879 * which is inserted between the columns of the icon view. 880 * 881 * Params: 882 * columnSpacing = the column spacing 883 * 884 * Since: 2.6 885 */ 886 public void setColumnSpacing(int columnSpacing) 887 { 888 gtk_icon_view_set_column_spacing(gtkIconView, columnSpacing); 889 } 890 891 /** 892 * Sets the ::columns property which determines in how 893 * many columns the icons are arranged. If @columns is 894 * -1, the number of columns will be chosen automatically 895 * to fill the available area. 896 * 897 * Params: 898 * columns = the number of columns 899 * 900 * Since: 2.6 901 */ 902 public void setColumns(int columns) 903 { 904 gtk_icon_view_set_columns(gtkIconView, columns); 905 } 906 907 /** 908 * Sets the current keyboard focus to be at @path, and selects it. This is 909 * useful when you want to focus the user’s attention on a particular item. 910 * If @cell is not %NULL, then focus is given to the cell specified by 911 * it. Additionally, if @start_editing is %TRUE, then editing should be 912 * started in the specified cell. 913 * 914 * This function is often followed by `gtk_widget_grab_focus 915 * (icon_view)` in order to give keyboard focus to the widget. 916 * Please note that editing can only happen when the widget is realized. 917 * 918 * Params: 919 * path = A #GtkTreePath 920 * cell = One of the cell renderers of @icon_view, or %NULL 921 * startEditing = %TRUE if the specified cell should start being edited. 922 * 923 * Since: 2.8 924 */ 925 public void setCursor(TreePath path, CellRenderer cell, bool startEditing) 926 { 927 gtk_icon_view_set_cursor(gtkIconView, (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct(), startEditing); 928 } 929 930 /** 931 * Sets the item that is highlighted for feedback. 932 * 933 * Params: 934 * path = The path of the item to highlight, or %NULL. 935 * pos = Specifies where to drop, relative to the item 936 * 937 * Since: 2.8 938 */ 939 public void setDragDestItem(TreePath path, GtkIconViewDropPosition pos) 940 { 941 gtk_icon_view_set_drag_dest_item(gtkIconView, (path is null) ? null : path.getTreePathStruct(), pos); 942 } 943 944 /** 945 * Sets the ::item-orientation property which determines whether the labels 946 * are drawn beside the icons instead of below. 947 * 948 * Params: 949 * orientation = the relative position of texts and icons 950 * 951 * Since: 2.6 952 */ 953 public void setItemOrientation(GtkOrientation orientation) 954 { 955 gtk_icon_view_set_item_orientation(gtkIconView, orientation); 956 } 957 958 /** 959 * Sets the #GtkIconView:item-padding property which specifies the padding 960 * around each of the icon view’s items. 961 * 962 * Params: 963 * itemPadding = the item padding 964 * 965 * Since: 2.18 966 */ 967 public void setItemPadding(int itemPadding) 968 { 969 gtk_icon_view_set_item_padding(gtkIconView, itemPadding); 970 } 971 972 /** 973 * Sets the ::item-width property which specifies the width 974 * to use for each item. If it is set to -1, the icon view will 975 * automatically determine a suitable item size. 976 * 977 * Params: 978 * itemWidth = the width for each item 979 * 980 * Since: 2.6 981 */ 982 public void setItemWidth(int itemWidth) 983 { 984 gtk_icon_view_set_item_width(gtkIconView, itemWidth); 985 } 986 987 /** 988 * Sets the ::margin property which specifies the space 989 * which is inserted at the top, bottom, left and right 990 * of the icon view. 991 * 992 * Params: 993 * margin = the margin 994 * 995 * Since: 2.6 996 */ 997 public void setMargin(int margin) 998 { 999 gtk_icon_view_set_margin(gtkIconView, margin); 1000 } 1001 1002 /** 1003 * Sets the column with markup information for @icon_view to be 1004 * @column. The markup column must be of type #G_TYPE_STRING. 1005 * If the markup column is set to something, it overrides 1006 * the text column set by gtk_icon_view_set_text_column(). 1007 * 1008 * Params: 1009 * column = A column in the currently used model, or -1 to display no text 1010 * 1011 * Since: 2.6 1012 */ 1013 public void setMarkupColumn(int column) 1014 { 1015 gtk_icon_view_set_markup_column(gtkIconView, column); 1016 } 1017 1018 /** 1019 * Sets the model for a #GtkIconView. 1020 * If the @icon_view already has a model set, it will remove 1021 * it before setting the new model. If @model is %NULL, then 1022 * it will unset the old model. 1023 * 1024 * Params: 1025 * model = The model. 1026 * 1027 * Since: 2.6 1028 */ 1029 public void setModel(TreeModelIF model) 1030 { 1031 gtk_icon_view_set_model(gtkIconView, (model is null) ? null : model.getTreeModelStruct()); 1032 } 1033 1034 /** 1035 * Sets the column with pixbufs for @icon_view to be @column. The pixbuf 1036 * column must be of type #GDK_TYPE_PIXBUF 1037 * 1038 * Params: 1039 * column = A column in the currently used model, or -1 to disable 1040 * 1041 * Since: 2.6 1042 */ 1043 public void setPixbufColumn(int column) 1044 { 1045 gtk_icon_view_set_pixbuf_column(gtkIconView, column); 1046 } 1047 1048 /** 1049 * This function is a convenience function to allow you to reorder models that 1050 * support the #GtkTreeDragSourceIface and the #GtkTreeDragDestIface. Both 1051 * #GtkTreeStore and #GtkListStore support these. If @reorderable is %TRUE, then 1052 * the user can reorder the model by dragging and dropping rows. The 1053 * developer can listen to these changes by connecting to the model's 1054 * row_inserted and row_deleted signals. The reordering is implemented by setting up 1055 * the icon view as a drag source and destination. Therefore, drag and 1056 * drop can not be used in a reorderable view for any other purpose. 1057 * 1058 * This function does not give you any degree of control over the order -- any 1059 * reordering is allowed. If more control is needed, you should probably 1060 * handle drag and drop manually. 1061 * 1062 * Params: 1063 * reorderable = %TRUE, if the list of items can be reordered. 1064 * 1065 * Since: 2.8 1066 */ 1067 public void setReorderable(bool reorderable) 1068 { 1069 gtk_icon_view_set_reorderable(gtkIconView, reorderable); 1070 } 1071 1072 /** 1073 * Sets the ::row-spacing property which specifies the space 1074 * which is inserted between the rows of the icon view. 1075 * 1076 * Params: 1077 * rowSpacing = the row spacing 1078 * 1079 * Since: 2.6 1080 */ 1081 public void setRowSpacing(int rowSpacing) 1082 { 1083 gtk_icon_view_set_row_spacing(gtkIconView, rowSpacing); 1084 } 1085 1086 /** 1087 * Sets the selection mode of the @icon_view. 1088 * 1089 * Params: 1090 * mode = The selection mode 1091 * 1092 * Since: 2.6 1093 */ 1094 public void setSelectionMode(GtkSelectionMode mode) 1095 { 1096 gtk_icon_view_set_selection_mode(gtkIconView, mode); 1097 } 1098 1099 /** 1100 * Sets the ::spacing property which specifies the space 1101 * which is inserted between the cells (i.e. the icon and 1102 * the text) of an item. 1103 * 1104 * Params: 1105 * spacing = the spacing 1106 * 1107 * Since: 2.6 1108 */ 1109 public void setSpacing(int spacing) 1110 { 1111 gtk_icon_view_set_spacing(gtkIconView, spacing); 1112 } 1113 1114 /** 1115 * Sets the column with text for @icon_view to be @column. The text 1116 * column must be of type #G_TYPE_STRING. 1117 * 1118 * Params: 1119 * column = A column in the currently used model, or -1 to display no text 1120 * 1121 * Since: 2.6 1122 */ 1123 public void setTextColumn(int column) 1124 { 1125 gtk_icon_view_set_text_column(gtkIconView, column); 1126 } 1127 1128 /** 1129 * Sets the tip area of @tooltip to the area which @cell occupies in 1130 * the item pointed to by @path. See also gtk_tooltip_set_tip_area(). 1131 * 1132 * See also gtk_icon_view_set_tooltip_column() for a simpler alternative. 1133 * 1134 * Params: 1135 * tooltip = a #GtkTooltip 1136 * path = a #GtkTreePath 1137 * cell = a #GtkCellRenderer or %NULL 1138 * 1139 * Since: 2.12 1140 */ 1141 public void setTooltipCell(Tooltip tooltip, TreePath path, CellRenderer cell) 1142 { 1143 gtk_icon_view_set_tooltip_cell(gtkIconView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct(), (cell is null) ? null : cell.getCellRendererStruct()); 1144 } 1145 1146 /** 1147 * If you only plan to have simple (text-only) tooltips on full items, you 1148 * can use this function to have #GtkIconView handle these automatically 1149 * for you. @column should be set to the column in @icon_view’s model 1150 * containing the tooltip texts, or -1 to disable this feature. 1151 * 1152 * When enabled, #GtkWidget:has-tooltip will be set to %TRUE and 1153 * @icon_view will connect a #GtkWidget::query-tooltip signal handler. 1154 * 1155 * Note that the signal handler sets the text with gtk_tooltip_set_markup(), 1156 * so &, <, etc have to be escaped in the text. 1157 * 1158 * Params: 1159 * column = an integer, which is a valid column number for @icon_view’s model 1160 * 1161 * Since: 2.12 1162 */ 1163 public void setTooltipColumn(int column) 1164 { 1165 gtk_icon_view_set_tooltip_column(gtkIconView, column); 1166 } 1167 1168 /** 1169 * Sets the tip area of @tooltip to be the area covered by the item at @path. 1170 * See also gtk_icon_view_set_tooltip_column() for a simpler alternative. 1171 * See also gtk_tooltip_set_tip_area(). 1172 * 1173 * Params: 1174 * tooltip = a #GtkTooltip 1175 * path = a #GtkTreePath 1176 * 1177 * Since: 2.12 1178 */ 1179 public void setTooltipItem(Tooltip tooltip, TreePath path) 1180 { 1181 gtk_icon_view_set_tooltip_item(gtkIconView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct()); 1182 } 1183 1184 /** 1185 * Unselects all the icons. 1186 * 1187 * Since: 2.6 1188 */ 1189 public void unselectAll() 1190 { 1191 gtk_icon_view_unselect_all(gtkIconView); 1192 } 1193 1194 /** 1195 * Unselects the row at @path. 1196 * 1197 * Params: 1198 * path = The #GtkTreePath to be unselected. 1199 * 1200 * Since: 2.6 1201 */ 1202 public void unselectPath(TreePath path) 1203 { 1204 gtk_icon_view_unselect_path(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 1205 } 1206 1207 /** 1208 * Undoes the effect of gtk_icon_view_enable_model_drag_dest(). Calling this 1209 * method sets #GtkIconView:reorderable to %FALSE. 1210 * 1211 * Since: 2.8 1212 */ 1213 public void unsetModelDragDest() 1214 { 1215 gtk_icon_view_unset_model_drag_dest(gtkIconView); 1216 } 1217 1218 /** 1219 * Undoes the effect of gtk_icon_view_enable_model_drag_source(). Calling this 1220 * method sets #GtkIconView:reorderable to %FALSE. 1221 * 1222 * Since: 2.8 1223 */ 1224 public void unsetModelDragSource() 1225 { 1226 gtk_icon_view_unset_model_drag_source(gtkIconView); 1227 } 1228 1229 protected class OnActivateCursorItemDelegateWrapper 1230 { 1231 bool delegate(IconView) dlg; 1232 gulong handlerId; 1233 1234 this(bool delegate(IconView) dlg) 1235 { 1236 this.dlg = dlg; 1237 onActivateCursorItemListeners ~= this; 1238 } 1239 1240 void remove(OnActivateCursorItemDelegateWrapper source) 1241 { 1242 foreach(index, wrapper; onActivateCursorItemListeners) 1243 { 1244 if (wrapper.handlerId == source.handlerId) 1245 { 1246 onActivateCursorItemListeners[index] = null; 1247 onActivateCursorItemListeners = std.algorithm.remove(onActivateCursorItemListeners, index); 1248 break; 1249 } 1250 } 1251 } 1252 } 1253 OnActivateCursorItemDelegateWrapper[] onActivateCursorItemListeners; 1254 1255 /** 1256 * A [keybinding signal][GtkBindingSignal] 1257 * which gets emitted when the user activates the currently 1258 * focused item. 1259 * 1260 * Applications should not connect to it, but may emit it with 1261 * g_signal_emit_by_name() if they need to control activation 1262 * programmatically. 1263 * 1264 * The default bindings for this signal are Space, Return and Enter. 1265 */ 1266 gulong addOnActivateCursorItem(bool delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1267 { 1268 auto wrapper = new OnActivateCursorItemDelegateWrapper(dlg); 1269 wrapper.handlerId = Signals.connectData( 1270 this, 1271 "activate-cursor-item", 1272 cast(GCallback)&callBackActivateCursorItem, 1273 cast(void*)wrapper, 1274 cast(GClosureNotify)&callBackActivateCursorItemDestroy, 1275 connectFlags); 1276 return wrapper.handlerId; 1277 } 1278 1279 extern(C) static int callBackActivateCursorItem(GtkIconView* iconviewStruct, OnActivateCursorItemDelegateWrapper wrapper) 1280 { 1281 return wrapper.dlg(wrapper.outer); 1282 } 1283 1284 extern(C) static void callBackActivateCursorItemDestroy(OnActivateCursorItemDelegateWrapper wrapper, GClosure* closure) 1285 { 1286 wrapper.remove(wrapper); 1287 } 1288 1289 protected class OnItemActivatedDelegateWrapper 1290 { 1291 void delegate(TreePath, IconView) dlg; 1292 gulong handlerId; 1293 1294 this(void delegate(TreePath, IconView) dlg) 1295 { 1296 this.dlg = dlg; 1297 onItemActivatedListeners ~= this; 1298 } 1299 1300 void remove(OnItemActivatedDelegateWrapper source) 1301 { 1302 foreach(index, wrapper; onItemActivatedListeners) 1303 { 1304 if (wrapper.handlerId == source.handlerId) 1305 { 1306 onItemActivatedListeners[index] = null; 1307 onItemActivatedListeners = std.algorithm.remove(onItemActivatedListeners, index); 1308 break; 1309 } 1310 } 1311 } 1312 } 1313 OnItemActivatedDelegateWrapper[] onItemActivatedListeners; 1314 1315 /** 1316 * The ::item-activated signal is emitted when the method 1317 * gtk_icon_view_item_activated() is called, when the user double 1318 * clicks an item with the "activate-on-single-click" property set 1319 * to %FALSE, or when the user single clicks an item when the 1320 * "activate-on-single-click" property set to %TRUE. It is also 1321 * emitted when a non-editable item is selected and one of the keys: 1322 * Space, Return or Enter is pressed. 1323 * 1324 * Params: 1325 * path = the #GtkTreePath for the activated item 1326 */ 1327 gulong addOnItemActivated(void delegate(TreePath, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1328 { 1329 auto wrapper = new OnItemActivatedDelegateWrapper(dlg); 1330 wrapper.handlerId = Signals.connectData( 1331 this, 1332 "item-activated", 1333 cast(GCallback)&callBackItemActivated, 1334 cast(void*)wrapper, 1335 cast(GClosureNotify)&callBackItemActivatedDestroy, 1336 connectFlags); 1337 return wrapper.handlerId; 1338 } 1339 1340 extern(C) static void callBackItemActivated(GtkIconView* iconviewStruct, GtkTreePath* path, OnItemActivatedDelegateWrapper wrapper) 1341 { 1342 wrapper.dlg(ObjectG.getDObject!(TreePath)(path), wrapper.outer); 1343 } 1344 1345 extern(C) static void callBackItemActivatedDestroy(OnItemActivatedDelegateWrapper wrapper, GClosure* closure) 1346 { 1347 wrapper.remove(wrapper); 1348 } 1349 1350 protected class OnMoveCursorDelegateWrapper 1351 { 1352 bool delegate(GtkMovementStep, int, IconView) dlg; 1353 gulong handlerId; 1354 1355 this(bool delegate(GtkMovementStep, int, IconView) dlg) 1356 { 1357 this.dlg = dlg; 1358 onMoveCursorListeners ~= this; 1359 } 1360 1361 void remove(OnMoveCursorDelegateWrapper source) 1362 { 1363 foreach(index, wrapper; onMoveCursorListeners) 1364 { 1365 if (wrapper.handlerId == source.handlerId) 1366 { 1367 onMoveCursorListeners[index] = null; 1368 onMoveCursorListeners = std.algorithm.remove(onMoveCursorListeners, index); 1369 break; 1370 } 1371 } 1372 } 1373 } 1374 OnMoveCursorDelegateWrapper[] onMoveCursorListeners; 1375 1376 /** 1377 * The ::move-cursor signal is a 1378 * [keybinding signal][GtkBindingSignal] 1379 * which gets emitted when the user initiates a cursor movement. 1380 * 1381 * Applications should not connect to it, but may emit it with 1382 * g_signal_emit_by_name() if they need to control the cursor 1383 * programmatically. 1384 * 1385 * The default bindings for this signal include 1386 * - Arrow keys which move by individual steps 1387 * - Home/End keys which move to the first/last item 1388 * - PageUp/PageDown which move by "pages" 1389 * All of these will extend the selection when combined with 1390 * the Shift modifier. 1391 * 1392 * Params: 1393 * step = the granularity of the move, as a #GtkMovementStep 1394 * count = the number of @step units to move 1395 */ 1396 gulong addOnMoveCursor(bool delegate(GtkMovementStep, int, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1397 { 1398 auto wrapper = new OnMoveCursorDelegateWrapper(dlg); 1399 wrapper.handlerId = Signals.connectData( 1400 this, 1401 "move-cursor", 1402 cast(GCallback)&callBackMoveCursor, 1403 cast(void*)wrapper, 1404 cast(GClosureNotify)&callBackMoveCursorDestroy, 1405 connectFlags); 1406 return wrapper.handlerId; 1407 } 1408 1409 extern(C) static int callBackMoveCursor(GtkIconView* iconviewStruct, GtkMovementStep step, int count, OnMoveCursorDelegateWrapper wrapper) 1410 { 1411 return wrapper.dlg(step, count, wrapper.outer); 1412 } 1413 1414 extern(C) static void callBackMoveCursorDestroy(OnMoveCursorDelegateWrapper wrapper, GClosure* closure) 1415 { 1416 wrapper.remove(wrapper); 1417 } 1418 1419 protected class OnSelectAllDelegateWrapper 1420 { 1421 void delegate(IconView) dlg; 1422 gulong handlerId; 1423 1424 this(void delegate(IconView) dlg) 1425 { 1426 this.dlg = dlg; 1427 onSelectAllListeners ~= this; 1428 } 1429 1430 void remove(OnSelectAllDelegateWrapper source) 1431 { 1432 foreach(index, wrapper; onSelectAllListeners) 1433 { 1434 if (wrapper.handlerId == source.handlerId) 1435 { 1436 onSelectAllListeners[index] = null; 1437 onSelectAllListeners = std.algorithm.remove(onSelectAllListeners, index); 1438 break; 1439 } 1440 } 1441 } 1442 } 1443 OnSelectAllDelegateWrapper[] onSelectAllListeners; 1444 1445 /** 1446 * A [keybinding signal][GtkBindingSignal] 1447 * which gets emitted when the user selects all items. 1448 * 1449 * Applications should not connect to it, but may emit it with 1450 * g_signal_emit_by_name() if they need to control selection 1451 * programmatically. 1452 * 1453 * The default binding for this signal is Ctrl-a. 1454 */ 1455 gulong addOnSelectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1456 { 1457 auto wrapper = new OnSelectAllDelegateWrapper(dlg); 1458 wrapper.handlerId = Signals.connectData( 1459 this, 1460 "select-all", 1461 cast(GCallback)&callBackSelectAll, 1462 cast(void*)wrapper, 1463 cast(GClosureNotify)&callBackSelectAllDestroy, 1464 connectFlags); 1465 return wrapper.handlerId; 1466 } 1467 1468 extern(C) static void callBackSelectAll(GtkIconView* iconviewStruct, OnSelectAllDelegateWrapper wrapper) 1469 { 1470 wrapper.dlg(wrapper.outer); 1471 } 1472 1473 extern(C) static void callBackSelectAllDestroy(OnSelectAllDelegateWrapper wrapper, GClosure* closure) 1474 { 1475 wrapper.remove(wrapper); 1476 } 1477 1478 protected class OnSelectCursorItemDelegateWrapper 1479 { 1480 void delegate(IconView) dlg; 1481 gulong handlerId; 1482 1483 this(void delegate(IconView) dlg) 1484 { 1485 this.dlg = dlg; 1486 onSelectCursorItemListeners ~= this; 1487 } 1488 1489 void remove(OnSelectCursorItemDelegateWrapper source) 1490 { 1491 foreach(index, wrapper; onSelectCursorItemListeners) 1492 { 1493 if (wrapper.handlerId == source.handlerId) 1494 { 1495 onSelectCursorItemListeners[index] = null; 1496 onSelectCursorItemListeners = std.algorithm.remove(onSelectCursorItemListeners, index); 1497 break; 1498 } 1499 } 1500 } 1501 } 1502 OnSelectCursorItemDelegateWrapper[] onSelectCursorItemListeners; 1503 1504 /** 1505 * A [keybinding signal][GtkBindingSignal] 1506 * which gets emitted when the user selects the item that is currently 1507 * focused. 1508 * 1509 * Applications should not connect to it, but may emit it with 1510 * g_signal_emit_by_name() if they need to control selection 1511 * programmatically. 1512 * 1513 * There is no default binding for this signal. 1514 */ 1515 gulong addOnSelectCursorItem(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1516 { 1517 auto wrapper = new OnSelectCursorItemDelegateWrapper(dlg); 1518 wrapper.handlerId = Signals.connectData( 1519 this, 1520 "select-cursor-item", 1521 cast(GCallback)&callBackSelectCursorItem, 1522 cast(void*)wrapper, 1523 cast(GClosureNotify)&callBackSelectCursorItemDestroy, 1524 connectFlags); 1525 return wrapper.handlerId; 1526 } 1527 1528 extern(C) static void callBackSelectCursorItem(GtkIconView* iconviewStruct, OnSelectCursorItemDelegateWrapper wrapper) 1529 { 1530 wrapper.dlg(wrapper.outer); 1531 } 1532 1533 extern(C) static void callBackSelectCursorItemDestroy(OnSelectCursorItemDelegateWrapper wrapper, GClosure* closure) 1534 { 1535 wrapper.remove(wrapper); 1536 } 1537 1538 protected class OnSelectionChangedDelegateWrapper 1539 { 1540 void delegate(IconView) dlg; 1541 gulong handlerId; 1542 1543 this(void delegate(IconView) dlg) 1544 { 1545 this.dlg = dlg; 1546 onSelectionChangedListeners ~= this; 1547 } 1548 1549 void remove(OnSelectionChangedDelegateWrapper source) 1550 { 1551 foreach(index, wrapper; onSelectionChangedListeners) 1552 { 1553 if (wrapper.handlerId == source.handlerId) 1554 { 1555 onSelectionChangedListeners[index] = null; 1556 onSelectionChangedListeners = std.algorithm.remove(onSelectionChangedListeners, index); 1557 break; 1558 } 1559 } 1560 } 1561 } 1562 OnSelectionChangedDelegateWrapper[] onSelectionChangedListeners; 1563 1564 /** 1565 * The ::selection-changed signal is emitted when the selection 1566 * (i.e. the set of selected items) changes. 1567 */ 1568 gulong addOnSelectionChanged(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1569 { 1570 auto wrapper = new OnSelectionChangedDelegateWrapper(dlg); 1571 wrapper.handlerId = Signals.connectData( 1572 this, 1573 "selection-changed", 1574 cast(GCallback)&callBackSelectionChanged, 1575 cast(void*)wrapper, 1576 cast(GClosureNotify)&callBackSelectionChangedDestroy, 1577 connectFlags); 1578 return wrapper.handlerId; 1579 } 1580 1581 extern(C) static void callBackSelectionChanged(GtkIconView* iconviewStruct, OnSelectionChangedDelegateWrapper wrapper) 1582 { 1583 wrapper.dlg(wrapper.outer); 1584 } 1585 1586 extern(C) static void callBackSelectionChangedDestroy(OnSelectionChangedDelegateWrapper wrapper, GClosure* closure) 1587 { 1588 wrapper.remove(wrapper); 1589 } 1590 1591 protected class OnToggleCursorItemDelegateWrapper 1592 { 1593 void delegate(IconView) dlg; 1594 gulong handlerId; 1595 1596 this(void delegate(IconView) dlg) 1597 { 1598 this.dlg = dlg; 1599 onToggleCursorItemListeners ~= this; 1600 } 1601 1602 void remove(OnToggleCursorItemDelegateWrapper source) 1603 { 1604 foreach(index, wrapper; onToggleCursorItemListeners) 1605 { 1606 if (wrapper.handlerId == source.handlerId) 1607 { 1608 onToggleCursorItemListeners[index] = null; 1609 onToggleCursorItemListeners = std.algorithm.remove(onToggleCursorItemListeners, index); 1610 break; 1611 } 1612 } 1613 } 1614 } 1615 OnToggleCursorItemDelegateWrapper[] onToggleCursorItemListeners; 1616 1617 /** 1618 * A [keybinding signal][GtkBindingSignal] 1619 * which gets emitted when the user toggles whether the currently 1620 * focused item is selected or not. The exact effect of this 1621 * depend on the selection mode. 1622 * 1623 * Applications should not connect to it, but may emit it with 1624 * g_signal_emit_by_name() if they need to control selection 1625 * programmatically. 1626 * 1627 * There is no default binding for this signal is Ctrl-Space. 1628 */ 1629 gulong addOnToggleCursorItem(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1630 { 1631 auto wrapper = new OnToggleCursorItemDelegateWrapper(dlg); 1632 wrapper.handlerId = Signals.connectData( 1633 this, 1634 "toggle-cursor-item", 1635 cast(GCallback)&callBackToggleCursorItem, 1636 cast(void*)wrapper, 1637 cast(GClosureNotify)&callBackToggleCursorItemDestroy, 1638 connectFlags); 1639 return wrapper.handlerId; 1640 } 1641 1642 extern(C) static void callBackToggleCursorItem(GtkIconView* iconviewStruct, OnToggleCursorItemDelegateWrapper wrapper) 1643 { 1644 wrapper.dlg(wrapper.outer); 1645 } 1646 1647 extern(C) static void callBackToggleCursorItemDestroy(OnToggleCursorItemDelegateWrapper wrapper, GClosure* closure) 1648 { 1649 wrapper.remove(wrapper); 1650 } 1651 1652 protected class OnUnselectAllDelegateWrapper 1653 { 1654 void delegate(IconView) dlg; 1655 gulong handlerId; 1656 1657 this(void delegate(IconView) dlg) 1658 { 1659 this.dlg = dlg; 1660 onUnselectAllListeners ~= this; 1661 } 1662 1663 void remove(OnUnselectAllDelegateWrapper source) 1664 { 1665 foreach(index, wrapper; onUnselectAllListeners) 1666 { 1667 if (wrapper.handlerId == source.handlerId) 1668 { 1669 onUnselectAllListeners[index] = null; 1670 onUnselectAllListeners = std.algorithm.remove(onUnselectAllListeners, index); 1671 break; 1672 } 1673 } 1674 } 1675 } 1676 OnUnselectAllDelegateWrapper[] onUnselectAllListeners; 1677 1678 /** 1679 * A [keybinding signal][GtkBindingSignal] 1680 * which gets emitted when the user unselects all items. 1681 * 1682 * Applications should not connect to it, but may emit it with 1683 * g_signal_emit_by_name() if they need to control selection 1684 * programmatically. 1685 * 1686 * The default binding for this signal is Ctrl-Shift-a. 1687 */ 1688 gulong addOnUnselectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1689 { 1690 auto wrapper = new OnUnselectAllDelegateWrapper(dlg); 1691 wrapper.handlerId = Signals.connectData( 1692 this, 1693 "unselect-all", 1694 cast(GCallback)&callBackUnselectAll, 1695 cast(void*)wrapper, 1696 cast(GClosureNotify)&callBackUnselectAllDestroy, 1697 connectFlags); 1698 return wrapper.handlerId; 1699 } 1700 1701 extern(C) static void callBackUnselectAll(GtkIconView* iconviewStruct, OnUnselectAllDelegateWrapper wrapper) 1702 { 1703 wrapper.dlg(wrapper.outer); 1704 } 1705 1706 extern(C) static void callBackUnselectAllDestroy(OnUnselectAllDelegateWrapper wrapper, GClosure* closure) 1707 { 1708 wrapper.remove(wrapper); 1709 } 1710 }