aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Piñeiro <apinheiro@igalia.com>2009-06-03 21:15:51 +0200
committerAlejandro Piñeiro <apinheiro@igalia.com>2009-06-25 14:20:40 +0200
commitae7c25e920f7773325a1f48b23fd86018c03f2ae (patch)
tree5184ad52b77059ddbfdc8132af4ea5c8c1020305
parent50d9c2ed3c66110399b422ef6bd390b6526a111a (diff)
Allow to use HILDON_UI_MODE_NORMAL on the HildonTouchSelector
* hildon/hildon-picker-dialog.c: (selection_completed): take into account HILDON_UI_MODE_NORMAL * hildon/hildon-touch-selector.c (hildon_touch_selector_init): Initialize hildon-ui-mode (hildon_touch_selector_row_activated): new callback for the "row-activated" signal, in order to save the last activated (hildon_touch_selector_check_ui_mode_coherence): new method that checks if the current hildon-ui-mode is coherent with the touch selector (hildon_touch_selector_class_init) (hildon_touch_selector_get_property) (hildon_touch_selector_set_property) Added "hildon-ui-mode" property (disconnect_model_handlers): renamed to clean_column (hildon_touch_selector_remove): use clean_column function (_create_new_column): use the hildon-ui-mode to create the treeview, and only select the first element on HILDON_UI_MODE_EDIT (hildon_touch_selector_column_init): Initialize last_activate (hildon_touch_selector_append_column): check that the touch selector is coherent with the current hildon-ui-mode (hildon_touch_selector_get_hildon_ui_mode) (hildon_touch_selector_set_hildon_ui_mode) Added a getter/setter for the hildon-ui-mode property (hildon_touch_selector_get_last_activated_row): Added this method in order to get the last activated row * examples/hildon-touch-selector-normal-mode-example.c New example, that shows how to use the HildonTouchSelector in HILDON_UI_MODE_NORMAL Fixes: NB#95685 (Add field dialog should use HILDON_UI_MODE_NORMAL), using Kristian Rietveld <kris@lanedo.com> advices
-rw-r--r--ChangeLog33
-rw-r--r--examples/Makefile.am7
-rw-r--r--examples/hildon-touch-selector-normal-mode-example.c156
-rw-r--r--hildon/hildon-picker-dialog.c6
-rw-r--r--hildon/hildon-touch-selector.c230
-rw-r--r--hildon/hildon-touch-selector.h10
6 files changed, 435 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ef74ed..368835b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2009-06-25 Alejandro Pinheiro <apinheiro@igalia.com>
+
+ * hildon/hildon-picker-dialog.c:
+ (selection_completed): take into account HILDON_UI_MODE_NORMAL
+ * hildon/hildon-touch-selector.c
+ (hildon_touch_selector_init): Initialize hildon-ui-mode
+ (hildon_touch_selector_row_activated): new callback for the
+ "row-activated" signal, in order to save the last activated
+ (hildon_touch_selector_check_ui_mode_coherence): new method that checks
+ if the current hildon-ui-mode is coherent with the touch selector
+ (hildon_touch_selector_class_init)
+ (hildon_touch_selector_get_property)
+ (hildon_touch_selector_set_property)
+ Added "hildon-ui-mode" property
+ (disconnect_model_handlers): renamed to clean_column
+ (hildon_touch_selector_remove): use clean_column function
+ (_create_new_column): use the hildon-ui-mode to create the treeview, and
+ only select the first element on HILDON_UI_MODE_EDIT
+ (hildon_touch_selector_column_init): Initialize last_activate
+ (hildon_touch_selector_append_column): check that the touch selector
+ is coherent with the current hildon-ui-mode
+ (hildon_touch_selector_get_hildon_ui_mode)
+ (hildon_touch_selector_set_hildon_ui_mode)
+ Added a getter/setter for the hildon-ui-mode property
+ (hildon_touch_selector_get_last_activated_row): Added this method in
+ order to get the last activated row.
+ * examples/hildon-touch-selector-normal-mode-example.c
+ New example, that shows how to use the HildonTouchSelector in
+ HILDON_UI_MODE_NORMAL
+
+ Fixes: NB#95685 (Add field dialog should use HILDON_UI_MODE_NORMAL), using
+ Kristian Rietveld <kris@lanedo.com> advices
+
2009-06-25 Claudio Saavedra <csaavedra@igalia.com>
* hildon/hildon-time-selector.c: (update_format_policy): Do
diff --git a/examples/Makefile.am b/examples/Makefile.am
index aa7826d..cf21a0c 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -36,6 +36,7 @@ EXAMPLES = hildon-window-example \
hildon-time-button-example \
hildon-check-button-example \
hildon-touch-selector-example \
+ hildon-touch-selector-normal-mode-example \
hildon-touch-selector-multi-cells-example \
hildon-touch-selector-entry-example \
hildon-progress-indicator-example \
@@ -444,6 +445,12 @@ hildon_touch_selector_example_CFLAGS = $(HILDON_OBJ_CFLAGS) \
$(EXTRA_CFLAGS)
hildon_touch_selector_example_SOURCES = hildon-touch-selector-example.c
+# Hildon touch picker using HILDON_UI_MODE_NORMAL
+hildon_touch_selector_normal_mode_example_LDADD = $(HILDON_OBJ_LIBS)
+hildon_touch_selector_normal_mode_example_CFLAGS = $(HILDON_OBJ_CFLAGS) \
+ $(EXTRA_CFLAGS)
+hildon_touch_selector_normal_mode_example_SOURCES = hildon-touch-selector-normal-mode-example.c
+
# Hildon touch picker with several cells per column
hildon_touch_selector_multi_cells_example_LDADD = $(HILDON_OBJ_LIBS)
hildon_touch_selector_multi_cells_example_CFLAGS = $(HILDON_OBJ_CFLAGS) \
diff --git a/examples/hildon-touch-selector-normal-mode-example.c b/examples/hildon-touch-selector-normal-mode-example.c
new file mode 100644
index 0000000..d62a72d
--- /dev/null
+++ b/examples/hildon-touch-selector-normal-mode-example.c
@@ -0,0 +1,156 @@
+/*
+ * This file is a part of hildon examples
+ *
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * Author: Alejandro Pinheiro <apinheiro@igalia.com>
+ * Based on hildon-touch-selector-example.c
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+static GtkWidget *create_selector ();
+static GtkWidget *get_visible_content (GtkWidget * window);
+
+static GtkWindow *parent_window = NULL;
+
+static GtkWidget *label = NULL;
+
+static void
+value_changed (HildonPickerButton * button,
+ gpointer user_data)
+{
+ HildonTouchSelector *selector;
+ gchar *aux_string = NULL;
+ GtkTreePath *path = NULL;
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+
+ selector = hildon_picker_button_get_selector (button);
+ model = hildon_touch_selector_get_model (selector, 0);
+ path = hildon_touch_selector_get_last_activated_row (selector, 0);
+
+ if (path != NULL) {
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, 0, &aux_string, -1);
+
+ gtk_label_set_text (GTK_LABEL (label), aux_string);
+ }
+
+ gtk_tree_path_free (path);
+}
+
+static GtkWidget *
+create_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);
+ g_object_set (G_OBJECT (column), "text-column", 0, NULL);
+
+ hildon_touch_selector_set_hildon_ui_mode (HILDON_TOUCH_SELECTOR (selector),
+ HILDON_UI_MODE_NORMAL);
+
+
+ return selector;
+}
+
+static GtkWidget *
+get_visible_content (GtkWidget * window)
+{
+ GtkWidget *result = NULL;
+ GtkWidget *button = NULL;
+ GtkWidget *selector;
+
+ label = gtk_label_new ("Here we are going to put the selection");
+
+ button = hildon_picker_button_new (HILDON_SIZE_AUTO, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+ hildon_button_set_title (HILDON_BUTTON (button), "Click me..");
+ selector = create_selector ();
+ hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+ HILDON_TOUCH_SELECTOR (selector));
+
+ g_signal_connect (G_OBJECT (button), "value-changed",
+ G_CALLBACK (value_changed), window);
+
+ result = gtk_vbox_new (FALSE, 6);
+
+ gtk_container_add (GTK_CONTAINER (result), button);
+ gtk_container_add (GTK_CONTAINER (result), label);
+
+ return result;
+}
+
+int
+main (int argc, char **argv)
+{
+ HildonProgram *program = NULL;
+ GtkWidget *window = NULL;
+
+ hildon_gtk_init (&argc, &argv);
+
+ program = hildon_program_get_instance ();
+ g_set_application_name
+ ("hildon-touch-selector normal mode example");
+
+ window = hildon_stackable_window_new ();
+ parent_window = GTK_WINDOW (window);
+ hildon_program_add_window (program, HILDON_WINDOW (window));
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), 6);
+
+ GtkWidget *vbox = get_visible_content (window);
+
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
+
+ g_signal_connect (G_OBJECT (window), "destroy",
+ G_CALLBACK (gtk_main_quit), NULL);
+ gtk_widget_show_all (GTK_WIDGET (window));
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/hildon/hildon-picker-dialog.c b/hildon/hildon-picker-dialog.c
index 4402bd2..0647e7d 100644
--- a/hildon/hildon-picker-dialog.c
+++ b/hildon/hildon-picker-dialog.c
@@ -416,9 +416,15 @@ selection_completed (HildonPickerDialog *dialog)
GList *list;
gint i, n_cols;
gboolean all_selected = TRUE;
+ HildonUIMode mode = HILDON_UI_MODE_NORMAL;
priv = HILDON_PICKER_DIALOG_GET_PRIVATE (dialog);
+ mode = hildon_touch_selector_get_hildon_ui_mode (HILDON_TOUCH_SELECTOR (priv->selector));
+ if (mode == HILDON_UI_MODE_NORMAL) {
+ return TRUE;
+ }
+
n_cols = hildon_touch_selector_get_num_columns (HILDON_TOUCH_SELECTOR (priv->selector));
for (i = 0; i < n_cols; i++) {
list = hildon_touch_selector_get_selected_rows (HILDON_TOUCH_SELECTOR (priv->selector), i);
diff --git a/hildon/hildon-touch-selector.c b/hildon/hildon-touch-selector.c
index f0614da..38c0781 100644
--- a/hildon/hildon-touch-selector.c
+++ b/hildon/hildon-touch-selector.c
@@ -198,6 +198,7 @@ struct _HildonTouchSelectorColumnPrivate
GtkTreePath *initial_path;
GtkWidget *panarea; /* the pannable widget */
+ GtkTreeRowReference *last_activated;
};
struct _HildonTouchSelectorPrivate
@@ -211,12 +212,15 @@ struct _HildonTouchSelectorPrivate
HildonTouchSelectorPrintFunc print_func;
gpointer print_user_data;
GDestroyNotify print_destroy_func;
+
+ HildonUIMode hildon_ui_mode;
};
enum
{
PROP_HAS_MULTIPLE_SELECTION = 1,
- PROP_INITIAL_SCROLL
+ PROP_INITIAL_SCROLL,
+ PROP_HILDON_UI_MODE
};
enum
@@ -250,6 +254,12 @@ static void hildon_touch_selector_remove (GtkContainer * container,
static void _row_tapped_cb (GtkTreeView * tree_view,
GtkTreePath * path,
gpointer user_data);
+static void
+hildon_touch_selector_row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data);
+
static gchar *_default_print_func (HildonTouchSelector * selector,
gpointer user_data);
@@ -311,6 +321,8 @@ static void hildon_touch_selector_column_cell_layout_reorder (GtkCellLayou
gint position);
static GList *hildon_touch_selector_column_cell_layout_get_cells (GtkCellLayout *cell_layout);
+static void
+hildon_touch_selector_check_ui_mode_coherence (HildonTouchSelector *selector);
static void
hildon_touch_selector_class_init (HildonTouchSelectorClass * class)
@@ -400,6 +412,31 @@ hildon_touch_selector_class_init (HildonTouchSelectorClass * class)
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ /**
+ * HildonTouchSelector:hildon-ui-mode:
+ *
+ * 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.
+ *
+ * Since: Hildon 2.2
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HILDON_UI_MODE,
+ g_param_spec_enum ("hildon-ui-mode",
+ "Hildon UI Mode",
+ "The Hildon UI mode according "
+ "to which the touch selector "
+ "should behave",
+ HILDON_TYPE_UI_MODE,
+ HILDON_UI_MODE_EDIT,
+ G_PARAM_READWRITE));
/* style properties */
/* We need to ensure fremantle mode for the treeview in order to work
properly. This is not about the appearance, this is about behaviour */
@@ -426,6 +463,9 @@ hildon_touch_selector_get_property (GObject * object,
case PROP_INITIAL_SCROLL:
g_value_set_boolean (value, priv->initial_scroll);
break;
+ case PROP_HILDON_UI_MODE:
+ g_value_set_enum (value, priv->hildon_ui_mode);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -442,6 +482,10 @@ hildon_touch_selector_set_property (GObject *object, guint prop_id,
case PROP_INITIAL_SCROLL:
priv->initial_scroll = g_value_get_boolean (value);
break;
+ case PROP_HILDON_UI_MODE:
+ hildon_touch_selector_set_hildon_ui_mode (HILDON_TOUCH_SELECTOR (object),
+ g_value_get_enum (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -467,6 +511,8 @@ hildon_touch_selector_init (HildonTouchSelector * selector)
selector->priv->changed_blocked = FALSE;
+ selector->priv->hildon_ui_mode = HILDON_UI_MODE_EDIT;
+
gtk_box_pack_end (GTK_BOX (selector), selector->priv->hbox,
TRUE, TRUE, 0);
gtk_widget_show (selector->priv->hbox);
@@ -487,16 +533,23 @@ hildon_touch_selector_dispose (GObject * object)
}
static void
-disconnect_model_handlers (HildonTouchSelectorColumn *col, HildonTouchSelector *selector)
+clean_column (HildonTouchSelectorColumn *col,
+ HildonTouchSelector *selector)
{
g_signal_handlers_disconnect_by_func (col->priv->model,
on_row_changed, selector);
+
+ if (col->priv->last_activated != NULL) {
+ gtk_tree_row_reference_free (col->priv->last_activated);
+ col->priv->last_activated = NULL;
+ }
}
/*
* IMPLEMENTATION NOTES:
- * Some people sent questions regarding a missing dispose/finalize function on
- * this widget that could lead to leak memory, so we will clarify this topic.
+ * Some people sent questions regarding the fact that the dispose/finalize functions
+ * doesn't clean the internal widgets that could lead to leak memory, so we will
+ * clarify this topic.
*
* This is not required as #HildonTouchSelector extends #GtkContainer. When the
* widget is freed, the #GtkContainer freeing memory functions are called. This
@@ -524,7 +577,7 @@ hildon_touch_selector_remove (GtkContainer * container, GtkWidget * widget)
/* Remove the extra data related to the columns, if required. */
if (widget == selector->priv->hbox) {
- g_slist_foreach (selector->priv->columns, (GFunc) disconnect_model_handlers, selector);
+ g_slist_foreach (selector->priv->columns, (GFunc) clean_column, selector);
g_slist_foreach (selector->priv->columns, (GFunc) g_object_unref, NULL);
g_slist_free (selector->priv->columns);
@@ -555,11 +608,25 @@ static void
hildon_touch_selector_emit_value_changed (HildonTouchSelector *selector,
gint column)
{
+ /* FIXME: it could be good to emit too the GtkTreePath of the element
+ selected, as now it is required to connect to the signal and then ask
+ for the element selected. We can't do this API change, in order to avoid
+ and ABI break */
if (!selector->priv->changed_blocked) {
g_signal_emit (selector, hildon_touch_selector_signals[CHANGED], 0, column);
}
}
+static void
+hildon_touch_selector_check_ui_mode_coherence (HildonTouchSelector *selector)
+{
+ g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
+
+ if (hildon_touch_selector_get_num_columns (selector) > 1) {
+ hildon_touch_selector_set_hildon_ui_mode (selector, HILDON_UI_MODE_EDIT);
+ }
+}
+
/**
* default_print_func:
* @selector: a #HildonTouchSelector
@@ -669,6 +736,27 @@ _default_print_func (HildonTouchSelector * selector, gpointer user_data)
}
static void
+hildon_touch_selector_row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ HildonTouchSelectorColumn *selector_column = NULL;
+ GtkTreeModel *model = NULL;
+
+ g_return_if_fail (HILDON_IS_TOUCH_SELECTOR_COLUMN (user_data));
+ selector_column = HILDON_TOUCH_SELECTOR_COLUMN (user_data);
+
+ model = selector_column->priv->model;
+
+ if (selector_column->priv->last_activated != NULL) {
+ gtk_tree_row_reference_free (selector_column->priv->last_activated);
+ }
+
+ selector_column->priv->last_activated = gtk_tree_row_reference_new (model, path);
+}
+
+static void
_row_tapped_cb (GtkTreeView * tree_view, GtkTreePath * path, gpointer user_data)
{
HildonTouchSelector *selector = NULL;
@@ -716,7 +804,7 @@ _create_new_column (HildonTouchSelector * selector,
}
#ifdef MAEMO_GTK
- tv = GTK_TREE_VIEW (hildon_gtk_tree_view_new (HILDON_UI_MODE_EDIT));
+ tv = GTK_TREE_VIEW (hildon_gtk_tree_view_new (selector->priv->hildon_ui_mode));
#else
tv = GTK_TREE_VIEW (gtk_tree_view_new ());
#endif /* MAEMO_GTK */
@@ -752,7 +840,8 @@ _create_new_column (HildonTouchSelector * selector,
/* select the first item */
*emit_changed = FALSE;
- if (gtk_tree_model_get_iter_first (model, &iter)) {
+ if ((gtk_tree_model_get_iter_first (model, &iter))&&
+ (selector->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT)) {
gtk_tree_selection_select_iter (selection, &iter);
*emit_changed = TRUE;
}
@@ -763,6 +852,9 @@ _create_new_column (HildonTouchSelector * selector,
g_signal_connect (G_OBJECT (tv), "hildon-row-tapped",
G_CALLBACK (_row_tapped_cb), new_column);
+ g_signal_connect (G_OBJECT (tv), "row-activated",
+ G_CALLBACK (hildon_touch_selector_row_activated_cb), new_column);
+
return new_column;
}
@@ -826,6 +918,7 @@ hildon_touch_selector_column_init (HildonTouchSelectorColumn *column)
column->priv = G_TYPE_INSTANCE_GET_PRIVATE (column, HILDON_TYPE_TOUCH_SELECTOR_COLUMN,
HildonTouchSelectorColumnPrivate);
column->priv->text_column = -1;
+ column->priv->last_activated = NULL;
}
/**
@@ -1202,6 +1295,11 @@ hildon_touch_selector_insert_text (HildonTouchSelector * selector,
* 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 #HildonTouchSelector: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,
+ * #HildonTouchSelector:hildon-ui-mode will change to %HILDON_UI_MODE_EDIT.
+ *
* Returns: the new column added added, %NULL otherwise.
*
* Since: 2.2
@@ -1248,6 +1346,8 @@ hildon_touch_selector_append_column (HildonTouchSelector * selector,
hildon_touch_selector_emit_value_changed (selector, colnum);
}
+ hildon_touch_selector_check_ui_mode_coherence (selector);
+
return new_column;
}
@@ -1440,6 +1540,10 @@ hildon_touch_selector_get_column_selection_mode (HildonTouchSelector * selector)
*
* 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
+ * #HildonTouchSelector:hildon-ui-mode property is set to %HILDON_UI_MODE_NORMAL
+ *
* Since: 2.2
**/
void
@@ -2256,3 +2360,115 @@ hildon_touch_selector_optimal_size_request (HildonTouchSelector *selector,
requisition->height = base_height + height;
}
+
+
+/**
+ * hildon_touch_selector_get_hildon_ui_mode
+ * @selector: a #HildonTouchSelector
+ *
+ * Gets the current hildon-ui-mode, see #HildonUIMode for more information
+ *
+ * Returns: the current hildon-ui-mode
+ *
+ * Since: 2.2
+ **/
+HildonUIMode
+hildon_touch_selector_get_hildon_ui_mode (HildonTouchSelector *selector)
+{
+ g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), HILDON_UI_MODE_EDIT);
+
+ return selector->priv->hildon_ui_mode;
+}
+
+/**
+ * hildon_touch_selector_set_hildon_ui_mode
+ * @selector: a #HildonTouchSelector
+ * @mode: a #HildonUIMode
+ *
+ * Sets the value of the property #HildonTouchSelector:hildon-ui-mode to be @mode,
+ * see #HildonUIMode for more information
+ *
+ * Note that the %HILDON_UI_MODE_NORMAL can be only used when the selector has
+ * one column, use the return value to check if the change was effective.
+ *
+ * Returns: %TRUE if #HildonTouchSelector:hildon-ui-mode was changed
+ * %FALSE otherwise
+ *
+ * Since: 2.2
+ **/
+gboolean
+hildon_touch_selector_set_hildon_ui_mode (HildonTouchSelector *selector,
+ HildonUIMode mode)
+{
+ gint num = 0;
+ GSList *iter = NULL;
+ HildonTouchSelectorColumn *column = NULL;
+ GtkTreeView *tree_view = NULL;
+
+ g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), FALSE);
+ num = hildon_touch_selector_get_num_columns (selector);
+ g_return_val_if_fail ((mode == HILDON_UI_MODE_EDIT) || (num == 1), FALSE);
+
+ if (mode == selector->priv->hildon_ui_mode) {
+ return FALSE;
+ }
+
+ for (iter = selector->priv->columns; iter; iter = g_slist_next (iter)) {
+ column = HILDON_TOUCH_SELECTOR_COLUMN (iter->data);
+ tree_view = column->priv->tree_view;
+
+ hildon_tree_view_set_hildon_ui_mode (tree_view, mode);
+
+ /* looking at the code of hildon_tree_view_set_hildon_ui_mode, it seems
+ that it call the unselect_all, but it is required anyway */
+ if (mode == HILDON_UI_MODE_NORMAL) {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
+
+ gtk_tree_selection_unselect_all (selection);
+ }
+ }
+
+ selector->priv->hildon_ui_mode = mode;
+
+ return TRUE;
+}
+
+/**
+ * hildon_touch_selector_get_last_activated_row
+ * @selector: a #HildonTouchSelector
+ * @column: column number
+ *
+ * Gets a #GtkTreePath of the last row activated in a column (the last row that
+ * emitted a #GtkTreeView::row-activated signal). This is mainly useful if the
+ * @selector #HildonTouchSelector:hildon-ui-mode in set to %HILDON_UI_MODE_NORMAL,
+ * as using this state there is no real selection, so a method like
+ * hildon_touch_selector_get_selected_rows() will return always a empty
+ * selection.
+ *
+ * Anyway, this method works as well on %HILDON_UI_MODE_EDIT, but in this case
+ * is better, and more useful, to get the current selection.
+ *
+ * Returns: a newly allocated #GtkTreePath pointing to the last activated row
+ * NULL if no row were activated.
+ *
+ * Since: 2.2
+ **/
+GtkTreePath*
+hildon_touch_selector_get_last_activated_row (HildonTouchSelector *selector,
+ gint column)
+{
+ HildonTouchSelectorColumn *selector_column = NULL;
+
+ /* this method with check selector and that the column number is correct*/
+ selector_column = hildon_touch_selector_get_column (selector, column);
+
+ if (selector_column == NULL) {
+ return NULL;
+ }
+
+ if (selector_column->priv->last_activated != NULL) {
+ return gtk_tree_row_reference_get_path (selector_column->priv->last_activated);
+ } else {
+ return NULL;
+ }
+}
diff --git a/hildon/hildon-touch-selector.h b/hildon/hildon-touch-selector.h
index 6f3022c..cdc83f9 100644
--- a/hildon/hildon-touch-selector.h
+++ b/hildon/hildon-touch-selector.h
@@ -219,6 +219,16 @@ void
hildon_touch_selector_optimal_size_request (HildonTouchSelector *selector,
GtkRequisition *requisition);
+HildonUIMode
+hildon_touch_selector_get_hildon_ui_mode (HildonTouchSelector *selector);
+
+gboolean
+hildon_touch_selector_set_hildon_ui_mode (HildonTouchSelector *selector,
+ HildonUIMode mode);
+GtkTreePath*
+hildon_touch_selector_get_last_activated_row (HildonTouchSelector *selector,
+ gint column);
+
G_END_DECLS
#endif /* __HILDON_TOUCH_SELECTOR_H__ */