Top | ![]() |
![]() |
![]() |
![]() |
GtkWidget * | gtk_drop_down_new () |
void | gtk_drop_down_set_from_strings () |
void | gtk_drop_down_set_model () |
GListModel * | gtk_drop_down_get_model () |
void | gtk_drop_down_set_selected () |
guint | gtk_drop_down_get_selected () |
void | gtk_drop_down_set_factory () |
GtkListItemFactory * | gtk_drop_down_get_factory () |
void | gtk_drop_down_set_list_factory () |
GtkListItemFactory * | gtk_drop_down_get_list_factory () |
void | gtk_drop_down_set_expression () |
GtkExpression * | gtk_drop_down_get_expression () |
void | gtk_drop_down_set_enable_search () |
gboolean | gtk_drop_down_get_enable_search () |
gboolean | enable-search | Read / Write |
GtkExpression * | expression | Read / Write |
GtkListItemFactory * | factory | Read / Write |
GtkListItemFactory * | list-factory | Read / Write |
GListModel * | model | Read / Write |
guint | selected | Read / Write |
GtkDropDown implements AtkImplementorIface, GtkBuildable and GtkConstraintTarget.
GtkDropDown is a widget that allows the user to choose an item from a list of options. The GtkDropDown displays the selected choice.
The options are given to GtkDropDown in the form of GListModel,
and how the individual options are represented is determined by
a GtkListItemFactory. The default factory displays simple strings,
and expects to obtain these from the model by evaluating an expression
that has to be provided via gtk_drop_down_set_expression()
.
The convenience method gtk_drop_down_set_from_strings()
can be used
to set up a model that is populated from an array of strings and
an expression for obtaining those strings.
GtkDropDown can optionally allow search in the popup, which is
useful if the list of options is long. To enable the search entry,
use gtk_drop_down_set_enable_search()
.
The GtkDropDown implementation of the GtkBuildable interface supports
adding items directly using the <items> element and specifying <item>
elements for each item. Using <items> is equivalent to calling
gtk_drop_down_set_from_strings()
. Each <item> element supports
the regular translation attributes “translatable”, “context”
and “comments”.
Here is a UI definition fragment specifying GtkDropDown items:
1 2 3 4 5 6 7 |
<object class="GtkDropDown"> <items> <item translatable="yes">Factory</item> <item translatable="yes">Home</item> <item translatable="yes">Subway</item> </items> </object> |
GtkWidget *
gtk_drop_down_new (void
);
Creates a new empty GtkDropDown.
You most likely want to call gtk_drop_down_set_factory()
to
set up a way to map its items to widgets and gtk_drop_down_set_model()
to set a model to provide items next.
void gtk_drop_down_set_from_strings (GtkDropDown *self
,const char *const *texts
);
Populates self
with the strings in text
,
by creating a suitable model and factory.
void gtk_drop_down_set_model (GtkDropDown *self
,GListModel *model
);
Sets the GListModel to use.
GListModel *
gtk_drop_down_get_model (GtkDropDown *self
);
Gets the model that provides the displayed items.
void gtk_drop_down_set_selected (GtkDropDown *self
,guint position
);
Selects the item at the given position.
guint
gtk_drop_down_get_selected (GtkDropDown *self
);
Gets the position of the selected item.
void gtk_drop_down_set_factory (GtkDropDown *self
,GtkListItemFactory *factory
);
Sets the GtkListItemFactory to use for populating list items.
GtkListItemFactory *
gtk_drop_down_get_factory (GtkDropDown *self
);
Gets the factory that's currently used to populate list items.
The factory returned by this function is always used for the item in the button. It is also used for items in the popup if “list-factory” is not set.
void gtk_drop_down_set_list_factory (GtkDropDown *self
,GtkListItemFactory *factory
);
Sets the GtkListItemFactory to use for populating list items in the popup.
GtkListItemFactory *
gtk_drop_down_get_list_factory (GtkDropDown *self
);
Gets the factory that's currently used to populate list items in the popup.
void gtk_drop_down_set_expression (GtkDropDown *self
,GtkExpression *expression
);
Sets the expression that gets evaluated to obtain strings from items when searching in the popup. The expression must have a value type of GTK_TYPE_STRING.
GtkExpression *
gtk_drop_down_get_expression (GtkDropDown *self
);
Gets the expression set with gtk_drop_down_set_expression()
.
void gtk_drop_down_set_enable_search (GtkDropDown *self
,gboolean enable_search
);
Sets whether a search entry will be shown in the popup that allows to search for items in the list.
Note that “expression” must be set for search to work.
gboolean
gtk_drop_down_get_enable_search (GtkDropDown *self
);
Returns whether search is enabled.
“enable-search”
property “enable-search” gboolean
Whether to show a search entry in the popup.
Note that search requires “expression” to be set.
Owner: GtkDropDown
Flags: Read / Write
Default value: FALSE
“expression”
property“expression” GtkExpression *
An expression to evaluate to obtain strings to match against the search term (see “enable-search”). If “factory” is not set, the expression is also used to bind strings to labels produced by a default factory.
[type GtkExpression]
Owner: GtkDropDown
Flags: Read / Write
“factory”
property“factory” GtkListItemFactory *
Factory for populating list items.
Owner: GtkDropDown
Flags: Read / Write
“list-factory”
property“list-factory” GtkListItemFactory *
The factory for populating list items in the popup.
If this is not set, “factory” is used.
Owner: GtkDropDown
Flags: Read / Write
“model”
property “model” GListModel *
Model for the displayed items.
Owner: GtkDropDown
Flags: Read / Write
“selected”
property “selected” guint
The position of the selected item in “model”, or GTK_INVALID_LIST_POSITION if no item is selected.
Owner: GtkDropDown
Flags: Read / Write
Default value: 4294967295