[maemo-commits] [maemo-commits] r17290 - in projects/haf/trunk/gtk+: . gtk gtk/tests

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jan 27 15:24:03 EET 2009
Author: kris
Date: 2009-01-27 15:23:57 +0200 (Tue, 27 Jan 2009)
New Revision: 17290

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtktreeselection.c
   projects/haf/trunk/gtk+/gtk/gtktreeview.c
   projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c
Log:
2009-01-27  Kristian Rietveld  <kris at imendio.com>

	Fixes: NB#99342 - behaviour change for multiple selection mode
	Part 1 / 2 (GtkTreeView)

	* gtk/gtktreeselection.c (_gtk_tree_selection_internal_select_node):
	remove one-must-be-selected-rule for multiple selection edit mode.

	* gtk/gtktreeview.c (gtk_tree_view_row_inserted),
	(gtk_tree_view_set_model), (hildon_tree_view_set_hildon_ui_mode): do
	not select a first item by default for multiple selection edit mode,
	(gtk_tree_view_row_deleted): do not select the first item if the
	last selected item was deleted.

	* gtk/tests/treeview-hildon.c: update unit test to reflect the
	changes.



Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2009-01-27 12:30:54 UTC (rev 17289)
+++ projects/haf/trunk/gtk+/ChangeLog	2009-01-27 13:23:57 UTC (rev 17290)
@@ -1,5 +1,22 @@
 2009-01-27  Kristian Rietveld  <kris at imendio.com>
 
+	Fixes: NB#99342 - behaviour change for multiple selection mode
+	Part 1 / 2 (GtkTreeView)
+
+	* gtk/gtktreeselection.c (_gtk_tree_selection_internal_select_node):
+	remove one-must-be-selected-rule for multiple selection edit mode.
+
+	* gtk/gtktreeview.c (gtk_tree_view_row_inserted),
+	(gtk_tree_view_set_model), (hildon_tree_view_set_hildon_ui_mode): do
+	not select a first item by default for multiple selection edit mode,
+	(gtk_tree_view_row_deleted): do not select the first item if the
+	last selected item was deleted.
+
+	* gtk/tests/treeview-hildon.c: update unit test to reflect the
+	changes.
+
+2009-01-27  Kristian Rietveld  <kris at imendio.com>
+
 	Fixes: NB#98806 - An unexpected item appears in some Email views when
 	'Enter' HW key is pressed.
 

Modified: projects/haf/trunk/gtk+/gtk/gtktreeselection.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtktreeselection.c	2009-01-27 12:30:54 UTC (rev 17289)
+++ projects/haf/trunk/gtk+/gtk/gtktreeselection.c	2009-01-27 13:23:57 UTC (rev 17290)
@@ -1535,14 +1535,6 @@
 	}
       else if ((mode & GTK_TREE_SELECT_MODE_TOGGLE) == GTK_TREE_SELECT_MODE_TOGGLE)
 	{
-#ifdef MAEMO_CHANGES
-          HildonMode mode;
-
-          gtk_widget_style_get (GTK_WIDGET (selection->tree_view),
-                                "hildon-mode", &mode,
-                                NULL);
-#endif /* MAEMO_CHANGES */
-
 	  flags = node->flags;
 	  if (selection->tree_view->priv->anchor)
 	    gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
@@ -1550,15 +1542,7 @@
 	  selection->tree_view->priv->anchor =
 	    gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
 
-	  if ((flags & GTK_RBNODE_IS_SELECTED) == GTK_RBNODE_IS_SELECTED
-#ifdef MAEMO_CHANGES
-              /* FIXME: implement count-caching if this shows up in
-               * profiles.
-               */
-              && (mode == HILDON_DIABLO
-                  || gtk_tree_selection_count_selected_rows (selection) > 1)
-#endif /* MAEMO_CHANGES */
-             )
+	  if ((flags & GTK_RBNODE_IS_SELECTED) == GTK_RBNODE_IS_SELECTED)
 	    dirty |= gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
 	  else
 	    dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);

