Added new method hildon_touch_selector_center_on_index
authorAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 30 Jul 2009 14:16:09 +0000 (16:16 +0200)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 30 Jul 2009 14:18:02 +0000 (16:18 +0200)
* 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)

ChangeLog
hildon/hildon-touch-selector.c
hildon/hildon-touch-selector.h

index 3b9c17a..f5cadce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-07-28  Alejandro Pinheiro <apinheiro@igalia.com>
+
+       * 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  <agarcia@igalia.com>
 
        * hildon/hildon-text-view.c
index 38c0781..518924c 100644 (file)
@@ -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);
+}
index cdc83f9..df236b7 100644 (file)
@@ -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);