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