ComboBox
Object Hierarchy:
Description:
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, GtkComboBoxText
offers a simple alternative. Both GtkComboBox and GtkComboBoxText can contain an entry.
Namespace: Gtk
Package: gtk+-2.0
Content:
Properties:
-
public int active { set; get; }
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 TreePath of the active item.
-
public bool add_tearoffs { set; get; }
The add-tearoffs property controls whether generated menus have tearoff menu items.
-
public SensitivityType button_sensitivity { set; get; }
Whether the dropdown button is sensitive when the model is empty.
-
public int column_span_column { set; get; }
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 bool focus_on_click { set; get; }
-
public bool has_frame { set; get; }
The has-frame property controls whether a frame is drawn around the entry.
-
public TreeModel model { set; get; }
The model from which the combo box takes the values shown in the list.
-
public bool popup_shown { get; }
Whether the combo boxes dropdown is popped up. Note that this property is mainly useful, because it
allows you to connect to notify::popup-shown.
-
public int row_span_column { set; get; }
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 { set; owned get; }
A title that may be displayed by the window manager when the popup is torn-off.
-
public int wrap_width { set; get; }
If wrap-width is set to a positive value, the list will be displayed in multiple columns, the number
of columns is determined by wrap-width.
Creation methods:
Methods:
-
public void append_text (string text)
Appends string to the list of strings stored in combo_box. Note that you can
only use this function with combo boxes constructed with
ComboBox.text.
-
public int get_active ()
Returns the index of the currently active item, or -1 if there's no active item. If the model is a
non-flat treemodel, and the active item is not an immediate child of the root of the tree, this function returns
gtk_tree_path_get_indices (path)[0], where path is the TreePath of the
active item.
-
public bool get_active_iter (out TreeIter iter)
Sets iter to point to the current active item, if it exists.
-
public virtual unowned string get_active_text ()
Returns the currently active string in combo_box or null if none is
selected. Note that you can only use this function with combo boxes constructed with
ComboBox.text and with
ComboBoxEntrys.
-
public bool get_add_tearoffs ()
-
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 combo_box.
-
public bool get_focus_on_click ()
Returns whether the combo box grabs focus when it is clicked with the mouse. See
set_focus_on_click.
-
public weak TreeModel get_model ()
Returns the TreeModel which is acting as data
source for combo_box.
-
public weak Object get_popup_accessible ()
Gets the accessible object corresponding to the combo box's popup.
-
public weak 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 combo_box.
-
public unowned string get_title ()
-
public int get_wrap_width ()
Returns the wrap width which is used to determine the number of columns for the popup menu. If the
wrap width is larger than 1, the combo box is in table mode.
-
public void insert_text (int position, string text)
Inserts string at position in the list of strings stored in combo_box
. Note that you can only use this function with combo boxes constructed with
ComboBox.text.
-
public void prepend_text (string text)
Prepends string to the list of strings stored in combo_box. Note that you
can only use this function with combo boxes constructed with
ComboBox.text.
-
public void remove_text (int position)
Removes the string at position from combo_box. Note that you can only use
this function with combo boxes constructed with ComboBox.text.
-
public void set_active (int index_)
Sets the active item of combo_box to be the item at index.
-
public void set_active_iter (TreeIter iter)
Sets the current active item to be the one referenced by iter, or unsets the active item
if iter is 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 combo_box to be column_span
. The column span column contains integers which indicate how many columns an item should span.
-
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. Making mouse clicks not
grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.
-
public void set_model (TreeModel? model)
Sets the model used by combo_box to be model. Will unset a previously set
model (if applicable). If model is null, then it will unset the model.
-
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. If the row separator function is null, no separators are drawn. This is the default value.
-
public void set_row_span_column (int row_span)
Sets the column with row span information for combo_box to be row_span. The
row span column contains integers which indicate how many rows an item should 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 combo_box to be width. The wrap width is basically
the preferred number of columns when you want the popup to be layed out in a table.
Signals:
-
public virtual void changed ()
The changed signal is 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 set_active_iter. It
will also be emitted while typing into a GtkComboBoxEntry, as well as when selecting an item from the GtkComboBoxEntry's list.
-
public virtual void move_active (ScrollType p0)
-
public virtual bool popdown ()
-
public virtual void popup ()