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