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