ComboBox
Object Hierarchy:
Description:
public class ComboBox : Bin, Implementor, Buildable, CellEditable, CellLayout
A GtkComboBox is a widget that allows the user to choose from a list of valid choices.
The GtkComboBox displays the selected choice. When activated, the GtkComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a Windows-style combo box.
The GtkComboBox uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since GtkComboBox implements the CellLayout interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.
To allow the user to enter values not in the model, the “has-entry” property allows the GtkComboBox to contain a Entry. This entry can be accessed by calling get_child on the combo box.
For a simple list of textual choices, the model-view API of GtkComboBox can be a bit overwhelming. In this case, ComboBoxText offers a simple alternative. Both GtkComboBox and ComboBoxText can contain an entry.
CSS nodes
combobox
├── box.linked
│ ╰── button.combo
│ ╰── box
│ ├── cellview
│ ╰── arrow
╰── window.popup
.linked class, a button with the .combo class and inside those buttons, there are a cellview and an arrow.
combobox
├── box.linked
│ ├── entry.combo
│ ╰── button.combo
│ ╰── box
│ ╰── arrow
╰── window.popup
SS node with name combobox. It contains a box with the .linked class. That box contains an entry and a button, both with the .combo class added.
The button also contains another node with name arrow.

Content:
Properties:
- public int active { get; set; }
The item which is currently active.
- public string? active_id { get; set; }
The value of the ID column of the active row.
- public bool add_tearoffs { get; set; }
The add-tearoffs property controls whether generated menus have tearoff menu items.
- public SensitivityType button_sensitivity { get; set; }
Whether the dropdown button is sensitive when the model is empty.
- public CellArea cell_area { owned get; construct; }
The CellArea used to layout cell renderers for this combo box.
- public int column_span_column { get; set; }
If this is set to a non-negative value, it must be the index of a column of type g_type_int in the model.
- public int entry_text_column { get; set; }
The column in the combo box's model to associate with strings from the entry if the combo was created with has_entry = true.
- public bool has_entry { get; construct; }
Whether the combo box has an entry.
- public bool has_frame { get; set; }
The has-frame property controls whether a frame is drawn around the entry.
- public int id_column { get; set; }
The column in the combo box's model that provides string IDs for the values in the model, if != -1.
- public TreeModel model { get; set; }
The model from which the combo box takes the values shown in the list.
- public bool popup_fixed_width { get; set; }
Whether the popup's width should be a fixed width matching the allocated width of the combo box.
- public bool popup_shown { get; }
Whether the combo boxes dropdown is popped up.
- public int row_span_column { get; set; }
If this is set to a non-negative value, it must be the index of a column of type g_type_int in the model.
- public string tearoff_title { owned get; set; }
A title that may be displayed by the window manager when the popup is torn-off.
- public int wrap_width { get; set; }
If wrap-width is set to a positive value, items in the popup will be laid out along multiple columns, starting a new row on reaching the wrap width.
Creation methods:
- public ComboBox ()
Creates a new empty ComboBox.
- public ComboBox.with_area (CellArea area)
Creates a new empty ComboBox using
areato layout cells. - public ComboBox.with_area_and_entry (CellArea area)
Creates a new empty ComboBox with an entry.
- public ComboBox.with_entry ()
Creates a new empty ComboBox with an entry.
- public ComboBox.with_model (TreeModel model)
Creates a new ComboBox with the model initialized to
model. - public ComboBox.with_model_and_entry (TreeModel model)
Creates a new empty ComboBox with an entry and with the model initialized to
model.
Methods:
- public int get_active ()
Returns the index of the currently active item, or -1 if there’s no active item.
- public unowned string? get_active_id ()
Returns the ID of the active row of this.
- public bool get_active_iter (out TreeIter iter)
Sets
iterto point to the currently active item, if any item is active. - public bool get_add_tearoffs ()
Gets the current value of the add_tearoffs property.
- public SensitivityType get_button_sensitivity ()
Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model.
- public int get_column_span_column ()
Returns the column with column span information for this.
- public int get_entry_text_column ()
Returns the column which this is using to get the strings from to display in the internal entry.
- public bool get_focus_on_click ()
Returns whether the combo box grabs focus when it is clicked with the mouse.
- public bool get_has_entry ()
Returns whether the combo box has an entry.
- public int get_id_column ()
Returns the column which this is using to get string IDs for values from.
- public unowned TreeModel get_model ()
Returns the TreeModel which is acting as data source for this.
- public unowned Object get_popup_accessible ()
Gets the accessible object corresponding to the combo box’s popup.
- public bool get_popup_fixed_width ()
Gets whether the popup uses a fixed width matching the allocated width of the combo box.
- public unowned TreeViewRowSeparatorFunc get_row_separator_func ()
Returns the current row separator function.
- public int get_row_span_column ()
Returns the column with row span information for this.
- public unowned string get_title ()
Gets the current title of the menu in tearoff mode.
- public int get_wrap_width ()
Returns the wrap width which is used to determine the number of columns for the popup menu.
- public void popup_for_device (Device device)
Pops up the menu or dropdown list of this, the popup window will be grabbed so only
deviceand its associated pointer/keyboard are the only Devices able to send events to it. - public void set_active (int index_)
Sets the active item of this to be the item at
index. - public bool set_active_id (string? active_id)
Changes the active row of this to the one that has an ID equal to
active_id, or unsets the active row ifactive_idis null . - public void set_active_iter (TreeIter? iter)
Sets the current active item to be the one referenced by
iter, or unsets the active item ifiteris null. - public void set_add_tearoffs (bool add_tearoffs)
Sets whether the popup menu should have a tearoff menu item.
- public void set_button_sensitivity (SensitivityType sensitivity)
Sets whether the dropdown button of the combo box should be always sensitive (gtk_sensitivity_on), never sensitive (gtk_sensitivity_off) or only if there is at least one item to display (gtk_sensitivity_auto).
- public void set_column_span_column (int column_span)
Sets the column with column span information for this to be
column_span. - public void set_entry_text_column (int text_column)
Sets the model column which this should use to get strings from to be
text_column. - public void set_focus_on_click (bool focus_on_click)
Sets whether the combo box will grab focus when it is clicked with the mouse.
- public void set_id_column (int id_column)
Sets the model column which this should use to get string IDs for values from.
- public void set_model (TreeModel? model)
Sets the model used by this to be
model. - public void set_popup_fixed_width (bool fixed)
Specifies whether the popup’s width should be a fixed width matching the allocated width of the combo box.
- public void set_row_separator_func (owned TreeViewRowSeparatorFunc func)
Sets the row separator function, which is used to determine whether a row should be drawn as a separator.
- public void set_row_span_column (int row_span)
Sets the column with row span information for this to be
row_span. - public void set_title (string title)
Sets the menu’s title in tearoff mode.
- public void set_wrap_width (int width)
Sets the wrap width of this to be
width.
Signals:
- public virtual signal void changed ()
The changed signal is emitted when the active item is changed.
- public virtual signal string format_entry_text (string path)
For combo boxes that are created with an entry (See GtkComboBox:has-entry).
- public signal void move_active (ScrollType scroll_type)
The move_active signal is a keybinding signal which gets emitted to move the active selection.
- public signal bool popdown ()
The popdown signal is a keybinding signal which gets emitted to popdown the combo box list.
- public signal void popup ()
The popup signal is a keybinding signal which gets emitted to popup the combo box list.
Inherited Members:
- accel_closures_changed
- activate
- add_accelerator
- add_device_events
- add_events
- add_mnemonic_label
- add_tick_callback
- adjust_baseline_allocation
- adjust_baseline_request
- adjust_size_allocation
- adjust_size_request
- app_paintable
- bind_template_callback_full
- bind_template_child_full
- button_press_event
- button_release_event
- can_activate_accel
- can_default
- can_focus
- child_focus
- child_notify
- class_path
- composite_child
- composited_changed
- compute_expand
- compute_expand_internal
- configure_event
- create_pango_context
- create_pango_layout
- damage_event
- delete_event
- destroy
- destroy_event
- destroyed
- device_is_shadowed
- direction_changed
- dispatch_child_properties_changed
- double_buffered
- drag_begin
- drag_data_delete
- drag_data_get
- drag_data_received
- drag_drop
- drag_end
- drag_failed
- drag_leave
- drag_motion
- draw
- draw_to_cairo_context
- ensure_style
- enter_notify_event
- error_bell
- event
- event_after
- events
- expand
- find_style_property
- focus
- focus_in_event
- focus_on_click
- focus_out_event
- freeze_child_notify
- get_accessible
- get_action_group
- get_allocated_baseline
- get_allocated_height
- get_allocated_size
- get_allocated_width
- get_allocation
- get_ancestor
- get_app_paintable
- get_can_default
- get_can_focus
- get_child_requisition
- get_child_visible
- get_clip
- get_clipboard
- get_composite_name
- get_css_name
- get_default_direction
- get_default_style
- get_device_enabled
- get_device_events
- get_direction
- get_display
- get_double_buffered
- get_events
- get_focus_on_click
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_has_window
- get_hexpand
- get_hexpand_set
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_left
- get_margin_right
- get_margin_start
- get_margin_top
- get_modifier_mask
- get_modifier_style
- get_no_show_all
- get_opacity
- get_pango_context
- get_parent
- get_parent_window
- get_path
- get_pointer
- get_preferred_height
- get_preferred_height_and_baseline_for_width
- get_preferred_height_for_width
- get_preferred_height_for_width_internal
- get_preferred_height_internal
- get_preferred_size
- get_preferred_width
- get_preferred_width_for_height
- get_preferred_width_for_height_internal
- get_preferred_width_internal
- get_realized
- get_receives_default
- get_request_mode
- get_requisition
- get_root_window
- get_scale_factor
- get_screen
- get_sensitive
- get_settings
- get_size_request
- get_state
- get_state_flags
- get_style
- get_style_context
- get_support_multidevice
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_tooltip_window
- get_toplevel
- get_valign
- get_valign_with_baseline
- get_vexpand
- get_vexpand_set
- get_visible
- get_visual
- get_window
- grab_broken_event
- grab_default
- grab_focus
- grab_notify
- halign
- has_default
- has_focus
- has_grab
- has_rc_style
- has_screen
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- hide_on_delete
- hierarchy_changed
- in_destruction
- init_template
- input_shape_combine_region
- insert_action_group
- install_style_property
- install_style_property_parser
- intersect
- is_ancestor
- is_composited
- is_drawable
- is_focus
- is_sensitive
- is_toplevel
- is_visible
- key_press_event
- key_release_event
- keynav_failed
- leave_notify_event
- list_accel_closures
- list_action_prefixes
- list_mnemonic_labels
- list_style_properties
- map
- map_event
- margin
- margin_bottom
- margin_end
- margin_left
- margin_right
- margin_start
- margin_top
- mnemonic_activate
- modify_base
- modify_bg
- modify_cursor
- modify_fg
- modify_font
- modify_style
- modify_text
- motion_notify_event
- move_focus
- name
- no_show_all
- opacity
- override_background_color
- override_color
- override_cursor
- override_font
- override_symbolic_color
- parent
- parent_set
- path
- pop_composite_child
- popup_menu
- property_notify_event
- proximity_in_event
- proximity_out_event
- push_composite_child
- query_tooltip
- queue_allocate
- queue_compute_expand
- queue_draw
- queue_draw_area
- queue_draw_region
- queue_resize
- queue_resize_no_redraw
- realize
- receives_default
- region_intersect
- register_window
- remove_accelerator
- remove_mnemonic_label
- remove_tick_callback
- render_icon
- render_icon_pixbuf
- reparent
- reset_rc_styles
- reset_style
- scale_factor
- screen_changed
- scroll_event
- selection_clear_event
- selection_get
- selection_notify_event
- selection_received
- selection_request_event
- send_expose
- send_focus_change
- sensitive
- set_accel_path
- set_accessible_role
- set_accessible_type
- set_allocation
- set_app_paintable
- set_can_default
- set_can_focus
- set_child_visible
- set_clip
- set_composite_name
- set_connect_func
- set_css_name
- set_default_direction
- set_device_enabled
- set_device_events
- set_direction
- set_double_buffered
- set_events
- set_focus_on_click
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_has_window
- set_hexpand
- set_hexpand_set
- set_mapped
- set_margin_bottom
- set_margin_end
- set_margin_left
- set_margin_right
- set_margin_start
- set_margin_top
- set_no_show_all
- set_opacity
- set_parent
- set_parent_window
- set_realized
- set_receives_default
- set_redraw_on_allocate
- set_sensitive
- set_size_request
- set_state
- set_state_flags
- set_style
- set_support_multidevice
- set_template
- set_template_from_resource
- set_tooltip_markup
- set_tooltip_text
- set_tooltip_window
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- set_visual
- set_window
- shape_combine_region
- show
- show_all
- show_help
- show_now
- size_allocate
- size_allocate_with_baseline
- size_request
- state_changed
- state_flags_changed
- style
- style_attach
- style_get
- style_get_property
- style_get_valist
- style_set
- style_updated
- thaw_child_notify
- tooltip_markup
- tooltip_text
- touch_event
- translate_coordinates
- trigger_tooltip_query
- unmap
- unmap_event
- unparent
- unrealize
- unregister_window
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visibility_notify_event
- visible
- width_request
- window_state_event