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.ComboBox; 26 27 private import atk.ObjectAtk; 28 private import gdk.Device; 29 private import glib.ConstructionException; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.Bin; 34 private import gtk.CellEditableIF; 35 private import gtk.CellEditableT; 36 private import gtk.CellLayoutIF; 37 private import gtk.CellLayoutT; 38 private import gtk.TreeIter; 39 private import gtk.TreeModel; 40 private import gtk.TreeModelIF; 41 public import gtkc.gdktypes; 42 private import gtkc.gtk; 43 public import gtkc.gtktypes; 44 45 46 /** 47 * A GtkComboBox is a widget that allows the user to choose from a list of 48 * valid choices. The GtkComboBox displays the selected choice. When 49 * activated, the GtkComboBox displays a popup which allows the user to 50 * make a new choice. The style in which the selected value is displayed, 51 * and the style of the popup is determined by the current theme. It may 52 * be similar to a Windows-style combo box. 53 * 54 * The GtkComboBox uses the model-view pattern; the list of valid choices 55 * is specified in the form of a tree model, and the display of the choices 56 * can be adapted to the data in the model by using cell renderers, as you 57 * would in a tree view. This is possible since GtkComboBox implements the 58 * #GtkCellLayout interface. The tree model holding the valid choices is 59 * not restricted to a flat list, it can be a real tree, and the popup will 60 * reflect the tree structure. 61 * 62 * To allow the user to enter values not in the model, the “has-entry” 63 * property allows the GtkComboBox to contain a #GtkEntry. This entry 64 * can be accessed by calling gtk_bin_get_child() on the combo box. 65 * 66 * For a simple list of textual choices, the model-view API of GtkComboBox 67 * can be a bit overwhelming. In this case, #GtkComboBoxText offers a 68 * simple alternative. Both GtkComboBox and #GtkComboBoxText can contain 69 * an entry. 70 * 71 * # CSS nodes 72 * 73 * |[<!-- language="plain" --> 74 * combobox 75 * ├── box.linked 76 * │ ╰── button.combo 77 * │ ╰── box 78 * │ ├── cellview 79 * │ ╰── arrow 80 * ╰── window.popup 81 * ]| 82 * 83 * A normal combobox contains a box with the .linked class, a button 84 * with the .combo class and inside those buttons, there are a cellview and 85 * an arrow. 86 * 87 * |[<!-- language="plain" --> 88 * combobox 89 * ├── box.linked 90 * │ ├── entry.combo 91 * │ ╰── button.combo 92 * │ ╰── box 93 * │ ╰── arrow 94 * ╰── window.popup 95 * ]| 96 * 97 * A GtkComboBox with an entry has a single CSS node with name combobox. It 98 * contains a bx with the .linked class and that box contains an entry and a 99 * button, both with the .combo class added. 100 * The button also contains another node with name arrow. 101 */ 102 public class ComboBox : Bin, CellEditableIF, CellLayoutIF 103 { 104 /** the main Gtk struct */ 105 protected GtkComboBox* gtkComboBox; 106 107 /** Get the main Gtk struct */ 108 public GtkComboBox* getComboBoxStruct() 109 { 110 return gtkComboBox; 111 } 112 113 /** the main Gtk struct as a void* */ 114 protected override void* getStruct() 115 { 116 return cast(void*)gtkComboBox; 117 } 118 119 protected override void setStruct(GObject* obj) 120 { 121 gtkComboBox = cast(GtkComboBox*)obj; 122 super.setStruct(obj); 123 } 124 125 /** 126 * Sets our main struct and passes it to the parent class. 127 */ 128 public this (GtkComboBox* gtkComboBox, bool ownedRef = false) 129 { 130 this.gtkComboBox = gtkComboBox; 131 super(cast(GtkBin*)gtkComboBox, ownedRef); 132 } 133 134 // add the CellEditable capabilities 135 mixin CellEditableT!(GtkComboBox); 136 137 // add the CellLayout capabilities 138 mixin CellLayoutT!(GtkComboBox); 139 140 /** 141 * Creates a new empty GtkComboBox. 142 * Params: 143 * entry = If true, create an empty ComboBox with an entry. 144 * Throws: ConstructionException GTK+ fails to create the object. 145 */ 146 public this (bool entry=true) 147 { 148 GtkComboBox* p; 149 if ( entry ) 150 { 151 // GtkWidget* gtk_combo_box_new_text (void); 152 p = cast(GtkComboBox*)gtk_combo_box_new_with_entry(); 153 } 154 else 155 { 156 // GtkWidget* gtk_combo_box_new (void); 157 p = cast(GtkComboBox*)gtk_combo_box_new(); 158 } 159 160 if(p is null) 161 { 162 throw new ConstructionException("null returned by gtk_combo_box_new"); 163 } 164 165 this(p); 166 } 167 168 /** 169 * Creates a new GtkComboBox with the model initialized to model. 170 * Params: 171 * model = A GtkTreeModel. 172 * entry = If true, create an empty ComboBox with an entry. 173 * Throws: ConstructionException GTK+ fails to create the object. 174 */ 175 public this (TreeModelIF model, bool entry=true) 176 { 177 GtkComboBox* p; 178 if ( entry ) 179 { 180 // GtkWidget* gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model); 181 p = cast(GtkComboBox*)gtk_combo_box_new_with_model_and_entry((model is null) ? null : model.getTreeModelStruct()); 182 } 183 else 184 { 185 // GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model); 186 p = cast(GtkComboBox*)gtk_combo_box_new_with_model((model is null) ? null : model.getTreeModelStruct()); 187 } 188 189 if(p is null) 190 { 191 throw new ConstructionException("null returned by gtk_combo_box_new"); 192 } 193 194 this(p); 195 } 196 197 /** 198 * Creates a new empty GtkComboBox using area to layout cells. 199 * Params: 200 * area = the GtkCellArea to use to layout cell renderers. 201 * entry = If true, create an empty ComboBox with an entry. 202 * Throws: ConstructionException GTK+ fails to create the object. 203 */ 204 public this (CellArea area, bool entry=true) 205 { 206 GtkComboBox* p; 207 if ( entry ) 208 { 209 // GtkWidget* gtk_combo_box_new_with_area_and_entry (GtkCellArea *area); 210 p = cast(GtkComboBox*)gtk_combo_box_new_with_area_and_entry((area is null) ? null : area.getCellAreaStruct()); 211 } 212 else 213 { 214 // GtkWidget* gtk_combo_box_new_with_area (GtkCellArea* area); 215 p = cast(GtkComboBox*)gtk_combo_box_new_with_area((area is null) ? null : area.getCellAreaStruct()); 216 } 217 218 if(p is null) 219 { 220 throw new ConstructionException("null returned by gtk_combo_box_new"); 221 } 222 223 this(p); 224 } 225 226 /** 227 */ 228 229 /** */ 230 public static GType getType() 231 { 232 return gtk_combo_box_get_type(); 233 } 234 235 /** 236 * Returns the index of the currently active item, or -1 if there’s no 237 * active item. If the model is a non-flat treemodel, and the active item 238 * is not an immediate child of the root of the tree, this function returns 239 * `gtk_tree_path_get_indices (path)[0]`, where 240 * `path` is the #GtkTreePath of the active item. 241 * 242 * Return: An integer which is the index of the currently active item, 243 * or -1 if there’s no active item. 244 * 245 * Since: 2.4 246 */ 247 public int getActive() 248 { 249 return gtk_combo_box_get_active(gtkComboBox); 250 } 251 252 /** 253 * Returns the ID of the active row of @combo_box. This value is taken 254 * from the active row and the column specified by the #GtkComboBox:id-column 255 * property of @combo_box (see gtk_combo_box_set_id_column()). 256 * 257 * The returned value is an interned string which means that you can 258 * compare the pointer by value to other interned strings and that you 259 * must not free it. 260 * 261 * If the #GtkComboBox:id-column property of @combo_box is not set, or if 262 * no row is active, or if the active row has a %NULL ID value, then %NULL 263 * is returned. 264 * 265 * Return: the ID of the active row, or %NULL 266 * 267 * Since: 3.0 268 */ 269 public string getActiveId() 270 { 271 return Str.toString(gtk_combo_box_get_active_id(gtkComboBox)); 272 } 273 274 /** 275 * Sets @iter to point to the current active item, if it exists. 276 * 277 * Params: 278 * iter = The uninitialized #GtkTreeIter 279 * 280 * Return: %TRUE, if @iter was set 281 * 282 * Since: 2.4 283 */ 284 public bool getActiveIter(out TreeIter iter) 285 { 286 GtkTreeIter* outiter = gMalloc!GtkTreeIter(); 287 288 auto p = gtk_combo_box_get_active_iter(gtkComboBox, outiter) != 0; 289 290 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 291 292 return p; 293 } 294 295 /** 296 * Gets the current value of the :add-tearoffs property. 297 * 298 * Return: the current value of the :add-tearoffs property. 299 */ 300 public bool getAddTearoffs() 301 { 302 return gtk_combo_box_get_add_tearoffs(gtkComboBox) != 0; 303 } 304 305 /** 306 * Returns whether the combo box sets the dropdown button 307 * sensitive or not when there are no items in the model. 308 * 309 * Return: %GTK_SENSITIVITY_ON if the dropdown button 310 * is sensitive when the model is empty, %GTK_SENSITIVITY_OFF 311 * if the button is always insensitive or 312 * %GTK_SENSITIVITY_AUTO if it is only sensitive as long as 313 * the model has one item to be selected. 314 * 315 * Since: 2.14 316 */ 317 public GtkSensitivityType getButtonSensitivity() 318 { 319 return gtk_combo_box_get_button_sensitivity(gtkComboBox); 320 } 321 322 /** 323 * Returns the column with column span information for @combo_box. 324 * 325 * Return: the column span column. 326 * 327 * Since: 2.6 328 */ 329 public int getColumnSpanColumn() 330 { 331 return gtk_combo_box_get_column_span_column(gtkComboBox); 332 } 333 334 /** 335 * Returns the column which @combo_box is using to get the strings 336 * from to display in the internal entry. 337 * 338 * Return: A column in the data source model of @combo_box. 339 * 340 * Since: 2.24 341 */ 342 public int getEntryTextColumn() 343 { 344 return gtk_combo_box_get_entry_text_column(gtkComboBox); 345 } 346 347 /** 348 * Returns whether the combo box grabs focus when it is clicked 349 * with the mouse. See gtk_combo_box_set_focus_on_click(). 350 * 351 * Deprecated: Use gtk_widget_get_focus_on_click() instead 352 * 353 * Return: %TRUE if the combo box grabs focus when it is 354 * clicked with the mouse. 355 * 356 * Since: 2.6 357 */ 358 public override bool getFocusOnClick() 359 { 360 return gtk_combo_box_get_focus_on_click(gtkComboBox) != 0; 361 } 362 363 /** 364 * Returns whether the combo box has an entry. 365 * 366 * Return: whether there is an entry in @combo_box. 367 * 368 * Since: 2.24 369 */ 370 public bool getHasEntry() 371 { 372 return gtk_combo_box_get_has_entry(gtkComboBox) != 0; 373 } 374 375 /** 376 * Returns the column which @combo_box is using to get string IDs 377 * for values from. 378 * 379 * Return: A column in the data source model of @combo_box. 380 * 381 * Since: 3.0 382 */ 383 public int getIdColumn() 384 { 385 return gtk_combo_box_get_id_column(gtkComboBox); 386 } 387 388 /** 389 * Returns the #GtkTreeModel which is acting as data source for @combo_box. 390 * 391 * Return: A #GtkTreeModel which was passed 392 * during construction. 393 * 394 * Since: 2.4 395 */ 396 public TreeModelIF getModel() 397 { 398 auto p = gtk_combo_box_get_model(gtkComboBox); 399 400 if(p is null) 401 { 402 return null; 403 } 404 405 return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p); 406 } 407 408 /** 409 * Gets the accessible object corresponding to the combo box’s popup. 410 * 411 * This function is mostly intended for use by accessibility technologies; 412 * applications should have little use for it. 413 * 414 * Return: the accessible object corresponding 415 * to the combo box’s popup. 416 * 417 * Since: 2.6 418 */ 419 public ObjectAtk getPopupAccessible() 420 { 421 auto p = gtk_combo_box_get_popup_accessible(gtkComboBox); 422 423 if(p is null) 424 { 425 return null; 426 } 427 428 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 429 } 430 431 /** 432 * Gets whether the popup uses a fixed width matching 433 * the allocated width of the combo box. 434 * 435 * Return: %TRUE if the popup uses a fixed width 436 * 437 * Since: 3.0 438 */ 439 public bool getPopupFixedWidth() 440 { 441 return gtk_combo_box_get_popup_fixed_width(gtkComboBox) != 0; 442 } 443 444 /** 445 * Returns the current row separator function. 446 * 447 * Return: the current row separator function. 448 * 449 * Since: 2.6 450 */ 451 public GtkTreeViewRowSeparatorFunc getRowSeparatorFunc() 452 { 453 return gtk_combo_box_get_row_separator_func(gtkComboBox); 454 } 455 456 /** 457 * Returns the column with row span information for @combo_box. 458 * 459 * Return: the row span column. 460 * 461 * Since: 2.6 462 */ 463 public int getRowSpanColumn() 464 { 465 return gtk_combo_box_get_row_span_column(gtkComboBox); 466 } 467 468 /** 469 * Gets the current title of the menu in tearoff mode. See 470 * gtk_combo_box_set_add_tearoffs(). 471 * 472 * Return: the menu’s title in tearoff mode. This is an internal copy of the 473 * string which must not be freed. 474 * 475 * Since: 2.10 476 */ 477 public string getTitle() 478 { 479 return Str.toString(gtk_combo_box_get_title(gtkComboBox)); 480 } 481 482 /** 483 * Returns the wrap width which is used to determine the number of columns 484 * for the popup menu. If the wrap width is larger than 1, the combo box 485 * is in table mode. 486 * 487 * Return: the wrap width. 488 * 489 * Since: 2.6 490 */ 491 public int getWrapWidth() 492 { 493 return gtk_combo_box_get_wrap_width(gtkComboBox); 494 } 495 496 /** 497 * Hides the menu or dropdown list of @combo_box. 498 * 499 * This function is mostly intended for use by accessibility technologies; 500 * applications should have little use for it. 501 * 502 * Since: 2.4 503 */ 504 public void popdown() 505 { 506 gtk_combo_box_popdown(gtkComboBox); 507 } 508 509 /** 510 * Pops up the menu or dropdown list of @combo_box. 511 * 512 * This function is mostly intended for use by accessibility technologies; 513 * applications should have little use for it. 514 * 515 * Since: 2.4 516 */ 517 public void popup() 518 { 519 gtk_combo_box_popup(gtkComboBox); 520 } 521 522 /** 523 * Pops up the menu or dropdown list of @combo_box, the popup window 524 * will be grabbed so only @device and its associated pointer/keyboard 525 * are the only #GdkDevices able to send events to it. 526 * 527 * Params: 528 * device = a #GdkDevice 529 * 530 * Since: 3.0 531 */ 532 public void popupForDevice(Device device) 533 { 534 gtk_combo_box_popup_for_device(gtkComboBox, (device is null) ? null : device.getDeviceStruct()); 535 } 536 537 /** 538 * Sets the active item of @combo_box to be the item at @index. 539 * 540 * Params: 541 * index = An index in the model passed during construction, or -1 to have 542 * no active item 543 * 544 * Since: 2.4 545 */ 546 public void setActive(int index) 547 { 548 gtk_combo_box_set_active(gtkComboBox, index); 549 } 550 551 /** 552 * Changes the active row of @combo_box to the one that has an ID equal to 553 * @active_id, or unsets the active row if @active_id is %NULL. Rows having 554 * a %NULL ID string cannot be made active by this function. 555 * 556 * If the #GtkComboBox:id-column property of @combo_box is unset or if no 557 * row has the given ID then the function does nothing and returns %FALSE. 558 * 559 * Params: 560 * activeId = the ID of the row to select, or %NULL 561 * 562 * Return: %TRUE if a row with a matching ID was found. If a %NULL 563 * @active_id was given to unset the active row, the function 564 * always returns %TRUE. 565 * 566 * Since: 3.0 567 */ 568 public bool setActiveId(string activeId) 569 { 570 return gtk_combo_box_set_active_id(gtkComboBox, Str.toStringz(activeId)) != 0; 571 } 572 573 /** 574 * Sets the current active item to be the one referenced by @iter, or 575 * unsets the active item if @iter is %NULL. 576 * 577 * Params: 578 * iter = The #GtkTreeIter, or %NULL 579 * 580 * Since: 2.4 581 */ 582 public void setActiveIter(TreeIter iter) 583 { 584 gtk_combo_box_set_active_iter(gtkComboBox, (iter is null) ? null : iter.getTreeIterStruct()); 585 } 586 587 /** 588 * Sets whether the popup menu should have a tearoff 589 * menu item. 590 * 591 * Params: 592 * addTearoffs = %TRUE to add tearoff menu items 593 * 594 * Since: 2.6 595 */ 596 public void setAddTearoffs(bool addTearoffs) 597 { 598 gtk_combo_box_set_add_tearoffs(gtkComboBox, addTearoffs); 599 } 600 601 /** 602 * Sets whether the dropdown button of the combo box should be 603 * always sensitive (%GTK_SENSITIVITY_ON), never sensitive (%GTK_SENSITIVITY_OFF) 604 * or only if there is at least one item to display (%GTK_SENSITIVITY_AUTO). 605 * 606 * Params: 607 * sensitivity = specify the sensitivity of the dropdown button 608 * 609 * Since: 2.14 610 */ 611 public void setButtonSensitivity(GtkSensitivityType sensitivity) 612 { 613 gtk_combo_box_set_button_sensitivity(gtkComboBox, sensitivity); 614 } 615 616 /** 617 * Sets the column with column span information for @combo_box to be 618 * @column_span. The column span column contains integers which indicate 619 * how many columns an item should span. 620 * 621 * Params: 622 * columnSpan = A column in the model passed during construction 623 * 624 * Since: 2.4 625 */ 626 public void setColumnSpanColumn(int columnSpan) 627 { 628 gtk_combo_box_set_column_span_column(gtkComboBox, columnSpan); 629 } 630 631 /** 632 * Sets the model column which @combo_box should use to get strings from 633 * to be @text_column. The column @text_column in the model of @combo_box 634 * must be of type %G_TYPE_STRING. 635 * 636 * This is only relevant if @combo_box has been created with 637 * #GtkComboBox:has-entry as %TRUE. 638 * 639 * Params: 640 * textColumn = A column in @model to get the strings from for 641 * the internal entry 642 * 643 * Since: 2.24 644 */ 645 public void setEntryTextColumn(int textColumn) 646 { 647 gtk_combo_box_set_entry_text_column(gtkComboBox, textColumn); 648 } 649 650 /** 651 * Sets whether the combo box will grab focus when it is clicked with 652 * the mouse. Making mouse clicks not grab focus is useful in places 653 * like toolbars where you don’t want the keyboard focus removed from 654 * the main area of the application. 655 * 656 * Deprecated: Use gtk_widget_set_focus_on_click() instead 657 * 658 * Params: 659 * focusOnClick = whether the combo box grabs focus when clicked 660 * with the mouse 661 * 662 * Since: 2.6 663 */ 664 public override void setFocusOnClick(bool focusOnClick) 665 { 666 gtk_combo_box_set_focus_on_click(gtkComboBox, focusOnClick); 667 } 668 669 /** 670 * Sets the model column which @combo_box should use to get string IDs 671 * for values from. The column @id_column in the model of @combo_box 672 * must be of type %G_TYPE_STRING. 673 * 674 * Params: 675 * idColumn = A column in @model to get string IDs for values from 676 * 677 * Since: 3.0 678 */ 679 public void setIdColumn(int idColumn) 680 { 681 gtk_combo_box_set_id_column(gtkComboBox, idColumn); 682 } 683 684 /** 685 * Sets the model used by @combo_box to be @model. Will unset a previously set 686 * model (if applicable). If model is %NULL, then it will unset the model. 687 * 688 * Note that this function does not clear the cell renderers, you have to 689 * call gtk_cell_layout_clear() yourself if you need to set up different 690 * cell renderers for the new model. 691 * 692 * Params: 693 * model = A #GtkTreeModel 694 * 695 * Since: 2.4 696 */ 697 public void setModel(TreeModelIF model) 698 { 699 gtk_combo_box_set_model(gtkComboBox, (model is null) ? null : model.getTreeModelStruct()); 700 } 701 702 /** 703 * Specifies whether the popup’s width should be a fixed width 704 * matching the allocated width of the combo box. 705 * 706 * Params: 707 * fixed = whether to use a fixed popup width 708 * 709 * Since: 3.0 710 */ 711 public void setPopupFixedWidth(bool fixed) 712 { 713 gtk_combo_box_set_popup_fixed_width(gtkComboBox, fixed); 714 } 715 716 /** 717 * Sets the row separator function, which is used to determine 718 * whether a row should be drawn as a separator. If the row separator 719 * function is %NULL, no separators are drawn. This is the default value. 720 * 721 * Params: 722 * func = a #GtkTreeViewRowSeparatorFunc 723 * data = user data to pass to @func, or %NULL 724 * destroy = destroy notifier for @data, or %NULL 725 * 726 * Since: 2.6 727 */ 728 public void setRowSeparatorFunc(GtkTreeViewRowSeparatorFunc func, void* data, GDestroyNotify destroy) 729 { 730 gtk_combo_box_set_row_separator_func(gtkComboBox, func, data, destroy); 731 } 732 733 /** 734 * Sets the column with row span information for @combo_box to be @row_span. 735 * The row span column contains integers which indicate how many rows 736 * an item should span. 737 * 738 * Params: 739 * rowSpan = A column in the model passed during construction. 740 * 741 * Since: 2.4 742 */ 743 public void setRowSpanColumn(int rowSpan) 744 { 745 gtk_combo_box_set_row_span_column(gtkComboBox, rowSpan); 746 } 747 748 /** 749 * Sets the menu’s title in tearoff mode. 750 * 751 * Params: 752 * title = a title for the menu in tearoff mode 753 * 754 * Since: 2.10 755 */ 756 public void setTitle(string title) 757 { 758 gtk_combo_box_set_title(gtkComboBox, Str.toStringz(title)); 759 } 760 761 /** 762 * Sets the wrap width of @combo_box to be @width. The wrap width is basically 763 * the preferred number of columns when you want the popup to be layed out 764 * in a table. 765 * 766 * Params: 767 * width = Preferred number of columns 768 * 769 * Since: 2.4 770 */ 771 public void setWrapWidth(int width) 772 { 773 gtk_combo_box_set_wrap_width(gtkComboBox, width); 774 } 775 776 int[string] connectedSignals; 777 778 void delegate(ComboBox)[] onChangedListeners; 779 /** 780 * The changed signal is emitted when the active 781 * item is changed. The can be due to the user selecting 782 * a different item from the list, or due to a 783 * call to gtk_combo_box_set_active_iter(). 784 * It will also be emitted while typing into the entry of a combo box 785 * with an entry. 786 * 787 * Since: 2.4 788 */ 789 void addOnChanged(void delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 790 { 791 if ( "changed" !in connectedSignals ) 792 { 793 Signals.connectData( 794 this, 795 "changed", 796 cast(GCallback)&callBackChanged, 797 cast(void*)this, 798 null, 799 connectFlags); 800 connectedSignals["changed"] = 1; 801 } 802 onChangedListeners ~= dlg; 803 } 804 extern(C) static void callBackChanged(GtkComboBox* comboboxStruct, ComboBox _combobox) 805 { 806 foreach ( void delegate(ComboBox) dlg; _combobox.onChangedListeners ) 807 { 808 dlg(_combobox); 809 } 810 } 811 812 string delegate(string, ComboBox)[] onFormatEntryTextListeners; 813 /** 814 * For combo boxes that are created with an entry (See GtkComboBox:has-entry). 815 * 816 * A signal which allows you to change how the text displayed in a combo box's 817 * entry is displayed. 818 * 819 * Connect a signal handler which returns an allocated string representing 820 * @path. That string will then be used to set the text in the combo box's entry. 821 * The default signal handler uses the text from the GtkComboBox::entry-text-column 822 * model column. 823 * 824 * Here's an example signal handler which fetches data from the model and 825 * displays it in the entry. 826 * |[<!-- language="C" --> 827 * static gchar* 828 * format_entry_text_callback (GtkComboBox *combo, 829 * const gchar *path, 830 * gpointer user_data) 831 * { 832 * GtkTreeIter iter; 833 * GtkTreeModel model; 834 * gdouble value; 835 * 836 * model = gtk_combo_box_get_model (combo); 837 * 838 * gtk_tree_model_get_iter_from_string (model, &iter, path); 839 * gtk_tree_model_get (model, &iter, 840 * THE_DOUBLE_VALUE_COLUMN, &value, 841 * -1); 842 * 843 * return g_strdup_printf ("%g", value); 844 * } 845 * ]| 846 * 847 * Params: 848 * path = the GtkTreePath string from the combo box's current model to format text for 849 * 850 * Return: a newly allocated string representing @path 851 * for the current GtkComboBox model. 852 * 853 * Since: 3.4 854 */ 855 void addOnFormatEntryText(string delegate(string, ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 856 { 857 if ( "format-entry-text" !in connectedSignals ) 858 { 859 Signals.connectData( 860 this, 861 "format-entry-text", 862 cast(GCallback)&callBackFormatEntryText, 863 cast(void*)this, 864 null, 865 connectFlags); 866 connectedSignals["format-entry-text"] = 1; 867 } 868 onFormatEntryTextListeners ~= dlg; 869 } 870 extern(C) static string callBackFormatEntryText(GtkComboBox* comboboxStruct, char* path, ComboBox _combobox) 871 { 872 return _combobox.onFormatEntryTextListeners[0](Str.toString(path), _combobox); 873 } 874 875 void delegate(GtkScrollType, ComboBox)[] onMoveActiveListeners; 876 /** 877 * The ::move-active signal is a 878 * [keybinding signal][GtkBindingSignal] 879 * which gets emitted to move the active selection. 880 * 881 * Params: 882 * scrollType = a #GtkScrollType 883 * 884 * Since: 2.12 885 */ 886 void addOnMoveActive(void delegate(GtkScrollType, ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 887 { 888 if ( "move-active" !in connectedSignals ) 889 { 890 Signals.connectData( 891 this, 892 "move-active", 893 cast(GCallback)&callBackMoveActive, 894 cast(void*)this, 895 null, 896 connectFlags); 897 connectedSignals["move-active"] = 1; 898 } 899 onMoveActiveListeners ~= dlg; 900 } 901 extern(C) static void callBackMoveActive(GtkComboBox* comboboxStruct, GtkScrollType scrollType, ComboBox _combobox) 902 { 903 foreach ( void delegate(GtkScrollType, ComboBox) dlg; _combobox.onMoveActiveListeners ) 904 { 905 dlg(scrollType, _combobox); 906 } 907 } 908 909 bool delegate(ComboBox)[] onPopdownListeners; 910 /** 911 * The ::popdown signal is a 912 * [keybinding signal][GtkBindingSignal] 913 * which gets emitted to popdown the combo box list. 914 * 915 * The default bindings for this signal are Alt+Up and Escape. 916 * 917 * Since: 2.12 918 */ 919 void addOnPopdown(bool delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 920 { 921 if ( "popdown" !in connectedSignals ) 922 { 923 Signals.connectData( 924 this, 925 "popdown", 926 cast(GCallback)&callBackPopdown, 927 cast(void*)this, 928 null, 929 connectFlags); 930 connectedSignals["popdown"] = 1; 931 } 932 onPopdownListeners ~= dlg; 933 } 934 extern(C) static int callBackPopdown(GtkComboBox* comboboxStruct, ComboBox _combobox) 935 { 936 foreach ( bool delegate(ComboBox) dlg; _combobox.onPopdownListeners ) 937 { 938 if ( dlg(_combobox) ) 939 { 940 return 1; 941 } 942 } 943 944 return 0; 945 } 946 947 void delegate(ComboBox)[] onPopupListeners; 948 /** 949 * The ::popup signal is a 950 * [keybinding signal][GtkBindingSignal] 951 * which gets emitted to popup the combo box list. 952 * 953 * The default binding for this signal is Alt+Down. 954 * 955 * Since: 2.12 956 */ 957 void addOnPopup(void delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 958 { 959 if ( "popup" !in connectedSignals ) 960 { 961 Signals.connectData( 962 this, 963 "popup", 964 cast(GCallback)&callBackPopup, 965 cast(void*)this, 966 null, 967 connectFlags); 968 connectedSignals["popup"] = 1; 969 } 970 onPopupListeners ~= dlg; 971 } 972 extern(C) static void callBackPopup(GtkComboBox* comboboxStruct, ComboBox _combobox) 973 { 974 foreach ( void delegate(ComboBox) dlg; _combobox.onPopupListeners ) 975 { 976 dlg(_combobox); 977 } 978 } 979 }