Top |
int | active | Read / Write |
gboolean | add-tearoffs | Read / Write |
GtkSensitivityType | button-sensitivity | Read / Write |
int | column-span-column | Read / Write |
int | entry-text-column | Read / Write |
gboolean | focus-on-click | Read / Write |
gboolean | has-entry | Read / Write / Construct Only |
gboolean | has-frame | Read / Write |
GtkTreeModel * | model | Read / Write |
gboolean | popup-shown | Read |
int | row-span-column | Read / Write |
char * | tearoff-title | Read / Write |
int | wrap-width | Read / Write |
GObject ╰── GInitiallyUnowned ╰── GtkObject ╰── GtkWidget ╰── GtkContainer ╰── GtkBin ╰── GtkComboBox ├── GtkComboBoxEntry ╰── GtkComboBoxText
GtkComboBox implements AtkImplementorIface, GtkBuildable, GtkCellLayout and GtkCellEditable.
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 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.
To allow the user to enter values not in the model, the 'has-entry'
property allows the GtkComboBox to contain a GtkEntry. This entry
can be accessed by calling gtk_bin_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.
GtkWidget *
gtk_combo_box_new (void
);
Creates a new empty GtkComboBox.
Since: 2.4
GtkWidget *
gtk_combo_box_new_with_entry (void
);
Creates a new empty GtkComboBox with an entry.
Since: 2.24
GtkWidget *
gtk_combo_box_new_with_model (GtkTreeModel *model
);
Creates a new GtkComboBox with the model initialized to model
.
Since: 2.4
GtkWidget *
gtk_combo_box_new_with_model_and_entry
(GtkTreeModel *model
);
Creates a new empty GtkComboBox with an entry
and with the model initialized to model
.
Since: 2.24
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
void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box
,gint 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.
Since: 2.4
gint
gtk_combo_box_get_row_span_column (GtkComboBox *combo_box
);
Returns the column with row span information for combo_box
.
Since: 2.6
void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box
,gint 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.
Since: 2.4
gint
gtk_combo_box_get_column_span_column (GtkComboBox *combo_box
);
Returns the column with column span information for combo_box
.
Since: 2.6
void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box
,gint 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.
Since: 2.4
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
gtk_tree_path_get_indices (path)[0]
, where
path
is the GtkTreePath of the active item.
An integer which is the index of the currently active item, or -1 if there's no active item.
Since: 2.4
void gtk_combo_box_set_active (GtkComboBox *combo_box
,gint index_
);
Sets the active item of combo_box
to be the item at index
.
combo_box |
||
index_ |
An index in the model passed during construction, or -1 to have no active item |
Since: 2.4
gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box
,GtkTreeIter *iter
);
Sets iter
to point to the currently active item, if any item is active.
Otherwise, iter
is left unchanged.
Since: 2.4
void gtk_combo_box_set_active_iter (GtkComboBox *combo_box
,GtkTreeIter *iter
);
Sets the current active item to be the one referenced by iter
, or
unsets the active item if iter
is NULL
.
Since: 2.4
GtkTreeModel *
gtk_combo_box_get_model (GtkComboBox *combo_box
);
Returns the GtkTreeModel which is acting as data source for combo_box
.
Since: 2.4
void gtk_combo_box_set_model (GtkComboBox *combo_box
,GtkTreeModel *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.
Note that this function does not clear the cell renderers, you have to
call gtk_cell_layout_clear()
yourself if you need to set up different
cell renderers for the new model.
Since: 2.4
GtkWidget *
gtk_combo_box_new_text (void
);
gtk_combo_box_new_text
has been deprecated since version 2.24 and should not be used in newly-written code.
Use GtkComboBoxText
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: gtk_combo_box_append_text()
,
gtk_combo_box_insert_text()
, gtk_combo_box_prepend_text()
and
gtk_combo_box_remove_text()
.
Since: 2.4
void gtk_combo_box_append_text (GtkComboBox *combo_box
,const gchar *text
);
gtk_combo_box_append_text
has been deprecated since version 2.24 and should not be used in newly-written code.
Use GtkComboBoxText
Appends string
to the list of strings stored in combo_box
. Note that
you can only use this function with combo boxes constructed with
gtk_combo_box_new_text()
.
Since: 2.4
void gtk_combo_box_insert_text (GtkComboBox *combo_box
,gint position
,const gchar *text
);
gtk_combo_box_insert_text
has been deprecated since version 2.24 and should not be used in newly-written code.
Use GtkComboBoxText
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 gtk_combo_box_new_text()
.
combo_box |
A GtkComboBox constructed using |
|
position |
An index to insert |
|
text |
A string |
Since: 2.4
void gtk_combo_box_prepend_text (GtkComboBox *combo_box
,const gchar *text
);
gtk_combo_box_prepend_text
has been deprecated since version 2.24 and should not be used in newly-written code.
Use GtkComboBoxText
Prepends string
to the list of strings stored in combo_box
. Note that
you can only use this function with combo boxes constructed with
gtk_combo_box_new_text()
.
Since: 2.4
void gtk_combo_box_remove_text (GtkComboBox *combo_box
,gint position
);
gtk_combo_box_remove_text
has been deprecated since version 2.24 and should not be used in newly-written code.
Use GtkComboBoxText
Removes the string at position
from combo_box
. Note that you can only use
this function with combo boxes constructed with gtk_combo_box_new_text()
.
combo_box |
A GtkComboBox constructed with |
|
position |
Index of the item to remove |
Since: 2.4
gchar *
gtk_combo_box_get_active_text (GtkComboBox *combo_box
);
gtk_combo_box_get_active_text
has been deprecated since version 2.24 and should not be used in newly-written code.
If you used this with a GtkComboBox constructed with
gtk_combo_box_new_text()
then you should now use GtkComboBoxText and
gtk_combo_box_text_get_active_text()
instead. Or if you used this with a
GtkComboBoxEntry then you should now use GtkComboBox with
“has-entry” as TRUE
and use
gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combobox))).
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 gtk_combo_box_new_text()
and with
GtkComboBoxEntrys.
Since: 2.6
void
gtk_combo_box_popup (GtkComboBox *combo_box
);
Pops up the menu or dropdown list of combo_box
.
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Since: 2.4
void
gtk_combo_box_popdown (GtkComboBox *combo_box
);
Hides the menu or dropdown list of combo_box
.
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
Since: 2.4
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
GtkTreeViewRowSeparatorFunc
gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box
);
Returns the current row separator function.
Since: 2.6
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 NULL
, no separators are drawn. This is the default value.
combo_box |
||
func |
||
data |
user data to pass to |
[allow-none] |
destroy |
destroy notifier for |
[allow-none] |
Since: 2.6
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
gboolean
gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box
);
Gets the current value of the :add-tearoffs property.
void gtk_combo_box_set_title (GtkComboBox *combo_box
,const gchar *title
);
Sets the menu's title in tearoff mode.
Since: 2.10
const gchar *
gtk_combo_box_get_title (GtkComboBox *combo_box
);
Gets the current title of the menu in tearoff mode. See
gtk_combo_box_set_add_tearoffs()
.
the menu's title in tearoff mode. This is an internal copy of the string which must not be freed.
Since: 2.10
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
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 gtk_combo_box_set_focus_on_click()
.
Since: 2.6
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 (GTK_SENSITIVITY_ON
), never sensitive (GTK_SENSITIVITY_OFF
)
or only if there is at least one item to display (GTK_SENSITIVITY_AUTO
).
Since: 2.14
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.
GTK_SENSITIVITY_ON
if the dropdown button
is sensitive when the model is empty, GTK_SENSITIVITY_OFF
if the button is always insensitive or
GTK_SENSITIVITY_AUTO
if it is only sensitive as long as
the model has one item to be selected.
Since: 2.14
gboolean
gtk_combo_box_get_has_entry (GtkComboBox *combo_box
);
Returns whether the combo box has an entry.
Since: 2.24
void gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box
,gint text_column
);
Sets the model column which combo_box
should use to get strings from
to be text_column
. The column text_column
in the model of combo_box
must be of type G_TYPE_STRING
.
This is only relevant if combo_box
has been created with
“has-entry” as TRUE
.
Since: 2.24
gint
gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box
);
Returns the column which combo_box
is using to get the strings
from to display in the internal entry.
Since: 2.24
“active”
property “active” int
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 GtkTreePath of the active item.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 2.4
“add-tearoffs”
property “add-tearoffs” gboolean
The add-tearoffs property controls whether generated menus have tearoff menu items.
Note that this only affects menu style combo boxes.
Owner: GtkComboBox
Flags: Read / Write
Default value: FALSE
Since: 2.6
“button-sensitivity”
property“button-sensitivity” GtkSensitivityType
Whether the dropdown button is sensitive when the model is empty.
Owner: GtkComboBox
Flags: Read / Write
Default value: GTK_SENSITIVITY_AUTO
Since: 2.14
“column-span-column”
property “column-span-column” int
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. The value in that column for each item
will determine how many columns that item will span in the popup.
Therefore, values in this column must be greater than zero, and the sum of
an item’s column position + span should not exceed “wrap-width”.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 2.4
“entry-text-column”
property “entry-text-column” int
The column in the combo box's model to associate with strings from the entry
if the combo was created with “has-entry” = TRUE
.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 2.24
“focus-on-click”
property “focus-on-click” gboolean
Whether the combo box grabs focus when it is clicked with the mouse.
Owner: GtkComboBox
Flags: Read / Write
Default value: TRUE
“has-entry”
property “has-entry” gboolean
Whether the combo box has an entry.
Owner: GtkComboBox
Flags: Read / Write / Construct Only
Default value: FALSE
Since: 2.24
“has-frame”
property “has-frame” gboolean
The has-frame property controls whether a frame is drawn around the entry.
Owner: GtkComboBox
Flags: Read / Write
Default value: TRUE
Since: 2.6
“model”
property“model” GtkTreeModel *
The model from which the combo box takes the values shown in the list.
Owner: GtkComboBox
Flags: Read / Write
Since: 2.4
“popup-shown”
property “popup-shown” gboolean
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.
Owner: GtkComboBox
Flags: Read
Default value: FALSE
Since: 2.10
“row-span-column”
property “row-span-column” int
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. The value in that column for each item
will determine how many rows that item will span in the popup. Therefore,
values in this column must be greater than zero.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= -1
Default value: -1
Since: 2.4
“tearoff-title”
property “tearoff-title” char *
A title that may be displayed by the window manager when the popup is torn-off.
Owner: GtkComboBox
Flags: Read / Write
Default value: NULL
Since: 2.10
“wrap-width”
property “wrap-width” int
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.
Owner: GtkComboBox
Flags: Read / Write
Allowed values: >= 0
Default value: 0
Since: 2.4
“appears-as-list”
style property “appears-as-list” gboolean
Whether dropdowns should look like lists rather than menus.
Owner: GtkComboBox
Flags: Read
Default value: FALSE
“arrow-size”
style property “arrow-size” int
Sets the minimum size of the arrow in the combo box. Note that the arrow size is coupled to the font size, so in case a larger font is used, the arrow will be larger than set by arrow size.
Owner: GtkComboBox
Flags: Read
Allowed values: >= 0
Default value: 15
Since: 2.12
“shadow-type”
style property“shadow-type” GtkShadowType
Which kind of shadow to draw around the combo box.
Owner: GtkComboBox
Flags: Read
Default value: GTK_SHADOW_NONE
Since: 2.12
“changed”
signalvoid user_function (GtkComboBox *widget, gpointer user_data)
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 gtk_combo_box_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.
widget |
the object which received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 2.4
“move-active”
signalvoid user_function (GtkComboBox *widget, GtkScrollType scroll_type, gpointer user_data)
The ::move-active signal is a
keybinding signalwhich gets emitted to move the active selection.
widget |
the object that received the signal |
|
scroll_type |
||
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 2.12
“popdown”
signalgboolean user_function (GtkComboBox *button, gpointer user_data)
The ::popdown signal is a
keybinding signalwhich gets emitted to popdown the combo box list.
The default bindings for this signal are Alt+Up and Escape.
button |
the object which received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 2.12
“popup”
signalvoid user_function (GtkComboBox *widget, gpointer user_data)
The ::popup signal is a
keybinding signalwhich gets emitted to popup the combo box list.
The default binding for this signal is Alt+Down.
widget |
the object that received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
Since: 2.12