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