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