Class ComboBox.Builder<B extends ComboBox.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, CellEditable.Builder<B>, BuilderInterface
Direct Known Subclasses:
ComboBoxText.Builder
Enclosing class:
ComboBox

public static class ComboBox.Builder<B extends ComboBox.Builder<B>> extends Widget.Builder<B> implements Accessible.Builder<B>, CellEditable.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public ComboBox build()
      Finish building the ComboBox object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to ComboBox.
      Overrides:
      build in class Widget.Builder<B extends ComboBox.Builder<B>>
      Returns:
      a new instance of ComboBox with the properties that were set in the Builder object.
    • setActive

      public B setActive(int active)

      The item which is currently active.

      If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has the value gtk_tree_path_get_indices (path)[0], where path is the Gtk.TreePath of the active item.

      Parameters:
      active - the value for the active property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setActiveId

      public B setActiveId(String activeId)
      The value of the ID column of the active row.
      Parameters:
      activeId - the value for the active-id property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setButtonSensitivity

      public B setButtonSensitivity(SensitivityType buttonSensitivity)
      Whether the dropdown button is sensitive when the model is empty.
      Parameters:
      buttonSensitivity - the value for the button-sensitivity property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setChild

      public B setChild(Widget child)
      The child widget.
      Parameters:
      child - the value for the child property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setEntryTextColumn

      public B setEntryTextColumn(int entryTextColumn)

      The model column to associate with strings from the entry.

      This is property only relevant if the combo was created with Gtk.ComboBox:has-entry is true.

      Parameters:
      entryTextColumn - the value for the entry-text-column property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasEntry

      public B setHasEntry(boolean hasEntry)
      Whether the combo box has an entry.
      Parameters:
      hasEntry - the value for the has-entry property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasFrame

      public B setHasFrame(boolean hasFrame)
      The has-frame property controls whether a frame is drawn around the entry.
      Parameters:
      hasFrame - the value for the has-frame property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setIdColumn

      public B setIdColumn(int idColumn)
      The model column that provides string IDs for the values in the model, if != -1.
      Parameters:
      idColumn - the value for the id-column property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setModel

      public B setModel(TreeModel model)
      The model from which the combo box takes its values.
      Parameters:
      model - the value for the model property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setPopupFixedWidth

      public B setPopupFixedWidth(boolean popupFixedWidth)
      Whether the popup's width should be a fixed width matching the allocated width of the combo box.
      Parameters:
      popupFixedWidth - the value for the popup-fixed-width property
      Returns:
      the Builder instance is returned, to allow method chaining
    • onActivate

      public B onActivate(ComboBox.ActivateCallback handler)

      Emitted to when the combo box is activated.

      The ::activate signal on GtkComboBox is an action signal and emitting it causes the combo box to pop up its dropdown.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.6
      See Also:
    • onChanged

      public B onChanged(ComboBox.ChangedCallback handler)

      Emitted when the active item is changed.

      The can be due to the user selecting a different item from the list, or due to a call to ComboBox.setActiveIter(TreeIter). It will also be emitted while typing into the entry of a combo box with an entry.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onFormatEntryText

      public B onFormatEntryText(ComboBox.FormatEntryTextCallback handler)

      Emitted to allow changing how the text in a combo box's entry is displayed.

      See Gtk.ComboBox:has-entry.

      Connect a signal handler which returns an allocated string representing path. That string will then be used to set the text in the combo box's entry. The default signal handler uses the text from the Gtk.ComboBox:entry-text-column model column.

      Here's an example signal handler which fetches data from the model and displays it in the entry.

      static char *
      format_entry_text_callback (GtkComboBox *combo,
                                  const char *path,
                                  gpointer     user_data)
      {
        GtkTreeIter iter;
        GtkTreeModel model;
        double       value;
      
        model = gtk_combo_box_get_model (combo);
      
        gtk_tree_model_get_iter_from_string (model, &iter, path);
        gtk_tree_model_get (model, &iter,
                            THE_DOUBLE_VALUE_COLUMN, &value,
                            -1);
      
        return g_strdup_printf ("%g", value);
      }
      
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onMoveActive

      public B onMoveActive(ComboBox.MoveActiveCallback handler)

      Emitted to move the active selection.

      This is an keybinding signal.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onPopdown

      public B onPopdown(ComboBox.PopdownCallback handler)

      Emitted to popdown the combo box list.

      This is an keybinding signal.

      The default bindings for this signal are Alt+Up and Escape.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onPopup

      public B onPopup(ComboBox.PopupCallback handler)

      Emitted to popup the combo box list.

      This is an keybinding signal.

      The default binding for this signal is Alt+Down.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: