Package: gtk

Class gtk:combo-box-text

Superclasses

Documented Subclasses

None

Direct Slots

None

Details

The gtk:combo-box-text widget is a simple variant of the gtk:combo-box widget that hides the model-view complexity for simple text-only use cases. To create a gtk:combo-box-text widget, use the gtk:combo-box-text-new or gtk:combo-box-text-new-with-entry functions.

You can add items to a gtk:combo-box-text widget with the gtk:combo-box-text-append-text, gtk:combo-box-text-insert-text or gtk:combo-box-text-prepend-text functions and remove options with the gtk:combo-box-text-remove function.

If the gtk:combo-box-text widget contains an entry via the has-entry property, its contents can be retrieved using the gtk:combo-box-text-active-text function. The entry itself can be accessed by calling the gtk:combo-box-child function on the combo box.

You should not call the gtk:combo-box-model function or attempt to pack more cells into this combo box via its gtk:cell-layout interface.

GtkComboBoxText as GtkBuildable

The gtk:combo-box-text implementation of the gtk:buildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element supports the regular translation attributes "translatable", "context" and "comments".

Example: A UI definition fragment specifying gtk:combo-box-text items
 <object class="GtkComboBoxText">
   <items>
     <item translatable="yes">Factory</item>
     <item translatable="yes">Home</item>
     <item translatable="yes">Subway</item>
   </items>
 </object>    

CSS nodes

 combobox
 ╰── box.linked
     ├── entry.combo
     ├── button.combo
     ╰── window.popup    
The gtk:combo-box-text implementation has a single CSS node with name combobox. It adds the .combo style class to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

Warning

The gtk:combo-box-text implementation is deprecated since 4.10. Use the gtk:drop-down widget with a gtk:string-list object instead.
 

Returned by

Inherited Slot Access Functions

See also

2024-4-6