From: Alejandro PiƱeiro Date: Thu, 30 Jul 2009 14:16:09 +0000 (+0200) Subject: Added new method hildon_touch_selector_center_on_index X-Git-Tag: 2.1.92-1~2 X-Git-Url: https://vcs.maemo.org/git/?p=hildon;a=commitdiff_plain;h=1ad71be0497a9ccbfbd4f1df4694798ebdea20d5 Added new method hildon_touch_selector_center_on_index * hildon/hildon-touch-selector.[ch] (hildon_touch_selector_center_on_index): New method that allows to center on a item not selected Fixes NB#130291 (New HildonTouchSelector API is required to center on any column item) --- diff --git a/ChangeLog b/ChangeLog index 3b9c17a..f5cadce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-07-28 Alejandro Pinheiro + + * hildon/hildon-touch-selector.[ch] + (hildon_touch_selector_center_on_index): New method that allows to center + on a item not selected + + Fixes NB#130291 (New HildonTouchSelector API is required to center on + any column item) + 2009-07-29 Alberto Garcia * hildon/hildon-text-view.c diff --git a/hildon/hildon-touch-selector.c b/hildon/hildon-touch-selector.c index 38c0781..518924c 100644 --- a/hildon/hildon-touch-selector.c +++ b/hildon/hildon-touch-selector.c @@ -2279,6 +2279,19 @@ hildon_touch_selector_get_column (HildonTouchSelector * selector, * will be scrolled to ensure the selected item that is closest to the * currently visible area is shown. * + * The #HildonTouchSelector:initial-scroll property configure the widget + * in order to use this function at the first show. + * + * Take into account that the element is not centered until the widget is + * realized. If the widget is not realized when the function is called, it + * will be postponed. If you call this functions several times before the + * widgets is realized, only the last one will be used. + * + * This behaviour includes any call to hildon_touch_selector_center_on_index(), + * so take care calling this functions, or with the + * #HildonTouchSelector:initial-scroll property in order to get centered on the + * proper element. + * * Since: 2.2 **/ void @@ -2472,3 +2485,47 @@ hildon_touch_selector_get_last_activated_row (HildonTouchSelector *selector, return NULL; } } + + +/** + * hildon_touch_selector_center_on_index: + * @selector: a #HildonTouchSelector + * @column: column number + * @index: the index of the item to center on + * + * Ensures that the column number @column shows the element @index + * + * This is similar to hildon_touch_selector_center_on_selected() but with the + * difference that allows to center on a column item not selected. + * + * Take into account that the element is not centered until the widget is + * realized. If the widget is not realized when the function is called, it will + * be postponed. If you call this function several times before the widget is + * realized, only the last one will be used. + * + * This behaviour includes any call to hildon_touch_selector_center_on_selected(). + * Check this function for more tips. + * + * Since: 2.2 + **/ +void +hildon_touch_selector_center_on_index (HildonTouchSelector *selector, + gint column, + gint index) +{ + HildonTouchSelectorColumn *current_column = NULL; + GtkTreePath *path = NULL; + + g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector)); + g_return_if_fail ((column >= 0) && (column < hildon_touch_selector_get_num_columns (selector))); + g_return_if_fail (index >= 0); + + current_column = g_slist_nth_data (selector->priv->columns, column); + + path = gtk_tree_path_new_from_indices (index, -1); + + hildon_touch_selector_scroll_to (current_column, + current_column->priv->tree_view, + path); + gtk_tree_path_free (path); +} diff --git a/hildon/hildon-touch-selector.h b/hildon/hildon-touch-selector.h index cdc83f9..df236b7 100644 --- a/hildon/hildon-touch-selector.h +++ b/hildon/hildon-touch-selector.h @@ -216,6 +216,10 @@ void hildon_touch_selector_center_on_selected (HildonTouchSelector *selector); void +hildon_touch_selector_center_on_index (HildonTouchSelector *selector, + gint column, + gint index); +void hildon_touch_selector_optimal_size_request (HildonTouchSelector *selector, GtkRequisition *requisition);