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