Modified: projects/haf/trunk/gtk+/gtk/gtktreeview.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtktreeview.c	2009-01-27 12:30:54 UTC (rev 17289)
+++ projects/haf/trunk/gtk+/gtk/gtktreeview.c	2009-01-27 13:23:57 UTC (rev 17290)
@@ -9523,6 +9523,7 @@
    */
   if (mode == HILDON_FREMANTLE
       && tree_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT
+      && tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE
       && gtk_tree_selection_count_selected_rows (tree_view->priv->selection) < 1)
     {
       GtkTreePath *tmppath;
@@ -9744,6 +9745,7 @@
   if (selection_changed
       && mode == HILDON_FREMANTLE
       && tree_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT
+      && tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE
       && gtk_tree_selection_count_selected_rows (tree_view->priv->selection) < 1)
     {
       GtkTreePath *tmppath;
@@ -12221,7 +12223,8 @@
 	}
 #ifdef MAEMO_CHANGES
       if (mode == HILDON_FREMANTLE
-          && tree_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT)
+          && tree_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT
+          && tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE)
         {
           /* Select the first item */
           search_first_focusable_path (tree_view, &path,
@@ -17415,7 +17418,8 @@
                                        GTK_SELECTION_SINGLE);
         }
 
-      if (gtk_tree_selection_count_selected_rows (tree_view->priv->selection) < 1)
+      if (tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE
+          && gtk_tree_selection_count_selected_rows (tree_view->priv->selection) < 1)
         {
           GtkTreePath *path;
 

Modified: projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c	2009-01-27 12:30:54 UTC (rev 17289)
+++ projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c	2009-01-27 13:23:57 UTC (rev 17290)
@@ -165,33 +165,33 @@
   GtkTreePath *path;
   GtkTreeIter iter;
 
-  /* One item must be selected */
-  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
+  /* Selection must be empty */
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 0);
 
-  /* Selection should move */
+  /* Selection should be extended */
   path = gtk_tree_path_new_from_indices (10, -1);
   gtk_tree_selection_select_path (fixture->selection, path);
-  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 2);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
   g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
 
-  /* When selected item is deleted, first item should get selection */
+  /* When selected item is deleted, the selection will be empty */
   gtk_tree_model_get_iter (fixture->model, &iter, path);
   gtk_tree_path_free (path);
 
   gtk_list_store_remove (GTK_LIST_STORE (fixture->model), &iter);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 0);
+
+  /* Selection should be extended */
+  path = gtk_tree_path_new_from_indices (10, -1);
+  gtk_tree_selection_select_path (fixture->selection, path);
   g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
-
-  /* Path 0 was selected and should still be selected */
-  path = gtk_tree_path_new_from_indices (0, -1);
   g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
 
-  /* Deleting path 0 should make the "new" path 0 selected */
-  gtk_tree_model_get_iter (fixture->model, &iter, path);
-  gtk_list_store_remove (GTK_LIST_STORE (fixture->model), &iter);
-  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
-
+  /* Selection should be extended */
+  path = gtk_tree_path_new_from_indices (20, -1);
+  gtk_tree_selection_select_path (fixture->selection, path);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 2);
   g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
-  gtk_tree_path_free (path);
 }
 
 static void
@@ -200,19 +200,30 @@
 {
   GtkTreePath *path;
 
-  /* One item must be selected */
-  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
+  /* Selection must be empty */
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 0);
 
   /* Select and unselect a row */
   path = gtk_tree_path_new_from_indices (10, -1);
   gtk_tree_selection_select_path (fixture->selection, path);
-  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 2);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
   g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
 
   gtk_tree_selection_unselect_path (fixture->selection, path);
   g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path) != TRUE);
   gtk_tree_path_free (path);
 
+  /* Select two rows */
+  path = gtk_tree_path_new_from_indices (10, -1);
+  gtk_tree_selection_select_path (fixture->selection, path);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);
+  g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
+
+  path = gtk_tree_path_new_from_indices (20, -1);
+  gtk_tree_selection_select_path (fixture->selection, path);
+  g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 2);
+  g_assert (gtk_tree_selection_path_is_selected (fixture->selection, path));
+
   /* Switch selection mode, one item should stay selected */
   gtk_tree_selection_set_mode (fixture->selection, GTK_SELECTION_SINGLE);
   g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1);


More information about the maemo-commits mailing list