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 gobject.ObjectG; 31 private import gobject.Signals; 32 private import gtk.CellArea; 33 private import gtk.CellLayoutIF; 34 private import gtk.CellLayoutT; 35 private import gtk.CellRenderer; 36 private import gtk.Container; 37 private import gtk.ScrollableIF; 38 private import gtk.ScrollableT; 39 private import gtk.TargetEntry; 40 private import gtk.Tooltip; 41 private import gtk.TreeIter; 42 private import gtk.TreeModel; 43 private import gtk.TreeModelIF; 44 private import gtk.TreePath; 45 private import gtk.Widget; 46 public import gtkc.gdktypes; 47 private import gtkc.gtk; 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() 82 { 83 return gtkIconView; 84 } 85 86 /** the main Gtk struct as a void* */ 87 protected override void* getStruct() 88 { 89 return cast(void*)gtkIconView; 90 } 91 92 protected override void setStruct(GObject* obj) 93 { 94 gtkIconView = cast(GtkIconView*)obj; 95 super.setStruct(obj); 96 } 97 98 /** 99 * Sets our main struct and passes it to the parent class. 100 */ 101 public this (GtkIconView* gtkIconView, bool ownedRef = false) 102 { 103 this.gtkIconView = gtkIconView; 104 super(cast(GtkContainer*)gtkIconView, ownedRef); 105 } 106 107 // add the CellLayout capabilities 108 mixin CellLayoutT!(GtkIconView); 109 110 // add the Scrollable capabilities 111 mixin ScrollableT!(GtkIconView); 112 113 114 /** */ 115 public static GType getType() 116 { 117 return gtk_icon_view_get_type(); 118 } 119 120 /** 121 * Creates a new #GtkIconView widget 122 * 123 * Return: A newly created #GtkIconView widget 124 * 125 * Since: 2.6 126 * 127 * Throws: ConstructionException GTK+ fails to create the object. 128 */ 129 public this() 130 { 131 auto p = gtk_icon_view_new(); 132 133 if(p is null) 134 { 135 throw new ConstructionException("null returned by new"); 136 } 137 138 this(cast(GtkIconView*) p); 139 } 140 141 /** 142 * Creates a new #GtkIconView widget using the 143 * specified @area to layout cells inside the icons. 144 * 145 * Params: 146 * area = the #GtkCellArea to use to layout cells 147 * 148 * Return: A newly created #GtkIconView widget 149 * 150 * Since: 3.0 151 * 152 * Throws: ConstructionException GTK+ fails to create the object. 153 */ 154 public this(CellArea area) 155 { 156 auto p = gtk_icon_view_new_with_area((area is null) ? null : area.getCellAreaStruct()); 157 158 if(p is null) 159 { 160 throw new ConstructionException("null returned by new_with_area"); 161 } 162 163 this(cast(GtkIconView*) p); 164 } 165 166 /** 167 * Creates a new #GtkIconView widget with the model @model. 168 * 169 * Params: 170 * model = The model. 171 * 172 * Return: A newly created #GtkIconView widget. 173 * 174 * Since: 2.6 175 * 176 * Throws: ConstructionException GTK+ fails to create the object. 177 */ 178 public this(TreeModelIF model) 179 { 180 auto p = gtk_icon_view_new_with_model((model is null) ? null : model.getTreeModelStruct()); 181 182 if(p is null) 183 { 184 throw new ConstructionException("null returned by new_with_model"); 185 } 186 187 this(cast(GtkIconView*) p); 188 } 189 190 /** 191 * Converts widget coordinates to coordinates for the bin_window, 192 * as expected by e.g. gtk_icon_view_get_path_at_pos(). 193 * 194 * Params: 195 * wx = X coordinate relative to the widget 196 * wy = Y coordinate relative to the widget 197 * bx = return location for bin_window X coordinate 198 * by = return location for bin_window Y coordinate 199 * 200 * Since: 2.12 201 */ 202 public void convertWidgetToBinWindowCoords(int wx, int wy, out int bx, out int by) 203 { 204 gtk_icon_view_convert_widget_to_bin_window_coords(gtkIconView, wx, wy, &bx, &by); 205 } 206 207 /** 208 * Creates a #cairo_surface_t representation of the item at @path. 209 * This image is used for a drag icon. 210 * 211 * Params: 212 * path = a #GtkTreePath in @icon_view 213 * 214 * Return: a newly-allocated surface of the drag icon. 215 * 216 * Since: 2.8 217 */ 218 public Surface createDragIcon(TreePath path) 219 { 220 auto p = gtk_icon_view_create_drag_icon(gtkIconView, (path is null) ? null : path.getTreePathStruct()); 221 222 if(p is null) 223 { 224 return null; 225 } 226 227 return new Surface(cast(cairo_surface_t*) p); 228 } 229 230 /** 231 * Turns @icon_view into a drop destination for automatic DND. Calling this 232 * method sets #GtkIconView:reorderable to %FALSE. 233 * 234 * Params: 235 * targets = the table of targets that the drag will 236 * support 237 * nTargets = the number of items in @targets 238 * actions = the bitmask of possible actions for a drag to this 239 * widget 240 * 241 * Since: 2.8 242 */ 243 public void enableModelDragDest(TargetEntry[] targets, GdkDragAction actions) 244 { 245 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 246 for ( int i = 0; i < targets.length; i++ ) 247 { 248 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 249 } 250 251 gtk_icon_view_enable_model_drag_dest(gtkIconView, targetsArray.ptr, cast(int)targets.length, actions); 252 } 253 254 /** 255 * Turns @icon_view into a drag source for automatic DND. Calling this 256 * method sets #GtkIconView:reorderable to %FALSE. 257 * 258 * Params: 259 * startButtonMask = Mask of allowed buttons to start drag 260 * targets = the table of targets that the drag will 261 * support 262 * nTargets = the number of items in @targets 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 * Return: %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 * Return: %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 * Return: 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 * Return: 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 * Return: %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 * Return: 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 * Return: %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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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!(TreeModel, 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 * Return: 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 * Return: 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 * Return: %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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 = gMalloc!GtkTreeIter(); 728 729 auto p = gtk_icon_view_get_tooltip_context(gtkIconView, &x, &y, keyboardTip, &outmodel, &outpath, outiter) != 0; 730 731 model = ObjectG.getDObject!(TreeModel, 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 * Return: %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 * Return: %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 ConnectFlags flags; 1234 this(bool delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1235 { 1236 this.dlg = dlg; 1237 this.handlerId = handlerId; 1238 this.flags = flags; 1239 } 1240 } 1241 protected OnActivateCursorItemDelegateWrapper[] onActivateCursorItemListeners; 1242 1243 /** 1244 * A [keybinding signal][GtkBindingSignal] 1245 * which gets emitted when the user activates the currently 1246 * focused item. 1247 * 1248 * Applications should not connect to it, but may emit it with 1249 * g_signal_emit_by_name() if they need to control activation 1250 * programmatically. 1251 * 1252 * The default bindings for this signal are Space, Return and Enter. 1253 */ 1254 gulong addOnActivateCursorItem(bool delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1255 { 1256 onActivateCursorItemListeners ~= new OnActivateCursorItemDelegateWrapper(dlg, 0, connectFlags); 1257 onActivateCursorItemListeners[onActivateCursorItemListeners.length - 1].handlerId = Signals.connectData( 1258 this, 1259 "activate-cursor-item", 1260 cast(GCallback)&callBackActivateCursorItem, 1261 cast(void*)onActivateCursorItemListeners[onActivateCursorItemListeners.length - 1], 1262 cast(GClosureNotify)&callBackActivateCursorItemDestroy, 1263 connectFlags); 1264 return onActivateCursorItemListeners[onActivateCursorItemListeners.length - 1].handlerId; 1265 } 1266 1267 extern(C) static int callBackActivateCursorItem(GtkIconView* iconviewStruct,OnActivateCursorItemDelegateWrapper wrapper) 1268 { 1269 return wrapper.dlg(wrapper.outer); 1270 } 1271 1272 extern(C) static void callBackActivateCursorItemDestroy(OnActivateCursorItemDelegateWrapper wrapper, GClosure* closure) 1273 { 1274 wrapper.outer.internalRemoveOnActivateCursorItem(wrapper); 1275 } 1276 1277 protected void internalRemoveOnActivateCursorItem(OnActivateCursorItemDelegateWrapper source) 1278 { 1279 foreach(index, wrapper; onActivateCursorItemListeners) 1280 { 1281 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1282 { 1283 onActivateCursorItemListeners[index] = null; 1284 onActivateCursorItemListeners = std.algorithm.remove(onActivateCursorItemListeners, index); 1285 break; 1286 } 1287 } 1288 } 1289 1290 1291 protected class OnItemActivatedDelegateWrapper 1292 { 1293 void delegate(TreePath, IconView) dlg; 1294 gulong handlerId; 1295 ConnectFlags flags; 1296 this(void delegate(TreePath, IconView) dlg, gulong handlerId, ConnectFlags flags) 1297 { 1298 this.dlg = dlg; 1299 this.handlerId = handlerId; 1300 this.flags = flags; 1301 } 1302 } 1303 protected OnItemActivatedDelegateWrapper[] onItemActivatedListeners; 1304 1305 /** 1306 * The ::item-activated signal is emitted when the method 1307 * gtk_icon_view_item_activated() is called, when the user double 1308 * clicks an item with the "activate-on-single-click" property set 1309 * to %FALSE, or when the user single clicks an item when the 1310 * "activate-on-single-click" property set to %TRUE. It is also 1311 * emitted when a non-editable item is selected and one of the keys: 1312 * Space, Return or Enter is pressed. 1313 * 1314 * Params: 1315 * path = the #GtkTreePath for the activated item 1316 */ 1317 gulong addOnItemActivated(void delegate(TreePath, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1318 { 1319 onItemActivatedListeners ~= new OnItemActivatedDelegateWrapper(dlg, 0, connectFlags); 1320 onItemActivatedListeners[onItemActivatedListeners.length - 1].handlerId = Signals.connectData( 1321 this, 1322 "item-activated", 1323 cast(GCallback)&callBackItemActivated, 1324 cast(void*)onItemActivatedListeners[onItemActivatedListeners.length - 1], 1325 cast(GClosureNotify)&callBackItemActivatedDestroy, 1326 connectFlags); 1327 return onItemActivatedListeners[onItemActivatedListeners.length - 1].handlerId; 1328 } 1329 1330 extern(C) static void callBackItemActivated(GtkIconView* iconviewStruct, GtkTreePath* path,OnItemActivatedDelegateWrapper wrapper) 1331 { 1332 wrapper.dlg(ObjectG.getDObject!(TreePath)(path), wrapper.outer); 1333 } 1334 1335 extern(C) static void callBackItemActivatedDestroy(OnItemActivatedDelegateWrapper wrapper, GClosure* closure) 1336 { 1337 wrapper.outer.internalRemoveOnItemActivated(wrapper); 1338 } 1339 1340 protected void internalRemoveOnItemActivated(OnItemActivatedDelegateWrapper source) 1341 { 1342 foreach(index, wrapper; onItemActivatedListeners) 1343 { 1344 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1345 { 1346 onItemActivatedListeners[index] = null; 1347 onItemActivatedListeners = std.algorithm.remove(onItemActivatedListeners, index); 1348 break; 1349 } 1350 } 1351 } 1352 1353 1354 protected class OnMoveCursorDelegateWrapper 1355 { 1356 bool delegate(GtkMovementStep, int, IconView) dlg; 1357 gulong handlerId; 1358 ConnectFlags flags; 1359 this(bool delegate(GtkMovementStep, int, IconView) dlg, gulong handlerId, ConnectFlags flags) 1360 { 1361 this.dlg = dlg; 1362 this.handlerId = handlerId; 1363 this.flags = flags; 1364 } 1365 } 1366 protected OnMoveCursorDelegateWrapper[] onMoveCursorListeners; 1367 1368 /** 1369 * The ::move-cursor signal is a 1370 * [keybinding signal][GtkBindingSignal] 1371 * which gets emitted when the user initiates a cursor movement. 1372 * 1373 * Applications should not connect to it, but may emit it with 1374 * g_signal_emit_by_name() if they need to control the cursor 1375 * programmatically. 1376 * 1377 * The default bindings for this signal include 1378 * - Arrow keys which move by individual steps 1379 * - Home/End keys which move to the first/last item 1380 * - PageUp/PageDown which move by "pages" 1381 * All of these will extend the selection when combined with 1382 * the Shift modifier. 1383 * 1384 * Params: 1385 * step = the granularity of the move, as a #GtkMovementStep 1386 * count = the number of @step units to move 1387 */ 1388 gulong addOnMoveCursor(bool delegate(GtkMovementStep, int, IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1389 { 1390 onMoveCursorListeners ~= new OnMoveCursorDelegateWrapper(dlg, 0, connectFlags); 1391 onMoveCursorListeners[onMoveCursorListeners.length - 1].handlerId = Signals.connectData( 1392 this, 1393 "move-cursor", 1394 cast(GCallback)&callBackMoveCursor, 1395 cast(void*)onMoveCursorListeners[onMoveCursorListeners.length - 1], 1396 cast(GClosureNotify)&callBackMoveCursorDestroy, 1397 connectFlags); 1398 return onMoveCursorListeners[onMoveCursorListeners.length - 1].handlerId; 1399 } 1400 1401 extern(C) static int callBackMoveCursor(GtkIconView* iconviewStruct, GtkMovementStep step, int count,OnMoveCursorDelegateWrapper wrapper) 1402 { 1403 return wrapper.dlg(step, count, wrapper.outer); 1404 } 1405 1406 extern(C) static void callBackMoveCursorDestroy(OnMoveCursorDelegateWrapper wrapper, GClosure* closure) 1407 { 1408 wrapper.outer.internalRemoveOnMoveCursor(wrapper); 1409 } 1410 1411 protected void internalRemoveOnMoveCursor(OnMoveCursorDelegateWrapper source) 1412 { 1413 foreach(index, wrapper; onMoveCursorListeners) 1414 { 1415 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1416 { 1417 onMoveCursorListeners[index] = null; 1418 onMoveCursorListeners = std.algorithm.remove(onMoveCursorListeners, index); 1419 break; 1420 } 1421 } 1422 } 1423 1424 1425 protected class OnSelectAllDelegateWrapper 1426 { 1427 void delegate(IconView) dlg; 1428 gulong handlerId; 1429 ConnectFlags flags; 1430 this(void delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1431 { 1432 this.dlg = dlg; 1433 this.handlerId = handlerId; 1434 this.flags = flags; 1435 } 1436 } 1437 protected OnSelectAllDelegateWrapper[] onSelectAllListeners; 1438 1439 /** 1440 * A [keybinding signal][GtkBindingSignal] 1441 * which gets emitted when the user selects all items. 1442 * 1443 * Applications should not connect to it, but may emit it with 1444 * g_signal_emit_by_name() if they need to control selection 1445 * programmatically. 1446 * 1447 * The default binding for this signal is Ctrl-a. 1448 */ 1449 gulong addOnSelectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1450 { 1451 onSelectAllListeners ~= new OnSelectAllDelegateWrapper(dlg, 0, connectFlags); 1452 onSelectAllListeners[onSelectAllListeners.length - 1].handlerId = Signals.connectData( 1453 this, 1454 "select-all", 1455 cast(GCallback)&callBackSelectAll, 1456 cast(void*)onSelectAllListeners[onSelectAllListeners.length - 1], 1457 cast(GClosureNotify)&callBackSelectAllDestroy, 1458 connectFlags); 1459 return onSelectAllListeners[onSelectAllListeners.length - 1].handlerId; 1460 } 1461 1462 extern(C) static void callBackSelectAll(GtkIconView* iconviewStruct,OnSelectAllDelegateWrapper wrapper) 1463 { 1464 wrapper.dlg(wrapper.outer); 1465 } 1466 1467 extern(C) static void callBackSelectAllDestroy(OnSelectAllDelegateWrapper wrapper, GClosure* closure) 1468 { 1469 wrapper.outer.internalRemoveOnSelectAll(wrapper); 1470 } 1471 1472 protected void internalRemoveOnSelectAll(OnSelectAllDelegateWrapper source) 1473 { 1474 foreach(index, wrapper; onSelectAllListeners) 1475 { 1476 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1477 { 1478 onSelectAllListeners[index] = null; 1479 onSelectAllListeners = std.algorithm.remove(onSelectAllListeners, index); 1480 break; 1481 } 1482 } 1483 } 1484 1485 1486 protected class OnSelectCursorItemDelegateWrapper 1487 { 1488 void delegate(IconView) dlg; 1489 gulong handlerId; 1490 ConnectFlags flags; 1491 this(void delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1492 { 1493 this.dlg = dlg; 1494 this.handlerId = handlerId; 1495 this.flags = flags; 1496 } 1497 } 1498 protected OnSelectCursorItemDelegateWrapper[] onSelectCursorItemListeners; 1499 1500 /** 1501 * A [keybinding signal][GtkBindingSignal] 1502 * which gets emitted when the user selects the item that is currently 1503 * focused. 1504 * 1505 * Applications should not connect to it, but may emit it with 1506 * g_signal_emit_by_name() if they need to control selection 1507 * programmatically. 1508 * 1509 * There is no default binding for this signal. 1510 */ 1511 gulong addOnSelectCursorItem(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1512 { 1513 onSelectCursorItemListeners ~= new OnSelectCursorItemDelegateWrapper(dlg, 0, connectFlags); 1514 onSelectCursorItemListeners[onSelectCursorItemListeners.length - 1].handlerId = Signals.connectData( 1515 this, 1516 "select-cursor-item", 1517 cast(GCallback)&callBackSelectCursorItem, 1518 cast(void*)onSelectCursorItemListeners[onSelectCursorItemListeners.length - 1], 1519 cast(GClosureNotify)&callBackSelectCursorItemDestroy, 1520 connectFlags); 1521 return onSelectCursorItemListeners[onSelectCursorItemListeners.length - 1].handlerId; 1522 } 1523 1524 extern(C) static void callBackSelectCursorItem(GtkIconView* iconviewStruct,OnSelectCursorItemDelegateWrapper wrapper) 1525 { 1526 wrapper.dlg(wrapper.outer); 1527 } 1528 1529 extern(C) static void callBackSelectCursorItemDestroy(OnSelectCursorItemDelegateWrapper wrapper, GClosure* closure) 1530 { 1531 wrapper.outer.internalRemoveOnSelectCursorItem(wrapper); 1532 } 1533 1534 protected void internalRemoveOnSelectCursorItem(OnSelectCursorItemDelegateWrapper source) 1535 { 1536 foreach(index, wrapper; onSelectCursorItemListeners) 1537 { 1538 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1539 { 1540 onSelectCursorItemListeners[index] = null; 1541 onSelectCursorItemListeners = std.algorithm.remove(onSelectCursorItemListeners, index); 1542 break; 1543 } 1544 } 1545 } 1546 1547 1548 protected class OnSelectionChangedDelegateWrapper 1549 { 1550 void delegate(IconView) dlg; 1551 gulong handlerId; 1552 ConnectFlags flags; 1553 this(void delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1554 { 1555 this.dlg = dlg; 1556 this.handlerId = handlerId; 1557 this.flags = flags; 1558 } 1559 } 1560 protected OnSelectionChangedDelegateWrapper[] onSelectionChangedListeners; 1561 1562 /** 1563 * The ::selection-changed signal is emitted when the selection 1564 * (i.e. the set of selected items) changes. 1565 */ 1566 gulong addOnSelectionChanged(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1567 { 1568 onSelectionChangedListeners ~= new OnSelectionChangedDelegateWrapper(dlg, 0, connectFlags); 1569 onSelectionChangedListeners[onSelectionChangedListeners.length - 1].handlerId = Signals.connectData( 1570 this, 1571 "selection-changed", 1572 cast(GCallback)&callBackSelectionChanged, 1573 cast(void*)onSelectionChangedListeners[onSelectionChangedListeners.length - 1], 1574 cast(GClosureNotify)&callBackSelectionChangedDestroy, 1575 connectFlags); 1576 return onSelectionChangedListeners[onSelectionChangedListeners.length - 1].handlerId; 1577 } 1578 1579 extern(C) static void callBackSelectionChanged(GtkIconView* iconviewStruct,OnSelectionChangedDelegateWrapper wrapper) 1580 { 1581 wrapper.dlg(wrapper.outer); 1582 } 1583 1584 extern(C) static void callBackSelectionChangedDestroy(OnSelectionChangedDelegateWrapper wrapper, GClosure* closure) 1585 { 1586 wrapper.outer.internalRemoveOnSelectionChanged(wrapper); 1587 } 1588 1589 protected void internalRemoveOnSelectionChanged(OnSelectionChangedDelegateWrapper source) 1590 { 1591 foreach(index, wrapper; onSelectionChangedListeners) 1592 { 1593 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1594 { 1595 onSelectionChangedListeners[index] = null; 1596 onSelectionChangedListeners = std.algorithm.remove(onSelectionChangedListeners, index); 1597 break; 1598 } 1599 } 1600 } 1601 1602 1603 protected class OnToggleCursorItemDelegateWrapper 1604 { 1605 void delegate(IconView) dlg; 1606 gulong handlerId; 1607 ConnectFlags flags; 1608 this(void delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1609 { 1610 this.dlg = dlg; 1611 this.handlerId = handlerId; 1612 this.flags = flags; 1613 } 1614 } 1615 protected 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 onToggleCursorItemListeners ~= new OnToggleCursorItemDelegateWrapper(dlg, 0, connectFlags); 1632 onToggleCursorItemListeners[onToggleCursorItemListeners.length - 1].handlerId = Signals.connectData( 1633 this, 1634 "toggle-cursor-item", 1635 cast(GCallback)&callBackToggleCursorItem, 1636 cast(void*)onToggleCursorItemListeners[onToggleCursorItemListeners.length - 1], 1637 cast(GClosureNotify)&callBackToggleCursorItemDestroy, 1638 connectFlags); 1639 return onToggleCursorItemListeners[onToggleCursorItemListeners.length - 1].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.outer.internalRemoveOnToggleCursorItem(wrapper); 1650 } 1651 1652 protected void internalRemoveOnToggleCursorItem(OnToggleCursorItemDelegateWrapper source) 1653 { 1654 foreach(index, wrapper; onToggleCursorItemListeners) 1655 { 1656 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1657 { 1658 onToggleCursorItemListeners[index] = null; 1659 onToggleCursorItemListeners = std.algorithm.remove(onToggleCursorItemListeners, index); 1660 break; 1661 } 1662 } 1663 } 1664 1665 1666 protected class OnUnselectAllDelegateWrapper 1667 { 1668 void delegate(IconView) dlg; 1669 gulong handlerId; 1670 ConnectFlags flags; 1671 this(void delegate(IconView) dlg, gulong handlerId, ConnectFlags flags) 1672 { 1673 this.dlg = dlg; 1674 this.handlerId = handlerId; 1675 this.flags = flags; 1676 } 1677 } 1678 protected OnUnselectAllDelegateWrapper[] onUnselectAllListeners; 1679 1680 /** 1681 * A [keybinding signal][GtkBindingSignal] 1682 * which gets emitted when the user unselects all items. 1683 * 1684 * Applications should not connect to it, but may emit it with 1685 * g_signal_emit_by_name() if they need to control selection 1686 * programmatically. 1687 * 1688 * The default binding for this signal is Ctrl-Shift-a. 1689 */ 1690 gulong addOnUnselectAll(void delegate(IconView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1691 { 1692 onUnselectAllListeners ~= new OnUnselectAllDelegateWrapper(dlg, 0, connectFlags); 1693 onUnselectAllListeners[onUnselectAllListeners.length - 1].handlerId = Signals.connectData( 1694 this, 1695 "unselect-all", 1696 cast(GCallback)&callBackUnselectAll, 1697 cast(void*)onUnselectAllListeners[onUnselectAllListeners.length - 1], 1698 cast(GClosureNotify)&callBackUnselectAllDestroy, 1699 connectFlags); 1700 return onUnselectAllListeners[onUnselectAllListeners.length - 1].handlerId; 1701 } 1702 1703 extern(C) static void callBackUnselectAll(GtkIconView* iconviewStruct,OnUnselectAllDelegateWrapper wrapper) 1704 { 1705 wrapper.dlg(wrapper.outer); 1706 } 1707 1708 extern(C) static void callBackUnselectAllDestroy(OnUnselectAllDelegateWrapper wrapper, GClosure* closure) 1709 { 1710 wrapper.outer.internalRemoveOnUnselectAll(wrapper); 1711 } 1712 1713 protected void internalRemoveOnUnselectAll(OnUnselectAllDelegateWrapper source) 1714 { 1715 foreach(index, wrapper; onUnselectAllListeners) 1716 { 1717 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1718 { 1719 onUnselectAllListeners[index] = null; 1720 onUnselectAllListeners = std.algorithm.remove(onUnselectAllListeners, index); 1721 break; 1722 } 1723 } 1724 } 1725 1726 }