ComboBoxText


Object Hierarchy:

Gtk.ComboBoxText Gtk.ComboBoxText Gtk.ComboBoxText Gtk.ComboBox Gtk.ComboBox Gtk.ComboBox->Gtk.ComboBoxText Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.ComboBox Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.ComboBoxText Atk.Implementor->Gtk.ComboBox Atk.Implementor->Gtk.Bin Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.ComboBoxText Gtk.Buildable->Gtk.ComboBox Gtk.Buildable->Gtk.Bin Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.CellEditable Gtk.CellEditable Gtk.CellEditable->Gtk.ComboBoxText Gtk.CellEditable->Gtk.ComboBox Gtk.CellLayout Gtk.CellLayout Gtk.CellLayout->Gtk.ComboBoxText Gtk.CellLayout->Gtk.ComboBox

Description:

[ CCode ( type_id = "gtk_combo_box_text_get_type ()" ) ]
public class ComboBoxText : ComboBox, Implementor, Buildable, CellEditable, CellLayout

A GtkComboBoxText is a simple variant of ComboBox that hides the model-view complexity for simple text-only use cases.

To create a GtkComboBoxText, use ComboBoxText or ComboBoxText.with_entry.

You can add items to a GtkComboBoxText with append_text, insert_text or prepend_text and remove options with remove.

If the GtkComboBoxText contains an entry (via the “has-entry” property), its contents can be retrieved using get_active_text. The entry itself can be accessed by calling get_child on the combo box.

You should not call set_model or attempt to pack more cells into this combo box via its GtkCellLayout interface.

GtkComboBoxText as GtkBuildable

The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the `<items>` element and specifying `<item>` elements for each item. Each `<item>` element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.

Here is a UI definition fragment specifying GtkComboBoxText items:

<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>

CSS nodes

combobox
╰── box.linked
├── entry.combo
├── button.combo
╰── window.popup
single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

GtkComboBoxText

Example: ComboBoxText:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.ComboBoxText";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);

// The Box:
Gtk.ComboBoxText box = new Gtk.ComboBoxText ();
box.append_text ("nemequ");
box.append_text ("juergbi");
box.append_text ("flo");
box.active = 0;
this.add (box);

box.changed.connect (() => {
string title = box.get_active_text ();
print ("%d: %s\n", box.active, title);
});
}

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}

valac --pkg gtk+-3.0 Gtk.ComboBoxText.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.CellEditable