Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ComboBoxText

[38:7] extends: object

A GtkComboBoxText is a simple variant of GtkComboBox for text-only use cases. An example GtkComboBoxText GtkComboBoxText hides the model-view complexity of GtkComboBox. To create a GtkComboBoxText, use [ctor@Gtk.ComboBoxText.new] or [ctor@Gtk.ComboBoxText.new_with_entry]. You can add items to a GtkComboBoxText with [method@Gtk.ComboBoxText.append_text], [method@Gtk.ComboBoxText.insert_text] or [method@Gtk.ComboBoxText.prepend_text] and remove options with [method@Gtk.ComboBoxText.remove]. If the GtkComboBoxText contains an entry (via the [property@Gtk.ComboBox:has-entry] property), its contents can be retrieved using [method@Gtk.ComboBoxText.get_active_text]. You should not call [method@Gtk.ComboBox.set_model] or attempt to pack more cells into this combo box via its [iface@Gtk.CellLayout] 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: xml <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 GtkComboBoxText has a 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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • ComboBoxText ()

    Creates a new GtkComboBoxText.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asComboBox ()

    Wraps this handle as ComboBox.

    • @r A ComboBox object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asCellEditable ()

    Wraps this handle as CellEditable.

    • @r A CellEditable object.
  • asCellLayout ()

    Wraps this handle as CellLayout.

    • @r A CellLayout object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • append (string id, string text)

    Appends @text to the list of strings stored in @combo_box. If @id is non-%NULL then it is used as the ID of the row. This is the same as calling [method@Gtk.ComboBoxText.insert] with a position of -1.

    • @p id is a string ID for this value.
    • @p text is A string.
    • @r None.
  • append_text (string text)

    Appends @text to the list of strings stored in @combo_box. This is the same as calling [method@Gtk.ComboBoxText.insert_text] with a position of -1.

    • @p text is A string.
    • @r None.
  • get_active_text ()

    Returns the currently active string in @combo_box. If no row is currently selected, %NULL is returned. If @combo_box contains an entry, this function will return its contents (which will not necessarily be an item from the list).

  • insert (int position, string id, string text)

    Inserts @text at @position in the list of strings stored in @combo_box. If @id is non-%NULL then it is used as the ID of the row. See [property@Gtk.ComboBox:id-column]. If @position is negative then @text is appended.

    • @p position is An index to insert @text.
    • @p id is a string ID for this value.
    • @p text is A string to display.
    • @r None.
  • insert_text (int position, string text)

    Inserts @text at @position in the list of strings stored in @combo_box. If @position is negative then @text is appended. This is the same as calling [method@Gtk.ComboBoxText.insert] with a %NULL ID string.

    • @p position is An index to insert @text.
    • @p text is A string.
    • @r None.
  • prepend (string id, string text)

    Prepends @text to the list of strings stored in @combo_box. If @id is non-%NULL then it is used as the ID of the row. This is the same as calling [method@Gtk.ComboBoxText.insert] with a position of 0.

    • @p id is a string ID for this value.
    • @p text is a string.
    • @r None.
  • prepend_text (string text)

    Prepends @text to the list of strings stored in @combo_box. This is the same as calling [method@Gtk.ComboBoxText.insert_text] with a position of 0.

    • @p text is A string.
    • @r None.
  • remove (int position)

    Removes the string at @position from @combo_box.

    • @p position is Index of the item to remove.
    • @r None.
  • remove_all ()

    Removes all the text entries from the combo box.

    • @r None.

class: ComboBoxTextCtors

[287:14] static extends: object

Alternate constructors for ComboBoxText. Usage: ComboBoxTextCtors.<name>(...). The primary constructor lives directly on ComboBoxText.

Methods

  • newWithEntry ()

    Creates a new GtkComboBoxText with an entry.

    • @r A new ComboBoxText.