#include <string.h>
#include <stdlib.h>
+
+#include "hildon-gtk.h"
+
#include "hildon-pannable-area.h"
#include "hildon-touch-selector.h"
* The changed signal is emitted when the active
* item 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_set_active_iter() on
+ * call to hildon_touch_selector_select_iter() on
* one of the columns.
*
*/
*
* Default print function
*
- * Returns: a new string that represent the selected items
+ * Returns: a new string that represents the selected items
**/
static gchar *
_default_print_func (HildonTouchSelector * selector)
for (i = initial_value; i < num_columns; i++) {
model = hildon_touch_selector_get_model (selector, i);
- if (hildon_touch_selector_get_active_iter (selector, i, &iter)) {
+ if (hildon_touch_selector_get_selected (selector, i, &iter)) {
gtk_tree_model_get (model, &iter, 0, ¤t_string, -1);
if (i != 0) {
{
SelectorColumn *new_column = NULL;
GtkTreeViewColumn *tree_column = NULL;
- GValue val = { 0, };
GtkTreeView *tv = NULL;
GtkWidget *panarea = NULL;
GtkTreeSelection *selection = NULL;
attribute = va_arg (args, gchar *);
}
- tv = g_object_new (GTK_TYPE_TREE_VIEW, "model", model, "name", "fremantle-widget", /* FIXME: is this always this name? */
- "hildon-ui-mode", HILDON_UI_MODE_EDIT,
- "rules-hint", TRUE, NULL);
+ tv = GTK_TREE_VIEW (hildon_gtk_tree_view_new (HILDON_UI_MODE_EDIT));
+ gtk_tree_view_set_model (tv, model);
+ gtk_tree_view_set_rules_hint (tv, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), tree_column);
panarea = hildon_pannable_area_new ();
- g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, HILDON_PANNABLE_AREA_INDICATOR_MODE_HIDE);
- g_object_set_property (G_OBJECT (panarea), "vindicator-mode", &val);
-
- g_value_unset (&val);
- g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val, FALSE);
- g_object_set_property (G_OBJECT (panarea), "initial-hint", &val);
+ g_object_set (G_OBJECT (panarea), "vscrollbar-policy", GTK_POLICY_NEVER,
+ "initial-hint", FALSE, NULL);
gtk_container_add (GTK_CONTAINER (panarea), GTK_WIDGET (tv));
hildon_touch_selector_remove_column (HildonTouchSelector * selector, gint column)
{
SelectorColumn *current_column = NULL;
+ HildonTouchSelectorPrivate *priv;
g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), FALSE);
g_return_val_if_fail (column <
hildon_touch_selector_get_num_columns (selector), FALSE);
- current_column = g_slist_nth_data (selector->priv->columns, column);
+ priv = HILDON_TOUCH_SELECTOR_GET_PRIVATE (selector);
+ current_column = g_slist_nth_data (priv->columns, column);
- gtk_container_remove (GTK_CONTAINER (selector), current_column->panarea);
+ gtk_container_remove (GTK_CONTAINER (priv->hbox), current_column->panarea);
+ priv->columns = g_slist_remove (priv->columns, current_column);
+ g_free (current_column);
return TRUE;
}
gtk_tree_view_append_column (current_column->tree_view, tree_column);
}
-#if 0
-gboolean
-hildon_touch_selector_insert_column (HildonTouchSelector * selector, gint position)
-{
- g_warning ("Un-implemented!");
-
- return TRUE;
-}
-#endif
-
/**
* hildon_touch_selector_get_num_columns:
* @selector: a #HildonTouchSelector
gint
hildon_touch_selector_get_num_columns (HildonTouchSelector * selector)
{
+ g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), -1);
+
return g_slist_length (selector->priv->columns);
}
GtkTreeView *tv = NULL;
SelectorColumn *column = NULL;
GtkTreeSelection *selection = NULL;
- GtkSelectionMode treeview_mode;
+ GtkSelectionMode treeview_mode = GTK_SELECTION_MULTIPLE;
GtkTreeIter iter;
g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
}
/**
- * hildon_touch_selector_get_active_iter:
+ * hildon_touch_selector_get_selected:
* @selector: a #HildonTouchSelector
* @column: the column number we want to get the element
* @iter: #GtkTreeIter currently selected
*
- * Sets @iter to the currently selected node on the nth-column, if selection is set to
- * %HILDON_TOUCH_SELECTOR_SINGLE. @iter may be %NULL if you just want to test if selection
- * has any selected items.
+ * 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.
+ * %HILDON_TOUCH_SELECTOR_MULTIPLE mode and the column is the first one.
*
* See gtk_tree_selection_get_selected() for more information.
*
* Returns: %TRUE if @iter was correctly set, %FALSE otherwise
**/
gboolean
-hildon_touch_selector_get_active_iter (HildonTouchSelector * selector,
- gint column, GtkTreeIter * iter)
+hildon_touch_selector_get_selected (HildonTouchSelector * selector,
+ gint column, GtkTreeIter * iter)
{
GtkTreeSelection *selection = NULL;
SelectorColumn *current_column = NULL;
+ HildonTouchSelectorSelectionMode mode;
g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), FALSE);
- g_return_val_if_fail (hildon_touch_selector_get_column_selection_mode (selector)
- == HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE, FALSE);
g_return_val_if_fail (column < hildon_touch_selector_get_num_columns (selector),
FALSE);
+ mode = hildon_touch_selector_get_column_selection_mode (selector);
+ g_return_val_if_fail
+ ((mode == HILDON_TOUCH_SELECTOR_SELECTION_MODE_SINGLE) ||
+ ((mode == HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)&&(column>0)),
+ FALSE);
current_column = g_slist_nth_data (selector->priv->columns, column);
}
/**
- * hildon_touch_selector_set_active_iter
+ * hildon_touch_selector_select_iter
* @selector: a #HildonTouchSelector
* @column: the column to selects
* @iter: the #GtkTreeIter to be selected
*
**/
void
-hildon_touch_selector_set_active_iter (HildonTouchSelector * selector,
- gint column, GtkTreeIter * iter,
- gboolean scroll_to)
+hildon_touch_selector_select_iter (HildonTouchSelector * selector,
+ gint column, GtkTreeIter * iter,
+ gboolean scroll_to)
{
GtkTreePath *path;
GtkTreeModel *model;
path = gtk_tree_model_get_path (model, iter);
gtk_tree_selection_select_iter (selection, iter);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (current_column->tree_view), path, NULL, FALSE);
if (scroll_to) {
gtk_tree_view_get_background_area (current_column->tree_view,
}
/**
+ * hildon_touch_selector_unselect_iter
+ * @selector: a #HildonTouchSelector
+ * @column: the column to unselects from
+ * @iter: the #GtkTreeIter to be unselected
+ *
+ * Unselect the item pointed by @iter in the column @column
+ *
+ **/
+
+void hildon_touch_selector_unselect_iter (HildonTouchSelector * selector,
+ gint column,
+ GtkTreeIter * iter)
+{
+ SelectorColumn *current_column = NULL;
+ GtkTreeSelection *selection = NULL;
+
+ g_return_if_fail (HILDON_IS_TOUCH_SELECTOR (selector));
+ g_return_if_fail (column < hildon_touch_selector_get_num_columns (selector));
+
+ current_column = g_slist_nth_data (selector->priv->columns, column);
+ selection = gtk_tree_view_get_selection (current_column->tree_view);
+ gtk_tree_selection_unselect_iter (selection, iter);
+}
+
+/**
* hildon_touch_selector_get_selected_rows:
* @selector: a #HildonTouchSelector
* @column: the position of the column to get the selected rows from
gint column, GtkTreeModel * model)
{
SelectorColumn *current_column = NULL;
- g_print ("this was actually called\n");
current_column =
(SelectorColumn *) g_slist_nth_data (selector->priv->columns, column);
&& (selection_mode == HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)) {
break;
}
- if (hildon_touch_selector_get_active_iter (selector, i, &iter)) {
+ if (hildon_touch_selector_get_selected (selector, i, &iter)) {
path = gtk_tree_model_get_path (column->model, &iter);
gtk_tree_view_get_background_area (GTK_TREE_VIEW
(column->tree_view), path, NULL,