Hildon Reference Manual | ||||
---|---|---|---|---|
gchar* (*HildonTouchSelectorPrintFunc) (HildonTouchSelector *selector, gpointer user_data); HildonTouchSelector; enum HildonTouchSelectorSelectionMode; GtkWidget* hildon_touch_selector_new (void); GtkWidget* hildon_touch_selector_new_text (void); void hildon_touch_selector_append_text (HildonTouchSelector *selector, const gchar *text); void hildon_touch_selector_prepend_text (HildonTouchSelector *selector, const gchar *text); void hildon_touch_selector_insert_text (HildonTouchSelector *selector, gint position, const gchar *text); HildonTouchSelectorColumn* hildon_touch_selector_append_text_column (HildonTouchSelector *selector, GtkTreeModel *model, gboolean center); HildonTouchSelectorColumn* hildon_touch_selector_append_column (HildonTouchSelector *selector, GtkTreeModel *model, GtkCellRenderer *cell_renderer, ...); void hildon_touch_selector_set_column_attributes (HildonTouchSelector *selector, gint num_column, GtkCellRenderer *cell_renderer, ...); gboolean hildon_touch_selector_remove_column (HildonTouchSelector *selector, gint column); gint hildon_touch_selector_get_num_columns (HildonTouchSelector *selector); void hildon_touch_selector_set_column_selection_mode (HildonTouchSelector *selector, HildonTouchSelectorSelectionMode mode); HildonTouchSelectorSelectionMode hildon_touch_selector_get_column_selection_mode (HildonTouchSelector *selector); HildonTouchSelectorColumn* hildon_touch_selector_get_column (HildonTouchSelector *selector, gint column); void hildon_touch_selector_set_active (HildonTouchSelector *selector, gint column, gint index); gint hildon_touch_selector_get_active (HildonTouchSelector *selector, gint column); gboolean hildon_touch_selector_get_selected (HildonTouchSelector *selector, gint column, GtkTreeIter *iter); void hildon_touch_selector_center_on_selected (HildonTouchSelector *selector); void hildon_touch_selector_select_iter (HildonTouchSelector *selector, gint column, GtkTreeIter *iter, gboolean scroll_to); void hildon_touch_selector_unselect_iter (HildonTouchSelector *selector, gint column, GtkTreeIter *iter); void hildon_touch_selector_unselect_all (HildonTouchSelector *selector, gint column); GList* hildon_touch_selector_get_selected_rows (HildonTouchSelector *selector, gint column); void hildon_touch_selector_set_model (HildonTouchSelector *selector, gint column, GtkTreeModel *model); GtkTreeModel* hildon_touch_selector_get_model (HildonTouchSelector *selector, gint column); gchar* hildon_touch_selector_get_current_text (HildonTouchSelector *selector); void hildon_touch_selector_set_print_func (HildonTouchSelector *selector, HildonTouchSelectorPrintFunc func); HildonTouchSelectorPrintFunc hildon_touch_selector_get_print_func (HildonTouchSelector *selector); void hildon_touch_selector_set_print_func_full (HildonTouchSelector *selector, HildonTouchSelectorPrintFunc func, gpointer user_data, GDestroyNotify destroy_func); gboolean hildon_touch_selector_has_multiple_selection (HildonTouchSelector *selector); void hildon_touch_selector_optimal_size_request (HildonTouchSelector *selector, GtkRequisition *requisition);
GObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkContainer +----GtkBox +----GtkVBox +----HildonTouchSelector +----HildonTouchSelectorEntry +----HildonTimeSelector +----HildonDateSelector
"has-multiple-selection" gboolean : Read "hildon-ui-mode" HildonUIMode : Read / Write "initial-scroll" gboolean : Read / Write / Construct
HildonTouchSelector is a selector widget, that allows users to select items from one to many predefined lists. It is very similar to GtkComboBox, but with several individual pannable columns.
Normally, you would use HildonTouchSelector together with a HildonPickerDialog activated from a button. For the most common cases, you should use HildonPickerButton.
The contents of each HildonTouchSelector column are stored in a
GtkTreeModel. To add a new column to a HildonTouchSelector, use
hildon_touch_selector_append_column()
. If you want to add a
text-only column, without special attributes, use
hildon_touch_selector_append_text_column()
.
It is highly recommended that you use only one column
HildonTouchSelectors.
If you only need a text only, one column selector, you can create it with
hildon_touch_selector_new_text()
and populate with
hildon_touch_selector_append_text()
, hildon_touch_selector_prepend_text()
,
and hildon_touch_selector_insert_text()
.
If you need a selector widget that also accepts user inputs, you can use HildonTouchSelectorEntry.
The current selection has a string representation. In the most common cases, each column model will contain a text column. You can configure which column in particular using the HildonTouchSelectorColumn property "text-column"
You can get this string representation using
hildon_touch_selector_get_current_text()
.
You can configure how the selection is printed with
hildon_touch_selector_set_print_func()
, that sets the current hildon touch
selector print function. The widget has a default print function, that
uses the "text-column" property on each
HildonTouchSelectorColumn to compose the final representation.
If you create the selector using hildon_touch_selector_new_text()
you
don't need to take care of this property, as the model is created internally.
If you create the selector using hildon_touch_selector_new()
, you
need to specify properly the property for your custom model in order to get a
non-empty string representation, or define your custom print function.
Example 10. Creating a HildonTouchSelector
void selection_changed (HildonTouchSelector * selector, gpointer *user_data) { gchar *current_selection = NULL; current_selection = hildon_touch_selector_get_current_text (selector); g_debug ("Current selection : %s", current_selection); } static GtkWidget * create_customized_selector () { GtkWidget *selector = NULL; GSList *icon_list = NULL; GtkListStore *store_icons = NULL; GSList *item = NULL; GtkCellRenderer *renderer = NULL; HildonTouchSelectorColumn *column = NULL; selector = hildon_touch_selector_new (); icon_list = gtk_stock_list_ids (); store_icons = gtk_list_store_new (1, G_TYPE_STRING); for (item = icon_list; item; item = g_slist_next (item)) { GtkTreeIter iter; gchar *label = item->data; gtk_list_store_append (store_icons, &iter); gtk_list_store_set (store_icons, &iter, 0, label, -1); g_free (label); } g_slist_free (icon_list); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_renderer_set_fixed_size (renderer, -1, 100); column = hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector), GTK_TREE_MODEL (store_icons), renderer, "stock-id", 0, NULL); hildon_touch_selector_column_set_text_column (column, 0); hildon_touch_selector_set_column_selection_mode (HILDON_TOUCH_SELECTOR (selector), HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE); g_signal_connect (G_OBJECT (selector), "changed", G_CALLBACK (selection_changed), NULL); return selector; } static GtkWidget * create_simple_selector () { GtkWidget *selector = NULL; gint i; selector = hildon_touch_selector_new_text (); hildon_touch_selector_set_column_selection_mode (HILDON_TOUCH_SELECTOR (selector), HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE); g_signal_connect (G_OBJECT (selector), "changed", G_CALLBACK (selection_changed), NULL); for (i = 1; i <= 10 ; i++) { gchar *label = g_strdup_printf ("Item %d", i); hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), label); g_free (label); } return selector; }
gchar* (*HildonTouchSelectorPrintFunc) (HildonTouchSelector *selector, gpointer user_data);
selector : |
|
user_data : |
|
Returns : |
typedef enum { HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE, HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE } HildonTouchSelectorSelectionMode;
Describes the selection mode of a HildonTouchSelector.
GtkWidget* hildon_touch_selector_new (void);
Creates a new empty HildonTouchSelector.
Returns : | a new HildonTouchSelector. |
Since 2.2
GtkWidget* hildon_touch_selector_new_text (void);
Creates a HildonTouchSelector with a single text column that
can be populated conveniently through hildon_touch_selector_append_text()
,
hildon_touch_selector_prepend_text()
, hildon_touch_selector_insert_text()
.
Returns : | A new HildonTouchSelector |
Since 2.2
void hildon_touch_selector_append_text (HildonTouchSelector *selector, const gchar *text);
Appends a new entry in a HildonTouchSelector created with
hildon_touch_selector_new_text()
.
selector : |
A HildonTouchSelector. |
text : |
a non NULL text string.
|
Since 2.2
void hildon_touch_selector_prepend_text (HildonTouchSelector *selector, const gchar *text);
Prepends a new entry in a HildonTouchSelector created with
hildon_touch_selector_new_text()
.
selector : |
A HildonTouchSelector. |
text : |
a non NULL text string.
|
Since 2.2
void hildon_touch_selector_insert_text (HildonTouchSelector *selector, gint position, const gchar *text);
Inserts a new entry in a particular position of a
HildonTouchSelector created with hildon_touch_selector_new_text()
.
selector : |
a HildonTouchSelector. |
position : |
the position to insert text .
|
text : |
A non NULL text string.
|
Since 2.2
HildonTouchSelectorColumn* hildon_touch_selector_append_text_column (HildonTouchSelector *selector, GtkTreeModel *model, gboolean center);
Equivalent to hildon_touch_selector_append_column()
, but using a
default text cell renderer. This is the most common use case of the
widget.
selector : |
a HildonTouchSelector |
model : |
a GtkTreeModel with data for the column |
center : |
whether to center the text on the column |
Returns : | the new column added, NULL otherwise. |
Since 2.2
HildonTouchSelectorColumn* hildon_touch_selector_append_column (HildonTouchSelector *selector, GtkTreeModel *model, GtkCellRenderer *cell_renderer, ...);
This functions adds a new column to the widget, whose data will
be obtained from the model. Only widgets added this way should used on
the selection logic, the print function, the "changed"
signal, etc. Internally, a GtkTreeView will be added to the widget, using
model
as the data source.
You can optionally pass a GtkCellRenderer in cell_renderer
,
together with a NULL
-terminated list of pairs property/value, in
the same way you would use gtk_tree_view_column_set_attributes()
.
This will pack cell_renderer
at the start of the column, expanded
by default. If you prefer not to add it this way, you can simply
pass NULL
to cell_renderer
and use the GtkCellLayout interface
on the returned HildonTouchSelectorColumn to set your
renderers. Please note that the returned HildonTouchSelectorColumn
is owned by selector
, you shouldn't unref it after setting it
up.
Initially, the returned HildonTouchSelectorColumn will have its
"text-column" property unset. You should set
it to a column in model
with type G_TYPE_STRING
. See
hildon_touch_selector_column_set_text_column()
.
This method could change the current "hildon-ui-mode".
HILDON_UI_MODE_NORMAL
is only allowed with one column, so if the selector
is in this mode, and a additional column is added,
"hildon-ui-mode" will change to HILDON_UI_MODE_EDIT
.
selector : |
a HildonTouchSelector |
model : |
the GtkTreeModel with the data of the column |
cell_renderer : |
The GtkCellRenderer where to draw each row contents. |
... : |
a NULL -terminated pair of attributes and column numbers.
|
Returns : | the new column added added, NULL otherwise.
|
Since 2.2
void hildon_touch_selector_set_column_attributes (HildonTouchSelector *selector, gint num_column, GtkCellRenderer *cell_renderer, ...);
hildon_touch_selector_set_column_attributes
is deprecated and should not be used in newly-written code. HildonTouchSelectorColumn implements GtkCellLayout, use this
interface instead. See
hildon_touch_selector_get_column()
.
Sets the attributes for the given column. The attributes must be given
in attribute/column pairs, just like in gtk_tree_view_column_set_attributes()
.
All existing attributes are removed and replaced with the new ones.
selector : |
a HildonTouchSelector |
num_column : |
the number of the column whose attributes we're setting |
cell_renderer : |
the GtkCellRendere we're setting the attributes of |
... : |
A NULL -terminated list of attributes.
|
Since 2.2
gboolean hildon_touch_selector_remove_column (HildonTouchSelector *selector, gint column);
Removes a column from selector
.
selector : |
a HildonTouchSelector |
column : |
the position of the column to be removed |
Returns : | TRUE if the column was removed, FALSE otherwise
|
Since 2.2
gint hildon_touch_selector_get_num_columns (HildonTouchSelector *selector);
Gets the number of columns in the HildonTouchSelector.
selector : |
a HildonTouchSelector |
Returns : | the number of columns in selector .
|
Since 2.2
void hildon_touch_selector_set_column_selection_mode (HildonTouchSelector *selector, HildonTouchSelectorSelectionMode mode);
Sets the selection mode for selector
. See HildonTouchSelectorSelectionMode.
The new mode
will be set, but take into into account that the
HildonTouchSelectorSelectionMode is ignored if the selector
"hildon-ui-mode" property is set to HILDON_UI_MODE_NORMAL
selector : |
a HildonTouchSelector |
mode : |
the HildonTouchSelectorMode for selector
|
Since 2.2
HildonTouchSelectorSelectionMode hildon_touch_selector_get_column_selection_mode (HildonTouchSelector *selector);
Gets the selection mode of selector
.
selector : |
a HildonTouchSelector |
Returns : | one of HildonTouchSelectorSelectionMode |
Since 2.2
HildonTouchSelectorColumn* hildon_touch_selector_get_column (HildonTouchSelector *selector, gint column);
Use this method to retrieve a HildonTouchSelectorColumn. Then, you can use the GtkCellLayout interface to set up the layout of the column.
selector : |
A HildonTouchSelector |
column : |
a column number |
Returns : | the column -th HildonTouchSelectorColumn in selector
|
Since 2.2
void hildon_touch_selector_set_active (HildonTouchSelector *selector, gint column, gint index);
Sets the active item of the HildonTouchSelector to index
. The
column number is taken from column
.
selector
must be in HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE
selector : |
a HildonTouchSelector |
column : |
column number |
index : |
the index of the item to select, or -1 to have no active item |
Since 2.2
gint hildon_touch_selector_get_active (HildonTouchSelector *selector, gint column);
Returns the index of the currently active item in column number
column
, or -1 if there's no active item.
selector
must be in HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE
selector : |
a HildonTouchSelector |
column : |
column number |
Returns : | an integer which is the index of the currently active item, or -1 if there's no active item. |
Since 2.2
gboolean hildon_touch_selector_get_selected (HildonTouchSelector *selector, gint column, GtkTreeIter *iter);
Sets iter
to the currently selected node on the nth-column, if selection is
set to HILDON_TOUCH_SELECTOR_SINGLE
or HILDON_TOUCH_SELECTOR_MULTIPLE
with
a column different that the first one. iter
may be NULL
if you just want to
test if selection has any selected items.
This function will not work if selection is in
HILDON_TOUCH_SELECTOR_MULTIPLE
mode and the column is the first one.
See gtk_tree_selection_get_selected()
for more information.
selector : |
a HildonTouchSelector |
column : |
the column number we want to get the element |
iter : |
GtkTreeIter currently selected |
Returns : | TRUE if iter was correctly set, FALSE otherwise
|
Since 2.2
void hildon_touch_selector_center_on_selected (HildonTouchSelector *selector);
Ensures all the columns in a HildonTouchSelector show a selected
item. If one of the columns is in
HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE
mode, that column
will be scrolled to ensure the selected item that is closest to the
currently visible area is shown.
selector : |
a HildonTouchSelector |
Since 2.2
void hildon_touch_selector_select_iter (HildonTouchSelector *selector, gint column, GtkTreeIter *iter, gboolean scroll_to);
Sets the currently selected item in the column column
to the one pointed by iter
,
optionally smoothly scrolling to it.
selector : |
a HildonTouchSelector |
column : |
the column to selects |
iter : |
the GtkTreeIter to be selected |
scroll_to : |
whether to smoothly scroll to the item |
Since 2.2
void hildon_touch_selector_unselect_iter (HildonTouchSelector *selector, gint column, GtkTreeIter *iter);
Unselect the item pointed by iter
in the column column
selector : |
a HildonTouchSelector |
column : |
the column to unselects from |
iter : |
the GtkTreeIter to be unselected |
Since 2.2
void hildon_touch_selector_unselect_all (HildonTouchSelector *selector, gint column);
Unselects all the selected items in the column column
.
selector : |
a HildonTouchSelector |
column : |
the position of the column to get the selected rows from |
Since 2.2
GList* hildon_touch_selector_get_selected_rows (HildonTouchSelector *selector, gint column);
Creates a list of GtkTreePaths of all selected rows in a column. Additionally,
if you to plan to modify the model after calling this function, you may
want to convert the returned list into a list of GtkTreeRowReferences. To do this,
you can use gtk_tree_row_reference_new()
.
See gtk_tree_selection_get_selected_rows()
for more information.
selector : |
a HildonTouchSelector |
column : |
the position of the column to get the selected rows from |
Returns : | A new GList containing a GtkTreePath for each selected row in the column column .
|
Since 2.2
void hildon_touch_selector_set_model (HildonTouchSelector *selector, gint column, GtkTreeModel *model);
Sets the GtkTreeModel for a particular column in model
.
selector : |
a HildonTouchSelector |
column : |
the position of the column to set the model to |
model : |
a GtkTreeModel |
Since 2.2
GtkTreeModel* hildon_touch_selector_get_model (HildonTouchSelector *selector, gint column);
Gets the model of a column of selector
.
selector : |
a HildonTouchSelector |
column : |
the position of the column in selector
|
Returns : | the GtkTreeModel for the column column of selector .
|
Since 2.2
gchar* hildon_touch_selector_get_current_text (HildonTouchSelector *selector);
Returns a string representing the currently selected items for
each column of selector
. See hildon_touch_selector_set_print_func()
.
selector : |
a HildonTouchSelector |
Returns : | a newly allocated string. |
Since 2.2
void hildon_touch_selector_set_print_func (HildonTouchSelector *selector, HildonTouchSelectorPrintFunc func);
Sets the function to be used by hildon_touch_selector_get_current_text()
.
See hildon_touch_selector_set_print_func_full()
.
selector : |
a HildonTouchSelector |
func : |
a HildonTouchSelectorPrintFunc function |
Since 2.2
HildonTouchSelectorPrintFunc hildon_touch_selector_get_print_func (HildonTouchSelector *selector);
Gets the HildonTouchSelectorPrintFunc currently used. See
hildon_touch_selector_set_print_func()
.
selector : |
a HildonTouchSelector |
Returns : | a HildonTouchSelectorPrintFunc or NULL if the default
one is currently used.
|
void hildon_touch_selector_set_print_func_full (HildonTouchSelector *selector, HildonTouchSelectorPrintFunc func, gpointer user_data, GDestroyNotify destroy_func);
Sets the function to be used by hildon_touch_selector_get_current_text()
to produce a text representation of the currently selected items in selector
.
The default function will return a concatenation of comma separated items
selected in each column in selector
. Use this to override this method if you
need a particular representation for your application.
selector : |
a HildonTouchSelector |
func : |
a HildonTouchSelectorPrintFunc function |
user_data : |
a pointer to user data or NULL
|
destroy_func : |
a callback for freeing the user data or NULL
|
Since 2.2
gboolean hildon_touch_selector_has_multiple_selection (HildonTouchSelector *selector);
Determines whether selector
is complex enough to actually require an
extra selection step than only picking an item. This is normally TRUE
if selector
has multiple columns, multiple selection, or when it is a
more complex widget, like HildonTouchSelectorEntry.
This information is useful for widgets containing a HildonTouchSelector, like HildonPickerDialog, that could need a "Done" button, in case that its internal HildonTouchSelector has multiple columns, for instance.
selector : |
A HildonTouchSelector |
Returns : | TRUE if selector requires multiple selection steps.
|
Since 2.2
void hildon_touch_selector_optimal_size_request (HildonTouchSelector *selector, GtkRequisition *requisition);
Gets the optimal size request of the touch selector. This function is mostly intended for dialog implementations that include a HildonTouchSelector and want to optimize the screen real state, for example, when you want a dialog to show as much of the selector, avoiding any extra empty space below the selector.
See HildonPickerDialog implementation for an example.
This function is oriented to be used in the size_request of a dialog or window, if you are not sure do not use it.
There is a precondition to this function: Since this function does not
call the "size_request" method, it can only be used when you know that
gtk_widget_size_request()
has been called since the last time a resize was
queued.
selector : |
a HildonTouchSelector |
requisition : |
a GtkRequisition |
Since 2.2
"has-multiple-selection"
property"has-multiple-selection" gboolean : Read
Whether the widget has multiple selection (like multiple columns, multiselection mode, or multiple internal widgets) and therefore it may need a confirmation button, for instance.
Default value: FALSE
"hildon-ui-mode"
property"hildon-ui-mode" HildonUIMode : Read / Write
Specifies which UI mode to use in the internal treeviews. A setting
of HILDON_UI_MODE_NORMAL
will cause these tree view to disable selections
and emit row-activated as soon as a row is pressed. You can use the
method hildon_touch_selector_get_last_activated_row()
to get it. When
HILDON_UI_MODE_EDIT
is set, selections can be made according to the
setting of the mode on GtkTreeSelection.
Toggling this property will cause the tree view to select an appropriate selection mode if not already done.
Default value: HILDON_UI_MODE_EDIT
Since Hildon 2.2
"initial-scroll"
property"initial-scroll" gboolean : Read / Write / Construct
Whether to scroll to thecurrent selection whenthe selector is firstshown.
Default value: TRUE
"changed"
signalvoid user_function (HildonTouchSelector *widget, gint column, gpointer user_data) : Run Last
The "changed" signal is emitted when the active item on any column is changed.
This can be due to the user selecting a different item from the list, or
due to a call to hildon_touch_selector_select_iter()
on one of the columns.
widget : |
the object which received the signal |
column : |
the number of the column that has changed |
user_data : |
user data set when the signal handler was connected. |
Since 2.2
"columns-changed"
signalvoid user_function (HildonTouchSelector *selector, gpointer user_data) : Run Last
The "columns-changed" signal is emitted when the number of columns in the HildonTouchSelector change.
selector : |
the object which received the signal |
user_data : |
user data set when the signal handler was connected. |
Since 2.2