[maemo-commits] [maemo-commits] r16494 - in projects/haf/trunk/gtk+: . gtk gtk/tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Oct 27 14:48:50 EET 2008
- Previous message: [maemo-commits] r16493 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Next message: [maemo-commits] r16495 - in projects/haf/trunk/gtk+: . gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kris Date: 2008-10-27 14:48:47 +0200 (Mon, 27 Oct 2008) New Revision: 16494 Modified: projects/haf/trunk/gtk+/ChangeLog projects/haf/trunk/gtk+/gtk/gtkiconview.c projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c Log: 2008-10-27 Kristian Rietveld <kris at imendio.com> Fixes NB#89408: Unable to select an item in the list picker Part 2 / 3 * gtk/gtkiconview.c (gtk_icon_view_set_selection_mode): s/selection_mode/hildon_ui_mode/ in "if normal mode" check; when switching selection modes, if the anchor is not on a selected item, force it to be on the first selected item. * gtk/tests/iconview-hildon.c: add test. Modified: projects/haf/trunk/gtk+/ChangeLog =================================================================== --- projects/haf/trunk/gtk+/ChangeLog 2008-10-27 12:41:22 UTC (rev 16493) +++ projects/haf/trunk/gtk+/ChangeLog 2008-10-27 12:48:47 UTC (rev 16494) @@ -1,6 +1,18 @@ 2008-10-27 Kristian Rietveld <kris at imendio.com> Fixes NB#89408: Unable to select an item in the list picker + Part 2 / 3 + + * gtk/gtkiconview.c (gtk_icon_view_set_selection_mode): + s/selection_mode/hildon_ui_mode/ in "if normal mode" check; + when switching selection modes, if the anchor is not on a + selected item, force it to be on the first selected item. + + * gtk/tests/iconview-hildon.c: add test. + +2008-10-27 Kristian Rietveld <kris at imendio.com> + + Fixes NB#89408: Unable to select an item in the list picker Part 1 / 3 * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): when Modified: projects/haf/trunk/gtk+/gtk/gtkiconview.c =================================================================== --- projects/haf/trunk/gtk+/gtk/gtkiconview.c 2008-10-27 12:41:22 UTC (rev 16493) +++ projects/haf/trunk/gtk+/gtk/gtkiconview.c 2008-10-27 12:48:47 UTC (rev 16494) @@ -5787,18 +5787,51 @@ NULL); if (hildon_mode == HILDON_FREMANTLE - && icon_view->priv->selection_mode == HILDON_UI_MODE_NORMAL + && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_NORMAL && mode != GTK_SELECTION_NONE) { g_warning ("Cannot change the selection mode to anything other than GTK_SELECTION_NONE in normal-mode.\n"); return; } + + if (hildon_mode == HILDON_FREMANTLE + && icon_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT + && icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE) + { + if (!icon_view->priv->anchor_item + || !icon_view->priv->anchor_item->selected) + { + GList *list; + + /* Look for the first selected item, make that the new + * anchor. + */ + + for (list = icon_view->priv->items; list; list = list->next) + { + GtkIconViewItem *item = list->data; + + if (item->selected) + { + icon_view->priv->anchor_item = item; + break; + } + } + } + + gtk_icon_view_unselect_all_internal (icon_view); + gtk_icon_view_select_item (icon_view, icon_view->priv->anchor_item); + } + else + { #endif /* MAEMO_CHANGES */ - if (mode == GTK_SELECTION_NONE || icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE) gtk_icon_view_unselect_all (icon_view); - +#ifdef MAEMO_CHANGES + } +#endif /* MAEMO_CHANGES */ + icon_view->priv->selection_mode = mode; g_object_notify (G_OBJECT (icon_view), "selection-mode"); Modified: projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c =================================================================== --- projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c 2008-10-27 12:41:22 UTC (rev 16493) +++ projects/haf/trunk/gtk+/gtk/tests/iconview-hildon.c 2008-10-27 12:48:47 UTC (rev 16494) @@ -215,7 +215,30 @@ gtk_tree_path_free (path); } +static void +edit_multi_to_single (HildonIconViewFixture *fixture, + gconstpointer test_data) +{ + GtkTreePath *path; + /* One item must be selected */ + g_assert (gtk_icon_view_count_selected_rows (GTK_ICON_VIEW (fixture->icon_view)) == 1); + + /* 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_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); + + /* 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); +} + int main (int argc, char **argv) { @@ -247,5 +270,11 @@ edit_selection_multi, hildon_icon_view_fixture_teardown); + g_test_add ("/iconview/hildon/edit-multi-to-single-test", + HildonIconViewFixture, NULL, + hildon_icon_view_fixture_edit_multi_setup, + edit_multi_to_single, + hildon_icon_view_fixture_teardown); + return g_test_run (); }
- Previous message: [maemo-commits] r16493 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Next message: [maemo-commits] r16495 - in projects/haf/trunk/gtk+: . gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]