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