[maemo-commits] [maemo-commits] r17291 - in projects/haf/trunk/gtk+: . gtk gtk/tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Jan 27 15:39:35 EET 2009
- Previous message: [maemo-commits] r17290 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Next message: [maemo-commits] r17292 - in projects/haf/trunk/gtk+: . gtk/tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kris Date: 2009-01-27 15:39:21 +0200 (Tue, 27 Jan 2009) New Revision: 17291 Modified: projects/haf/trunk/gtk+/ChangeLog projects/haf/trunk/gtk+/gtk/gtkiconview.c projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c Log: 2009-01-27 Kristian Rietveld <kris at imendio.com> Fixes: NB#99342 - behaviour change for multiple selection mode Part 2 / 2 (GtkIconView) * gtk/gtkiconview.c (gtk_icon_view_button_release): remove enforcement of one-must-be-selected-rule for multiple selection edit mode, (gtk_icon_view_row_inserted), (hildon_icon_view_set_hildon_ui_mode): do not select a first item by default for multiple selection edit mode, (gtk_icon_view_row_deleted): do not select the first item if the last selected item was deleted. * gtk/tests/iconview-hildon.c: update unit test to reflect the changes. Modified: projects/haf/trunk/gtk+/ChangeLog =================================================================== --- projects/haf/trunk/gtk+/ChangeLog 2009-01-27 13:23:57 UTC (rev 17290) +++ projects/haf/trunk/gtk+/ChangeLog 2009-01-27 13:39:21 UTC (rev 17291) @@ -1,6 +1,23 @@ 2009-01-27 Kristian Rietveld <kris at imendio.com> Fixes: NB#99342 - behaviour change for multiple selection mode + Part 2 / 2 (GtkIconView) + + * gtk/gtkiconview.c (gtk_icon_view_button_release): remove + enforcement of one-must-be-selected-rule for multiple selection edit + mode, + (gtk_icon_view_row_inserted), (hildon_icon_view_set_hildon_ui_mode): + do not select a first item by default for multiple selection edit + mode, + (gtk_icon_view_row_deleted): do not select the first item if the + last selected item was deleted. + + * gtk/tests/iconview-hildon.c: update unit test to reflect the + changes. + +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): Modified: projects/haf/trunk/gtk+/gtk/gtkiconview.c =================================================================== --- projects/haf/trunk/gtk+/gtk/gtkiconview.c 2009-01-27 13:23:57 UTC (rev 17290) +++ projects/haf/trunk/gtk+/gtk/gtkiconview.c 2009-01-27 13:39:21 UTC (rev 17291) @@ -2387,35 +2387,10 @@ } else if (icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE) { - gboolean found = FALSE; + item->selected = !item->selected; + gtk_icon_view_queue_draw_item (icon_view, item); - if (item->selected) - { - GList *items; - - /* This item will now be unselected, only possible if there - * are 2 items selected at this point. We look for one - * *other* selected item. - */ - - for (items = icon_view->priv->items; items; items = items->next) - { - GtkIconViewItem *tmp = items->data; - - if (tmp->selected && tmp != item) - found = TRUE; - } - } - else - found = TRUE; - - if (found) - { - item->selected = !item->selected; - gtk_icon_view_queue_draw_item (icon_view, item); - - g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); - } + g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); } icon_view->priv->anchor_item = item; @@ -4075,7 +4050,8 @@ NULL); if (mode == HILDON_FREMANTLE - && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT) + && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT + && icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) { GtkTreePath *tmppath; @@ -4142,7 +4118,8 @@ NULL); if (mode == HILDON_FREMANTLE - && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT) + && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT + && icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) { GtkTreePath *path; @@ -8184,30 +8161,33 @@ gtk_icon_view_set_selection_mode (icon_view, GTK_SELECTION_SINGLE); } - /* Instead of using gtk_icon_view_get_selected_items() we walk - * over the list of items ourselves to save allocating/deallocating all - * paths. - */ - for (list = icon_view->priv->items; list; list = list->next) + if (icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) { - GtkIconViewItem *item = list->data; - - if (item->selected) + /* Instead of using gtk_icon_view_get_selected_items() we walk + * over the list of items ourselves to save allocating/deallocating + * all paths. + */ + for (list = icon_view->priv->items; list; list = list->next) { - count++; - break; + GtkIconViewItem *item = list->data; + + if (item->selected) + { + count++; + break; + } } - } - if (!count) - { - GtkTreePath *path; + if (!count) + { + GtkTreePath *path; - /* Select the first item */ - path = gtk_tree_path_new_first (); - search_first_selectable_path (icon_view, &path, TRUE); - gtk_icon_view_select_path (icon_view, path); - gtk_tree_path_free (path); + /* Select the first item */ + path = gtk_tree_path_new_first (); + search_first_selectable_path (icon_view, &path, TRUE); + gtk_icon_view_select_path (icon_view, path); + gtk_tree_path_free (path); + } } } else Modified: projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c =================================================================== --- projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c 2009-01-27 13:23:57 UTC (rev 17290) +++ projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c 2009-01-27 13:39:21 UTC (rev 17291) @@ -186,31 +186,33 @@ GtkTreePath *path; GtkTreeIter iter; - /* One item must be selected */ - g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); + /* Selection must be empty */ + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 0); - /* Selection should move */ + /* Selection should be extended */ path = gtk_tree_path_new_from_indices (10, -1); gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); - g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 2); + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), 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_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 0); + + /* Selection should be extended */ + path = gtk_tree_path_new_from_indices (10, -1); + gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); - - /* Path 0 was selected and should still be selected */ - path = gtk_tree_path_new_from_indices (0, -1); g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path)); + gtk_tree_path_free (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_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); - + /* Selection should be extended */ + path = gtk_tree_path_new_from_indices (20, -1); + gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 2); g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path)); gtk_tree_path_free (path); } @@ -221,19 +223,32 @@ { GtkTreePath *path; - /* One item must be selected */ - g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); + /* Selection must be empty */ + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 0); /* Select and unselect a row */ path = gtk_tree_path_new_from_indices (10, -1); gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); - g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 2); + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path)); gtk_icon_view_unselect_path (GTK_ICON_VIEW (fixture->icon_view), path); g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path) != TRUE); gtk_tree_path_free (path); + /* Select two rows */ + path = gtk_tree_path_new_from_indices (10, -1); + gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); + g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path)); + gtk_tree_path_free (path); + + path = gtk_tree_path_new_from_indices (20, -1); + gtk_icon_view_select_path (GTK_ICON_VIEW (fixture->icon_view), path); + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 2); + g_assert (gtk_icon_view_path_is_selected (GTK_ICON_VIEW (fixture->icon_view), path)); + gtk_tree_path_free (path); + /* Switch selection mode, one item should stay selected */ gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (fixture->icon_view), GTK_SELECTION_SINGLE); g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1);
- Previous message: [maemo-commits] r17290 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Next message: [maemo-commits] r17292 - in projects/haf/trunk/gtk+: . gtk/tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]