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.MemorySlice; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import gtk.Bin; 35 private import gtk.CellEditableIF; 36 private import gtk.CellEditableT; 37 private import gtk.CellLayoutIF; 38 private import gtk.CellLayoutT; 39 private import gtk.TreeIter; 40 private import gtk.TreeModelIF; 41 private import gtk.c.functions; 42 public import gtk.c.types; 43 public import gtkc.gtktypes; 44 private import std.algorithm; 45 46 47 /** 48 * A GtkComboBox is a widget that allows the user to choose from a list of 49 * valid choices. The GtkComboBox displays the selected choice. When 50 * activated, the GtkComboBox displays a popup which allows the user to 51 * make a new choice. The style in which the selected value is displayed, 52 * and the style of the popup is determined by the current theme. It may 53 * be similar to a Windows-style combo box. 54 * 55 * The GtkComboBox uses the model-view pattern; the list of valid choices 56 * is specified in the form of a tree model, and the display of the choices 57 * can be adapted to the data in the model by using cell renderers, as you 58 * would in a tree view. This is possible since GtkComboBox implements the 59 * #GtkCellLayout interface. The tree model holding the valid choices is 60 * not restricted to a flat list, it can be a real tree, and the popup will 61 * reflect the tree structure. 62 * 63 * To allow the user to enter values not in the model, the “has-entry” 64 * property allows the GtkComboBox to contain a #GtkEntry. This entry 65 * can be accessed by calling gtk_bin_get_child() on the combo box. 66 * 67 * For a simple list of textual choices, the model-view API of GtkComboBox 68 * can be a bit overwhelming. In this case, #GtkComboBoxText offers a 69 * simple alternative. Both GtkComboBox and #GtkComboBoxText can contain 70 * an entry. 71 * 72 * # CSS nodes 73 * 74 * |[<!-- language="plain" --> 75 * combobox 76 * ├── box.linked 77 * │ ╰── button.combo 78 * │ ╰── box 79 * │ ├── cellview 80 * │ ╰── arrow 81 * ╰── window.popup 82 * ]| 83 * 84 * A normal combobox contains a box with the .linked class, a button 85 * with the .combo class and inside those buttons, there are a cellview and 86 * an arrow. 87 * 88 * |[<!-- language="plain" --> 89 * combobox 90 * ├── box.linked 91 * │ ├── entry.combo 92 * │ ╰── button.combo 93 * │ ╰── box 94 * │ ╰── arrow 95 * ╰── window.popup 96 * ]| 97 * 98 * A GtkComboBox with an entry has a single CSS node with name combobox. It 99 * contains a box with the .linked class. That box contains an entry and a 100 * button, both with the .combo class added. 101 * The button also contains another node with name arrow. 102 */ 103 public class ComboBox : Bin, CellEditableIF, CellLayoutIF 104 { 105 /** the main Gtk struct */ 106 protected GtkComboBox* gtkComboBox; 107 108 /** Get the main Gtk struct */ 109 public GtkComboBox* getComboBoxStruct(bool transferOwnership = false) 110 { 111 if (transferOwnership) 112 ownedRef = false; 113 return gtkComboBox; 114 } 115 116 /** the main Gtk struct as a void* */ 117 protected override void* getStruct() 118 { 119 return cast(void*)gtkComboBox; 120 } 121 122 /** 123 * Sets our main struct and passes it to the parent class. 124 */ 125 public this (GtkComboBox* gtkComboBox, bool ownedRef = false) 126 { 127 this.gtkComboBox = gtkComboBox; 128 super(cast(GtkBin*)gtkComboBox, ownedRef); 129 } 130 131 // add the CellEditable capabilities 132 mixin CellEditableT!(GtkComboBox); 133 134 // add the CellLayout capabilities 135 mixin CellLayoutT!(GtkComboBox); 136 137 /** 138 * Creates a new empty GtkComboBox. 139 * Params: 140 * entry = If true, create an empty ComboBox with an entry. 141 * Throws: ConstructionException GTK+ fails to create the object. 142 */ 143 public this (bool entry=true) 144 { 145 GtkComboBox* p; 146 if ( entry ) 147 { 148 // GtkWidget* gtk_combo_box_new_text (void); 149 p = cast(GtkComboBox*)gtk_combo_box_new_with_entry(); 150 } 151 else 152 { 153 // GtkWidget* gtk_combo_box_new (void); 154 p = cast(GtkComboBox*)gtk_combo_box_new(); 155 } 156 157 if(p is null) 158 { 159 throw new ConstructionException("null returned by gtk_combo_box_new"); 160 } 161 162 this(p); 163 } 164 165 /** 166 * Creates a new GtkComboBox with the model initialized to model. 167 * Params: 168 * model = A GtkTreeModel. 169 * entry = If true, create an empty ComboBox with an entry. 170 * Throws: ConstructionException GTK+ fails to create the object. 171 */ 172 public this (TreeModelIF model, bool entry=true) 173 { 174 GtkComboBox* p; 175 if ( entry ) 176 { 177 // GtkWidget* gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model); 178 p = cast(GtkComboBox*)gtk_combo_box_new_with_model_and_entry((model is null) ? null : model.getTreeModelStruct()); 179 } 180 else 181 { 182 // GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model); 183 p = cast(GtkComboBox*)gtk_combo_box_new_with_model((model is null) ? null : model.getTreeModelStruct()); 184 } 185 186 if(p is null) 187 { 188 throw new ConstructionException("null returned by gtk_combo_box_new"); 189 } 190 191 this(p); 192 } 193 194 /** 195 * Creates a new empty GtkComboBox using area to layout cells. 196 * Params: 197 * area = the GtkCellArea to use to layout cell renderers. 198 * entry = If true, create an empty ComboBox with an entry. 199 * Throws: ConstructionException GTK+ fails to create the object. 200 */ 201 public this (CellArea area, bool entry=true) 202 { 203 GtkComboBox* p; 204 if ( entry ) 205 { 206 // GtkWidget* gtk_combo_box_new_with_area_and_entry (GtkCellArea *area); 207 p = cast(GtkComboBox*)gtk_combo_box_new_with_area_and_entry((area is null) ? null : area.getCellAreaStruct()); 208 } 209 else 210 { 211 // GtkWidget* gtk_combo_box_new_with_area (GtkCellArea* area); 212 p = cast(GtkComboBox*)gtk_combo_box_new_with_area((area is null) ? null : area.getCellAreaStruct()); 213 } 214 215 if(p is null) 216 { 217 throw new ConstructionException("null returned by gtk_combo_box_new"); 218 } 219 220 this(p); 221 } 222 223 /** 224 */ 225 226 /** */ 227 public static GType getType() 228 { 229 return gtk_combo_box_get_type(); 230 } 231 232 /** 233 * Returns the index of the currently active item, or -1 if there’s no 234 * active item. If the model is a non-flat treemodel, and the active item 235 * is not an immediate child of the root of the tree, this function returns 236 * `gtk_tree_path_get_indices (path)[0]`, where 237 * `path` is the #GtkTreePath of the active item. 238 * 239 * Returns: An integer which is the index of the currently active item, 240 * or -1 if there’s no active item. 241 * 242 * Since: 2.4 243 */ 244 public int getActive() 245 { 246 return gtk_combo_box_get_active(gtkComboBox); 247 } 248 249 /** 250 * Returns the ID of the active row of @combo_box. This value is taken 251 * from the active row and the column specified by the #GtkComboBox:id-column 252 * property of @combo_box (see gtk_combo_box_set_id_column()). 253 * 254 * The returned value is an interned string which means that you can 255 * compare the pointer by value to other interned strings and that you 256 * must not free it. 257 * 258 * If the #GtkComboBox:id-column property of @combo_box is not set, or if 259 * no row is active, or if the active row has a %NULL ID value, then %NULL 260 * is returned. 261 * 262 * Returns: the ID of the active row, or %NULL 263 * 264 * Since: 3.0 265 */ 266 public string getActiveId() 267 { 268 return Str.toString(gtk_combo_box_get_active_id(gtkComboBox)); 269 } 270 271 /** 272 * Sets @iter to point to the currently active item, if any item is active. 273 * Otherwise, @iter is left unchanged. 274 * 275 * Params: 276 * iter = A #GtkTreeIter 277 * 278 * Returns: %TRUE if @iter was set, %FALSE otherwise 279 * 280 * Since: 2.4 281 */ 282 public bool getActiveIter(out TreeIter iter) 283 { 284 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 285 286 auto p = gtk_combo_box_get_active_iter(gtkComboBox, outiter) != 0; 287 288 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 289 290 return p; 291 } 292 293 /** 294 * Gets the current value of the :add-tearoffs property. 295 * 296 * Returns: the current value of the :add-tearoffs property. 297 */ 298 public bool getAddTearoffs() 299 { 300 return gtk_combo_box_get_add_tearoffs(gtkComboBox) != 0; 301 } 302 303 /** 304 * Returns whether the combo box sets the dropdown button 305 * sensitive or not when there are no items in the model. 306 * 307 * Returns: %GTK_SENSITIVITY_ON if the dropdown button 308 * is sensitive when the model is empty, %GTK_SENSITIVITY_OFF 309 * if the button is always insensitive or 310 * %GTK_SENSITIVITY_AUTO if it is only sensitive as long as 311 * the model has one item to be selected. 312 * 313 * Since: 2.14 314 */ 315 public GtkSensitivityType getButtonSensitivity() 316 { 317 return gtk_combo_box_get_button_sensitivity(gtkComboBox); 318 } 319 320 /** 321 * Returns the column with column span information for @combo_box. 322 * 323 * Returns: the column span column. 324 * 325 * Since: 2.6 326 */ 327 public int getColumnSpanColumn() 328 { 329 return gtk_combo_box_get_column_span_column(gtkComboBox); 330 } 331 332 /** 333 * Returns the column which @combo_box is using to get the strings 334 * from to display in the internal entry. 335 * 336 * Returns: A column in the data source model of @combo_box. 337 * 338 * Since: 2.24 339 */ 340 public int getEntryTextColumn() 341 { 342 return gtk_combo_box_get_entry_text_column(gtkComboBox); 343 } 344 345 /** 346 * Returns whether the combo box grabs focus when it is clicked 347 * with the mouse. See gtk_combo_box_set_focus_on_click(). 348 * 349 * Deprecated: Use gtk_widget_get_focus_on_click() instead 350 * 351 * Returns: %TRUE if the combo box grabs focus when it is 352 * clicked with the mouse. 353 * 354 * Since: 2.6 355 */ 356 public override bool getFocusOnClick() 357 { 358 return gtk_combo_box_get_focus_on_click(gtkComboBox) != 0; 359 } 360 361 /** 362 * Returns whether the combo box has an entry. 363 * 364 * Returns: whether there is an entry in @combo_box. 365 * 366 * Since: 2.24 367 */ 368 public bool getHasEntry() 369 { 370 return gtk_combo_box_get_has_entry(gtkComboBox) != 0; 371 } 372 373 /** 374 * Returns the column which @combo_box is using to get string IDs 375 * for values from. 376 * 377 * Returns: A column in the data source model of @combo_box. 378 * 379 * Since: 3.0 380 */ 381 public int getIdColumn() 382 { 383 return gtk_combo_box_get_id_column(gtkComboBox); 384 } 385 386 /** 387 * Returns the #GtkTreeModel which is acting as data source for @combo_box. 388 * 389 * Returns: A #GtkTreeModel which was passed 390 * during construction. 391 * 392 * Since: 2.4 393 */ 394 public TreeModelIF getModel() 395 { 396 auto p = gtk_combo_box_get_model(gtkComboBox); 397 398 if(p is null) 399 { 400 return null; 401 } 402 403 return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) p); 404 } 405 406 /** 407 * Gets the accessible object corresponding to the combo box’s popup. 408 * 409 * This function is mostly intended for use by accessibility technologies; 410 * applications should have little use for it. 411 * 412 * Returns: the accessible object corresponding 413 * to the combo box’s popup. 414 * 415 * Since: 2.6 416 */ 417 public ObjectAtk getPopupAccessible() 418 { 419 auto p = gtk_combo_box_get_popup_accessible(gtkComboBox); 420 421 if(p is null) 422 { 423 return null; 424 } 425 426 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 427 } 428 429 /** 430 * Gets whether the popup uses a fixed width matching 431 * the allocated width of the combo box. 432 * 433 * Returns: %TRUE if the popup uses a fixed width 434 * 435 * Since: 3.0 436 */ 437 public bool getPopupFixedWidth() 438 { 439 return gtk_combo_box_get_popup_fixed_width(gtkComboBox) != 0; 440 } 441 442 /** 443 * Returns the current row separator function. 444 * 445 * Returns: the current row separator function. 446 * 447 * Since: 2.6 448 */ 449 public GtkTreeViewRowSeparatorFunc getRowSeparatorFunc() 450 { 451 return gtk_combo_box_get_row_separator_func(gtkComboBox); 452 } 453 454 /** 455 * Returns the column with row span information for @combo_box. 456 * 457 * Returns: the row span column. 458 * 459 * Since: 2.6 460 */ 461 public int getRowSpanColumn() 462 { 463 return gtk_combo_box_get_row_span_column(gtkComboBox); 464 } 465 466 /** 467 * Gets the current title of the menu in tearoff mode. See 468 * gtk_combo_box_set_add_tearoffs(). 469 * 470 * Returns: the menu’s title in tearoff mode. This is an internal copy of the 471 * string which must not be freed. 472 * 473 * Since: 2.10 474 */ 475 public string getTitle() 476 { 477 return Str.toString(gtk_combo_box_get_title(gtkComboBox)); 478 } 479 480 /** 481 * Returns the wrap width which is used to determine the number of columns 482 * for the popup menu. If the wrap width is larger than 1, the combo box 483 * is in table mode. 484 * 485 * Returns: the wrap width. 486 * 487 * Since: 2.6 488 */ 489 public int getWrapWidth() 490 { 491 return gtk_combo_box_get_wrap_width(gtkComboBox); 492 } 493 494 /** 495 * Hides the menu or dropdown list of @combo_box. 496 * 497 * This function is mostly intended for use by accessibility technologies; 498 * applications should have little use for it. 499 * 500 * Since: 2.4 501 */ 502 public void popdown() 503 { 504 gtk_combo_box_popdown(gtkComboBox); 505 } 506 507 /** 508 * Pops up the menu or dropdown list of @combo_box. 509 * 510 * This function is mostly intended for use by accessibility technologies; 511 * applications should have little use for it. 512 * 513 * Before calling this, @combo_box must be mapped, or nothing will happen. 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 * Returns: %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 /** 777 * The changed signal is emitted when the active 778 * item is changed. The can be due to the user selecting 779 * a different item from the list, or due to a 780 * call to gtk_combo_box_set_active_iter(). 781 * It will also be emitted while typing into the entry of a combo box 782 * with an entry. 783 * 784 * Since: 2.4 785 */ 786 gulong addOnChanged(void delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 787 { 788 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 789 } 790 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 * Returns: a newly allocated string representing @path 829 * for the current GtkComboBox model. 830 * 831 * Since: 3.4 832 */ 833 gulong addOnFormatEntryText(string delegate(string, ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 834 { 835 return Signals.connect(this, "format-entry-text", dlg, connectFlags ^ ConnectFlags.SWAPPED); 836 } 837 838 /** 839 * The ::move-active signal is a 840 * [keybinding signal][GtkBindingSignal] 841 * which gets emitted to move the active selection. 842 * 843 * Params: 844 * scrollType = a #GtkScrollType 845 * 846 * Since: 2.12 847 */ 848 gulong addOnMoveActive(void delegate(GtkScrollType, ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 849 { 850 return Signals.connect(this, "move-active", dlg, connectFlags ^ ConnectFlags.SWAPPED); 851 } 852 853 /** 854 * The ::popdown signal is a 855 * [keybinding signal][GtkBindingSignal] 856 * which gets emitted to popdown the combo box list. 857 * 858 * The default bindings for this signal are Alt+Up and Escape. 859 * 860 * Since: 2.12 861 */ 862 gulong addOnPopdown(bool delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 863 { 864 return Signals.connect(this, "popdown", dlg, connectFlags ^ ConnectFlags.SWAPPED); 865 } 866 867 /** 868 * The ::popup signal is a 869 * [keybinding signal][GtkBindingSignal] 870 * which gets emitted to popup the combo box list. 871 * 872 * The default binding for this signal is Alt+Down. 873 * 874 * Since: 2.12 875 */ 876 gulong addOnPopup(void delegate(ComboBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 877 { 878 return Signals.connect(this, "popup", dlg, connectFlags ^ ConnectFlags.SWAPPED); 879 } 880 }