Synopsis
#include <gtk/gtk.h>
GtkComboBox;
GtkWidget* gtk_combo_box_new (void);
GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model);
gint gtk_combo_box_get_wrap_width (GtkComboBox *combo_box);
void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
gint width);
gint gtk_combo_box_get_row_span_column (GtkComboBox *combo_box);
void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
gint row_span);
gint gtk_combo_box_get_column_span_column
(GtkComboBox *combo_box);
void gtk_combo_box_set_column_span_column
(GtkComboBox *combo_box,
gint column_span);
gint gtk_combo_box_get_active (GtkComboBox *combo_box);
void gtk_combo_box_set_active (GtkComboBox *combo_box,
gint index_);
gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
GtkTreeIter *iter);
void gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
GtkTreeIter *iter);
GtkTreeModel* gtk_combo_box_get_model (GtkComboBox *combo_box);
void gtk_combo_box_set_model (GtkComboBox *combo_box,
GtkTreeModel *model);
GtkWidget* gtk_combo_box_new_text (void);
void gtk_combo_box_append_text (GtkComboBox *combo_box,
const gchar *text);
void gtk_combo_box_insert_text (GtkComboBox *combo_box,
gint position,
const gchar *text);
void gtk_combo_box_prepend_text (GtkComboBox *combo_box,
const gchar *text);
void gtk_combo_box_remove_text (GtkComboBox *combo_box,
gint position);
gchar* gtk_combo_box_get_active_text (GtkComboBox *combo_box);
void gtk_combo_box_popup (GtkComboBox *combo_box);
void gtk_combo_box_popdown (GtkComboBox *combo_box);
AtkObject* gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box);
GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func
(GtkComboBox *combo_box);
void gtk_combo_box_set_row_separator_func
(GtkComboBox *combo_box,
GtkTreeViewRowSeparatorFunc func,
gpointer data,
GDestroyNotify destroy);
void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
gboolean add_tearoffs);
gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box);
void gtk_combo_box_set_title (GtkComboBox *combo_box,
const gchar *title);
const gchar* gtk_combo_box_get_title (GtkComboBox *combo_box);
void gtk_combo_box_set_focus_on_click (GtkComboBox *combo,
gboolean focus_on_click);
gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
void gtk_combo_box_set_button_sensitivity
(GtkComboBox *combo_box,
GtkSensitivityType sensitivity);
GtkSensitivityType gtk_combo_box_get_button_sensitivity
(GtkComboBox *combo_box);
Object Hierarchy
GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkContainer
+----GtkBin
+----GtkComboBox
+----GtkComboBoxEntry
Implemented InterfacesGtkComboBox implements AtkImplementorIface, GtkBuildable, GtkCellEditable and GtkCellLayout. Properties"active" gint : Read / Write "add-tearoffs" gboolean : Read / Write "button-sensitivity" GtkSensitivityType : Read / Write "column-span-column" gint : Read / Write "focus-on-click" gboolean : Read / Write "has-frame" gboolean : Read / Write "model" GtkTreeModel* : Read / Write "popup-shown" gboolean : Read "row-span-column" gint : Read / Write "tearoff-title" gchar* : Read / Write "wrap-width" gint : Read / Write Style Properties"appears-as-list" gboolean : Read "arrow-size" gint : Read "shadow-type" GtkShadowType : Read Signals"changed" : Run Last "move-active" : Run Last / Action "popdown" : Run Last / Action "popup" : Run Last / Action DescriptionA 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 GtkOptionMenu, or similar to a Windows-style combo box. Unlike its predecessors GtkCombo and GtkOptionMenu, 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 GtkCellLayout 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.
In addition to the model-view API, GtkComboBox offers a simple API which
is suitable for text-only combo boxes, and hides the complexity of managing
the data in a model. It consists of the functions Detailsgtk_combo_box_new ()GtkWidget* gtk_combo_box_new (void); Creates a new empty GtkComboBox.
Since 2.4 gtk_combo_box_new_with_model ()GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model);
Creates a new GtkComboBox with the model initialized to
Since 2.4 gtk_combo_box_get_wrap_width ()gint gtk_combo_box_get_wrap_width (GtkComboBox *combo_box); 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.
Since 2.6 gtk_combo_box_set_wrap_width ()void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, gint width);
Sets the wrap width of
Since 2.4 gtk_combo_box_get_row_span_column ()gint gtk_combo_box_get_row_span_column (GtkComboBox *combo_box);
Returns the column with row span information for
Since 2.6 gtk_combo_box_set_row_span_column ()void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, gint row_span);
Sets the column with row span information for
Since 2.4 gtk_combo_box_get_column_span_column ()gint gtk_combo_box_get_column_span_column
(GtkComboBox *combo_box);
Returns the column with column span information for
Since 2.6 gtk_combo_box_set_column_span_column ()void gtk_combo_box_set_column_span_column
(GtkComboBox *combo_box,
gint column_span);
Sets the column with column span information for
Since 2.4 gtk_combo_box_get_active ()gint gtk_combo_box_get_active (GtkComboBox *combo_box);
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
Since 2.4 gtk_combo_box_set_active ()void gtk_combo_box_set_active (GtkComboBox *combo_box, gint index_);
Sets the active item of
Since 2.4 gtk_combo_box_get_active_iter ()gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box, GtkTreeIter *iter);
Sets
Since 2.4 gtk_combo_box_set_active_iter ()void gtk_combo_box_set_active_iter (GtkComboBox *combo_box, GtkTreeIter *iter);
Sets the current active item to be the one referenced by
Since 2.4 gtk_combo_box_get_model ()GtkTreeModel* gtk_combo_box_get_model (GtkComboBox *combo_box);
Returns the GtkTreeModel which is acting as data source for
Since 2.4 gtk_combo_box_set_model ()void gtk_combo_box_set_model (GtkComboBox *combo_box, GtkTreeModel *model);
Sets the model used by
Note that this function does not clear the cell renderers, you have to
call
Since 2.4 gtk_combo_box_new_text ()GtkWidget* gtk_combo_box_new_text (void);
Convenience function which constructs a new text combo box, which is a
GtkComboBox just displaying strings. If you use this function to create
a text combo box, you should only manipulate its data source with the
following convenience functions:
Since 2.4 gtk_combo_box_append_text ()void gtk_combo_box_append_text (GtkComboBox *combo_box, const gchar *text);
Appends
Since 2.4 gtk_combo_box_insert_text ()void gtk_combo_box_insert_text (GtkComboBox *combo_box, gint position, const gchar *text);
Inserts
Since 2.4 gtk_combo_box_prepend_text ()void gtk_combo_box_prepend_text (GtkComboBox *combo_box, const gchar *text);
Prepends
Since 2.4 gtk_combo_box_remove_text ()void gtk_combo_box_remove_text (GtkComboBox *combo_box, gint position);
Removes the string at
Since 2.4 gtk_combo_box_get_active_text ()gchar* gtk_combo_box_get_active_text (GtkComboBox *combo_box);
Returns the currently active string in
Since 2.6 gtk_combo_box_popup ()void gtk_combo_box_popup (GtkComboBox *combo_box);
Pops up the menu or dropdown list of This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Since 2.4 gtk_combo_box_popdown ()void gtk_combo_box_popdown (GtkComboBox *combo_box);
Hides the menu or dropdown list of This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Since 2.4 gtk_combo_box_get_popup_accessible ()AtkObject* gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box); Gets the accessible object corresponding to the combo box's popup. This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Since 2.6 gtk_combo_box_get_row_separator_func ()GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box); Returns the current row separator function.
Since 2.6 gtk_combo_box_set_row_separator_func ()void gtk_combo_box_set_row_separator_func
(GtkComboBox *combo_box,
GtkTreeViewRowSeparatorFunc func,
gpointer data,
GDestroyNotify destroy);
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
Since 2.6 gtk_combo_box_set_add_tearoffs ()void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box, gboolean add_tearoffs); Sets whether the popup menu should have a tearoff menu item.
Since 2.6 gtk_combo_box_get_add_tearoffs ()gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box); Gets the current value of the :add-tearoffs property.
gtk_combo_box_set_title ()void gtk_combo_box_set_title (GtkComboBox *combo_box, const gchar *title); Sets the menu's title in tearoff mode.
Since 2.10 gtk_combo_box_get_title ()const gchar* gtk_combo_box_get_title (GtkComboBox *combo_box);
Gets the current title of the menu in tearoff mode. See
Since 2.10 gtk_combo_box_set_focus_on_click ()void gtk_combo_box_set_focus_on_click (GtkComboBox *combo, gboolean 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.
Since 2.6 gtk_combo_box_get_focus_on_click ()gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
Returns whether the combo box grabs focus when it is clicked
with the mouse. See
Since 2.6 gtk_combo_box_set_button_sensitivity ()void gtk_combo_box_set_button_sensitivity
(GtkComboBox *combo_box,
GtkSensitivityType sensitivity);
Sets whether the dropdown button of the combo box should be
always sensitive (
Since 2.14 gtk_combo_box_get_button_sensitivity ()GtkSensitivityType gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box); Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model.
Since 2.14 Property DetailsThe
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
the object which received the signal |
|
user data set when the signal handler was connected. |
Since 2.4
"move-active" signalvoid user_function (GtkComboBox *widget, GtkScrollType scroll_type, gpointer user_data) : Run Last / Action
The ::move-active signal is a keybinding signal which gets emitted to move the active selection.
|
the object that received the signal |
|
a GtkScrollType |
|
user data set when the signal handler was connected. |
Since 2.12
"popdown" signalgboolean user_function (GtkComboBox *button, gpointer user_data) : Run Last / Action
The ::popdown signal is a keybinding signal which gets emitted to popdown the combo box list.
The default bindings for this signal are Alt+Up and Escape.
|
the object which received the signal |
|
user data set when the signal handler was connected. |
Since 2.12
"popup" signalvoid user_function (GtkComboBox *widget, gpointer user_data) : Run Last / Action
The ::popup signal is a keybinding signal which gets emitted to popup the combo box list.
The default binding for this signal is Alt+Down.
|
the object that received the signal |
|
user data set when the signal handler was connected. |
Since 2.12