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.TreeViewColumn; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.BuildableIF; 32 private import gtk.BuildableT; 33 private import gtk.Button; 34 private import gtk.CellArea; 35 private import gtk.CellLayoutIF; 36 private import gtk.CellLayoutT; 37 private import gtk.CellRenderer; 38 private import gtk.TreeIter; 39 private import gtk.TreeModelIF; 40 private import gtk.TreeView; 41 private import gtk.Widget; 42 private import gtkc.gtk; 43 public import gtkc.gtktypes; 44 private import std.algorithm; 45 46 47 /** 48 * The GtkTreeViewColumn object represents a visible column in a #GtkTreeView widget. 49 * It allows to set properties of the column header, and functions as a holding pen for 50 * the cell renderers which determine how the data in the column is displayed. 51 * 52 * Please refer to the [tree widget conceptual overview][TreeWidget] 53 * for an overview of all the objects and data types related to the tree widget and how 54 * they work together. 55 */ 56 public class TreeViewColumn : ObjectG, BuildableIF, CellLayoutIF 57 { 58 /** the main Gtk struct */ 59 protected GtkTreeViewColumn* gtkTreeViewColumn; 60 61 /** Get the main Gtk struct */ 62 public GtkTreeViewColumn* getTreeViewColumnStruct(bool transferOwnership = false) 63 { 64 if (transferOwnership) 65 ownedRef = false; 66 return gtkTreeViewColumn; 67 } 68 69 /** the main Gtk struct as a void* */ 70 protected override void* getStruct() 71 { 72 return cast(void*)gtkTreeViewColumn; 73 } 74 75 protected override void setStruct(GObject* obj) 76 { 77 gtkTreeViewColumn = cast(GtkTreeViewColumn*)obj; 78 super.setStruct(obj); 79 } 80 81 /** 82 * Sets our main struct and passes it to the parent class. 83 */ 84 public this (GtkTreeViewColumn* gtkTreeViewColumn, bool ownedRef = false) 85 { 86 this.gtkTreeViewColumn = gtkTreeViewColumn; 87 super(cast(GObject*)gtkTreeViewColumn, ownedRef); 88 } 89 90 // add the Buildable capabilities 91 mixin BuildableT!(GtkTreeViewColumn); 92 93 // add the CellLayout capabilities 94 mixin CellLayoutT!(GtkTreeViewColumn); 95 96 /** 97 * Creates a new Tree view column 98 * Params: 99 * header = th column header text 100 * renderer = the rederer for the column cells 101 * type = the type of data to be displayed (shouldn't this be on the renderer?) 102 * column = the column number 103 * Throws: ConstructionException GTK+ fails to create the object. 104 */ 105 this(string header, CellRenderer renderer, string type, int column) 106 { 107 auto p = gtk_tree_view_column_new_with_attributes( 108 Str.toStringz(header), 109 renderer.getCellRendererStruct(), 110 Str.toStringz(type), 111 column, 112 null); 113 114 if(p is null) 115 { 116 throw new ConstructionException("null returned by gtk_tree_view_column_new_with_attributes"); 117 } 118 119 this(p); 120 } 121 122 /** 123 * Returns the button used in the treeview column header 124 * Returns: The button for the column header. [transfer none] Since 3.0 125 */ 126 public Button getButton() 127 { 128 // GtkWidget * gtk_tree_view_column_get_button (GtkTreeViewColumn *tree_column); 129 auto p = gtk_tree_view_column_get_button(gtkTreeViewColumn); 130 if(p is null) 131 { 132 return null; 133 } 134 return new Button(cast(GtkButton*) p); 135 } 136 137 /** 138 * Returns the GtkTreeView wherein tree_column has been inserted. 139 * If column is currently not inserted in any tree view, NULL is 140 * returned. 141 * Since 2.12 142 * Returns: The tree view wherein column has been inserted if any, NULL otherwise. [transfer none] 143 */ 144 public TreeView getTreeView() 145 { 146 // GtkWidget * gtk_tree_view_column_get_tree_view (GtkTreeViewColumn *tree_column); 147 auto p = gtk_tree_view_column_get_tree_view(gtkTreeViewColumn); 148 if(p is null) 149 { 150 return null; 151 } 152 return new TreeView(cast(GtkTreeView*) p); 153 } 154 155 /** 156 */ 157 158 /** */ 159 public static GType getType() 160 { 161 return gtk_tree_view_column_get_type(); 162 } 163 164 /** 165 * Creates a new #GtkTreeViewColumn. 166 * 167 * Returns: A newly created #GtkTreeViewColumn. 168 * 169 * Throws: ConstructionException GTK+ fails to create the object. 170 */ 171 public this() 172 { 173 auto p = gtk_tree_view_column_new(); 174 175 if(p is null) 176 { 177 throw new ConstructionException("null returned by new"); 178 } 179 180 this(cast(GtkTreeViewColumn*) p); 181 } 182 183 /** 184 * Creates a new #GtkTreeViewColumn using @area to render its cells. 185 * 186 * Params: 187 * area = the #GtkCellArea that the newly created column should use to layout cells. 188 * 189 * Returns: A newly created #GtkTreeViewColumn. 190 * 191 * Since: 3.0 192 * 193 * Throws: ConstructionException GTK+ fails to create the object. 194 */ 195 public this(CellArea area) 196 { 197 auto p = gtk_tree_view_column_new_with_area((area is null) ? null : area.getCellAreaStruct()); 198 199 if(p is null) 200 { 201 throw new ConstructionException("null returned by new_with_area"); 202 } 203 204 this(cast(GtkTreeViewColumn*) p); 205 } 206 207 /** 208 * Obtains the horizontal position and size of a cell in a column. If the 209 * cell is not found in the column, @start_pos and @width are not changed and 210 * %FALSE is returned. 211 * 212 * Params: 213 * cellRenderer = a #GtkCellRenderer 214 * xOffset = return location for the horizontal 215 * position of @cell within @tree_column, may be %NULL 216 * width = return location for the width of @cell, 217 * may be %NULL 218 * 219 * Returns: %TRUE if @cell belongs to @tree_column. 220 */ 221 public bool cellGetPosition(CellRenderer cellRenderer, out int xOffset, out int width) 222 { 223 return gtk_tree_view_column_cell_get_position(gtkTreeViewColumn, (cellRenderer is null) ? null : cellRenderer.getCellRendererStruct(), &xOffset, &width) != 0; 224 } 225 226 /** 227 * Obtains the width and height needed to render the column. This is used 228 * primarily by the #GtkTreeView. 229 * 230 * Params: 231 * cellArea = The area a cell in the column will be allocated, or %NULL 232 * xOffset = location to return x offset of a cell relative to @cell_area, or %NULL 233 * yOffset = location to return y offset of a cell relative to @cell_area, or %NULL 234 * width = location to return width needed to render a cell, or %NULL 235 * height = location to return height needed to render a cell, or %NULL 236 */ 237 public void cellGetSize(GdkRectangle* cellArea, out int xOffset, out int yOffset, out int width, out int height) 238 { 239 gtk_tree_view_column_cell_get_size(gtkTreeViewColumn, cellArea, &xOffset, &yOffset, &width, &height); 240 } 241 242 /** 243 * Returns %TRUE if any of the cells packed into the @tree_column are visible. 244 * For this to be meaningful, you must first initialize the cells with 245 * gtk_tree_view_column_cell_set_cell_data() 246 * 247 * Returns: %TRUE, if any of the cells packed into the @tree_column are currently visible 248 */ 249 public bool cellIsVisible() 250 { 251 return gtk_tree_view_column_cell_is_visible(gtkTreeViewColumn) != 0; 252 } 253 254 /** 255 * Sets the cell renderer based on the @tree_model and @iter. That is, for 256 * every attribute mapping in @tree_column, it will get a value from the set 257 * column on the @iter, and use that value to set the attribute on the cell 258 * renderer. This is used primarily by the #GtkTreeView. 259 * 260 * Params: 261 * treeModel = The #GtkTreeModel to to get the cell renderers attributes from. 262 * iter = The #GtkTreeIter to to get the cell renderer’s attributes from. 263 * isExpander = %TRUE, if the row has children 264 * isExpanded = %TRUE, if the row has visible children 265 */ 266 public void cellSetCellData(TreeModelIF treeModel, TreeIter iter, bool isExpander, bool isExpanded) 267 { 268 gtk_tree_view_column_cell_set_cell_data(gtkTreeViewColumn, (treeModel is null) ? null : treeModel.getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), isExpander, isExpanded); 269 } 270 271 /** 272 * Emits the “clicked” signal on the column. This function will only work if 273 * @tree_column is clickable. 274 */ 275 public void clicked() 276 { 277 gtk_tree_view_column_clicked(gtkTreeViewColumn); 278 } 279 280 /** 281 * Sets the current keyboard focus to be at @cell, if the column contains 282 * 2 or more editable and activatable cells. 283 * 284 * Params: 285 * cell = A #GtkCellRenderer 286 * 287 * Since: 2.2 288 */ 289 public void focusCell(CellRenderer cell) 290 { 291 gtk_tree_view_column_focus_cell(gtkTreeViewColumn, (cell is null) ? null : cell.getCellRendererStruct()); 292 } 293 294 /** 295 * Returns the current x alignment of @tree_column. This value can range 296 * between 0.0 and 1.0. 297 * 298 * Returns: The current alignent of @tree_column. 299 */ 300 public float getAlignment() 301 { 302 return gtk_tree_view_column_get_alignment(gtkTreeViewColumn); 303 } 304 305 /** 306 * Returns %TRUE if the user can click on the header for the column. 307 * 308 * Returns: %TRUE if user can click the column header. 309 */ 310 public bool getClickable() 311 { 312 return gtk_tree_view_column_get_clickable(gtkTreeViewColumn) != 0; 313 } 314 315 /** 316 * Returns %TRUE if the column expands to fill available space. 317 * 318 * Returns: %TRUE if the column expands to fill available space. 319 * 320 * Since: 2.4 321 */ 322 public bool getExpand() 323 { 324 return gtk_tree_view_column_get_expand(gtkTreeViewColumn) != 0; 325 } 326 327 /** 328 * Gets the fixed width of the column. This may not be the actual displayed 329 * width of the column; for that, use gtk_tree_view_column_get_width(). 330 * 331 * Returns: The fixed width of the column. 332 */ 333 public int getFixedWidth() 334 { 335 return gtk_tree_view_column_get_fixed_width(gtkTreeViewColumn); 336 } 337 338 /** 339 * Returns the maximum width in pixels of the @tree_column, or -1 if no maximum 340 * width is set. 341 * 342 * Returns: The maximum width of the @tree_column. 343 */ 344 public int getMaxWidth() 345 { 346 return gtk_tree_view_column_get_max_width(gtkTreeViewColumn); 347 } 348 349 /** 350 * Returns the minimum width in pixels of the @tree_column, or -1 if no minimum 351 * width is set. 352 * 353 * Returns: The minimum width of the @tree_column. 354 */ 355 public int getMinWidth() 356 { 357 return gtk_tree_view_column_get_min_width(gtkTreeViewColumn); 358 } 359 360 /** 361 * Returns %TRUE if the @tree_column can be reordered by the user. 362 * 363 * Returns: %TRUE if the @tree_column can be reordered by the user. 364 */ 365 public bool getReorderable() 366 { 367 return gtk_tree_view_column_get_reorderable(gtkTreeViewColumn) != 0; 368 } 369 370 /** 371 * Returns %TRUE if the @tree_column can be resized by the end user. 372 * 373 * Returns: %TRUE, if the @tree_column can be resized. 374 */ 375 public bool getResizable() 376 { 377 return gtk_tree_view_column_get_resizable(gtkTreeViewColumn) != 0; 378 } 379 380 /** 381 * Returns the current type of @tree_column. 382 * 383 * Returns: The type of @tree_column. 384 */ 385 public GtkTreeViewColumnSizing getSizing() 386 { 387 return gtk_tree_view_column_get_sizing(gtkTreeViewColumn); 388 } 389 390 /** 391 * Gets the logical @sort_column_id that the model sorts on when this 392 * column is selected for sorting. 393 * See gtk_tree_view_column_set_sort_column_id(). 394 * 395 * Returns: the current @sort_column_id for this column, or -1 if 396 * this column can’t be used for sorting. 397 */ 398 public int getSortColumnId() 399 { 400 return gtk_tree_view_column_get_sort_column_id(gtkTreeViewColumn); 401 } 402 403 /** 404 * Gets the value set by gtk_tree_view_column_set_sort_indicator(). 405 * 406 * Returns: whether the sort indicator arrow is displayed 407 */ 408 public bool getSortIndicator() 409 { 410 return gtk_tree_view_column_get_sort_indicator(gtkTreeViewColumn) != 0; 411 } 412 413 /** 414 * Gets the value set by gtk_tree_view_column_set_sort_order(). 415 * 416 * Returns: the sort order the sort indicator is indicating 417 */ 418 public GtkSortType getSortOrder() 419 { 420 return gtk_tree_view_column_get_sort_order(gtkTreeViewColumn); 421 } 422 423 /** 424 * Returns the spacing of @tree_column. 425 * 426 * Returns: the spacing of @tree_column. 427 */ 428 public int getSpacing() 429 { 430 return gtk_tree_view_column_get_spacing(gtkTreeViewColumn); 431 } 432 433 /** 434 * Returns the title of the widget. 435 * 436 * Returns: the title of the column. This string should not be 437 * modified or freed. 438 */ 439 public string getTitle() 440 { 441 return Str.toString(gtk_tree_view_column_get_title(gtkTreeViewColumn)); 442 } 443 444 /** 445 * Returns %TRUE if @tree_column is visible. 446 * 447 * Returns: whether the column is visible or not. If it is visible, then 448 * the tree will show the column. 449 */ 450 public bool getVisible() 451 { 452 return gtk_tree_view_column_get_visible(gtkTreeViewColumn) != 0; 453 } 454 455 /** 456 * Returns the #GtkWidget in the button on the column header. 457 * If a custom widget has not been set then %NULL is returned. 458 * 459 * Returns: The #GtkWidget in the column 460 * header, or %NULL 461 */ 462 public Widget getWidget() 463 { 464 auto p = gtk_tree_view_column_get_widget(gtkTreeViewColumn); 465 466 if(p is null) 467 { 468 return null; 469 } 470 471 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 472 } 473 474 /** 475 * Returns the current size of @tree_column in pixels. 476 * 477 * Returns: The current width of @tree_column. 478 */ 479 public int getWidth() 480 { 481 return gtk_tree_view_column_get_width(gtkTreeViewColumn); 482 } 483 484 /** 485 * Returns the current X offset of @tree_column in pixels. 486 * 487 * Returns: The current X offset of @tree_column. 488 * 489 * Since: 3.2 490 */ 491 public int getXOffset() 492 { 493 return gtk_tree_view_column_get_x_offset(gtkTreeViewColumn); 494 } 495 496 /** 497 * Flags the column, and the cell renderers added to this column, to have 498 * their sizes renegotiated. 499 * 500 * Since: 2.8 501 */ 502 public void queueResize() 503 { 504 gtk_tree_view_column_queue_resize(gtkTreeViewColumn); 505 } 506 507 /** 508 * Sets the alignment of the title or custom widget inside the column header. 509 * The alignment determines its location inside the button -- 0.0 for left, 0.5 510 * for center, 1.0 for right. 511 * 512 * Params: 513 * xalign = The alignment, which is between [0.0 and 1.0] inclusive. 514 */ 515 public void setAlignment(float xalign) 516 { 517 gtk_tree_view_column_set_alignment(gtkTreeViewColumn, xalign); 518 } 519 520 /** 521 * Sets the #GtkTreeCellDataFunc to use for the column. This 522 * function is used instead of the standard attributes mapping for 523 * setting the column value, and should set the value of @tree_column's 524 * cell renderer as appropriate. @func may be %NULL to remove an 525 * older one. 526 * 527 * Params: 528 * cellRenderer = A #GtkCellRenderer 529 * func = The #GtkTreeCellDataFunc to use. 530 * funcData = The user data for @func. 531 * destroy = The destroy notification for @func_data 532 */ 533 public void setCellDataFunc(CellRenderer cellRenderer, GtkTreeCellDataFunc func, void* funcData, GDestroyNotify destroy) 534 { 535 gtk_tree_view_column_set_cell_data_func(gtkTreeViewColumn, (cellRenderer is null) ? null : cellRenderer.getCellRendererStruct(), func, funcData, destroy); 536 } 537 538 /** 539 * Sets the header to be active if @clickable is %TRUE. When the header is 540 * active, then it can take keyboard focus, and can be clicked. 541 * 542 * Params: 543 * clickable = %TRUE if the header is active. 544 */ 545 public void setClickable(bool clickable) 546 { 547 gtk_tree_view_column_set_clickable(gtkTreeViewColumn, clickable); 548 } 549 550 /** 551 * Sets the column to take available extra space. This space is shared equally 552 * amongst all columns that have the expand set to %TRUE. If no column has this 553 * option set, then the last column gets all extra space. By default, every 554 * column is created with this %FALSE. 555 * 556 * Along with “fixed-width”, the “expand” property changes when the column is 557 * resized by the user. 558 * 559 * Params: 560 * expand = %TRUE if the column should expand to fill available space. 561 * 562 * Since: 2.4 563 */ 564 public void setExpand(bool expand) 565 { 566 gtk_tree_view_column_set_expand(gtkTreeViewColumn, expand); 567 } 568 569 /** 570 * If @fixed_width is not -1, sets the fixed width of @tree_column; otherwise 571 * unsets it. The effective value of @fixed_width is clamped between the 572 * minimum and maximum width of the column; however, the value stored in the 573 * “fixed-width” property is not clamped. If the column sizing is 574 * #GTK_TREE_VIEW_COLUMN_GROW_ONLY or #GTK_TREE_VIEW_COLUMN_AUTOSIZE, setting 575 * a fixed width overrides the automatically calculated width. Note that 576 * @fixed_width is only a hint to GTK+; the width actually allocated to the 577 * column may be greater or less than requested. 578 * 579 * Along with “expand”, the “fixed-width” property changes when the column is 580 * resized by the user. 581 * 582 * Params: 583 * fixedWidth = The new fixed width, in pixels, or -1. 584 */ 585 public void setFixedWidth(int fixedWidth) 586 { 587 gtk_tree_view_column_set_fixed_width(gtkTreeViewColumn, fixedWidth); 588 } 589 590 /** 591 * Sets the maximum width of the @tree_column. If @max_width is -1, then the 592 * maximum width is unset. Note, the column can actually be wider than max 593 * width if it’s the last column in a view. In this case, the column expands to 594 * fill any extra space. 595 * 596 * Params: 597 * maxWidth = The maximum width of the column in pixels, or -1. 598 */ 599 public void setMaxWidth(int maxWidth) 600 { 601 gtk_tree_view_column_set_max_width(gtkTreeViewColumn, maxWidth); 602 } 603 604 /** 605 * Sets the minimum width of the @tree_column. If @min_width is -1, then the 606 * minimum width is unset. 607 * 608 * Params: 609 * minWidth = The minimum width of the column in pixels, or -1. 610 */ 611 public void setMinWidth(int minWidth) 612 { 613 gtk_tree_view_column_set_min_width(gtkTreeViewColumn, minWidth); 614 } 615 616 /** 617 * If @reorderable is %TRUE, then the column can be reordered by the end user 618 * dragging the header. 619 * 620 * Params: 621 * reorderable = %TRUE, if the column can be reordered. 622 */ 623 public void setReorderable(bool reorderable) 624 { 625 gtk_tree_view_column_set_reorderable(gtkTreeViewColumn, reorderable); 626 } 627 628 /** 629 * If @resizable is %TRUE, then the user can explicitly resize the column by 630 * grabbing the outer edge of the column button. If resizable is %TRUE and 631 * sizing mode of the column is #GTK_TREE_VIEW_COLUMN_AUTOSIZE, then the sizing 632 * mode is changed to #GTK_TREE_VIEW_COLUMN_GROW_ONLY. 633 * 634 * Params: 635 * resizable = %TRUE, if the column can be resized 636 */ 637 public void setResizable(bool resizable) 638 { 639 gtk_tree_view_column_set_resizable(gtkTreeViewColumn, resizable); 640 } 641 642 /** 643 * Sets the growth behavior of @tree_column to @type. 644 * 645 * Params: 646 * type = The #GtkTreeViewColumnSizing. 647 */ 648 public void setSizing(GtkTreeViewColumnSizing type) 649 { 650 gtk_tree_view_column_set_sizing(gtkTreeViewColumn, type); 651 } 652 653 /** 654 * Sets the logical @sort_column_id that this column sorts on when this column 655 * is selected for sorting. Doing so makes the column header clickable. 656 * 657 * Params: 658 * sortColumnId = The @sort_column_id of the model to sort on. 659 */ 660 public void setSortColumnId(int sortColumnId) 661 { 662 gtk_tree_view_column_set_sort_column_id(gtkTreeViewColumn, sortColumnId); 663 } 664 665 /** 666 * Call this function with a @setting of %TRUE to display an arrow in 667 * the header button indicating the column is sorted. Call 668 * gtk_tree_view_column_set_sort_order() to change the direction of 669 * the arrow. 670 * 671 * Params: 672 * setting = %TRUE to display an indicator that the column is sorted 673 */ 674 public void setSortIndicator(bool setting) 675 { 676 gtk_tree_view_column_set_sort_indicator(gtkTreeViewColumn, setting); 677 } 678 679 /** 680 * Changes the appearance of the sort indicator. 681 * 682 * This does not actually sort the model. Use 683 * gtk_tree_view_column_set_sort_column_id() if you want automatic sorting 684 * support. This function is primarily for custom sorting behavior, and should 685 * be used in conjunction with gtk_tree_sortable_set_sort_column_id() to do 686 * that. For custom models, the mechanism will vary. 687 * 688 * The sort indicator changes direction to indicate normal sort or reverse sort. 689 * Note that you must have the sort indicator enabled to see anything when 690 * calling this function; see gtk_tree_view_column_set_sort_indicator(). 691 * 692 * Params: 693 * order = sort order that the sort indicator should indicate 694 */ 695 public void setSortOrder(GtkSortType order) 696 { 697 gtk_tree_view_column_set_sort_order(gtkTreeViewColumn, order); 698 } 699 700 /** 701 * Sets the spacing field of @tree_column, which is the number of pixels to 702 * place between cell renderers packed into it. 703 * 704 * Params: 705 * spacing = distance between cell renderers in pixels. 706 */ 707 public void setSpacing(int spacing) 708 { 709 gtk_tree_view_column_set_spacing(gtkTreeViewColumn, spacing); 710 } 711 712 /** 713 * Sets the title of the @tree_column. If a custom widget has been set, then 714 * this value is ignored. 715 * 716 * Params: 717 * title = The title of the @tree_column. 718 */ 719 public void setTitle(string title) 720 { 721 gtk_tree_view_column_set_title(gtkTreeViewColumn, Str.toStringz(title)); 722 } 723 724 /** 725 * Sets the visibility of @tree_column. 726 * 727 * Params: 728 * visible = %TRUE if the @tree_column is visible. 729 */ 730 public void setVisible(bool visible) 731 { 732 gtk_tree_view_column_set_visible(gtkTreeViewColumn, visible); 733 } 734 735 /** 736 * Sets the widget in the header to be @widget. If widget is %NULL, then the 737 * header button is set with a #GtkLabel set to the title of @tree_column. 738 * 739 * Params: 740 * widget = A child #GtkWidget, or %NULL. 741 */ 742 public void setWidget(Widget widget) 743 { 744 gtk_tree_view_column_set_widget(gtkTreeViewColumn, (widget is null) ? null : widget.getWidgetStruct()); 745 } 746 747 protected class OnClickedDelegateWrapper 748 { 749 static OnClickedDelegateWrapper[] listeners; 750 void delegate(TreeViewColumn) dlg; 751 gulong handlerId; 752 753 this(void delegate(TreeViewColumn) dlg) 754 { 755 this.dlg = dlg; 756 this.listeners ~= this; 757 } 758 759 void remove(OnClickedDelegateWrapper source) 760 { 761 foreach(index, wrapper; listeners) 762 { 763 if (wrapper.handlerId == source.handlerId) 764 { 765 listeners[index] = null; 766 listeners = std.algorithm.remove(listeners, index); 767 break; 768 } 769 } 770 } 771 } 772 773 /** */ 774 gulong addOnClicked(void delegate(TreeViewColumn) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 775 { 776 auto wrapper = new OnClickedDelegateWrapper(dlg); 777 wrapper.handlerId = Signals.connectData( 778 this, 779 "clicked", 780 cast(GCallback)&callBackClicked, 781 cast(void*)wrapper, 782 cast(GClosureNotify)&callBackClickedDestroy, 783 connectFlags); 784 return wrapper.handlerId; 785 } 786 787 extern(C) static void callBackClicked(GtkTreeViewColumn* treeviewcolumnStruct, OnClickedDelegateWrapper wrapper) 788 { 789 wrapper.dlg(wrapper.outer); 790 } 791 792 extern(C) static void callBackClickedDestroy(OnClickedDelegateWrapper wrapper, GClosure* closure) 793 { 794 wrapper.remove(wrapper); 795 } 796 }