[maemo-commits] [maemo-commits] r16493 - in projects/haf/trunk/gtk+: . gtk gtk/tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Oct 27 14:42:01 EET 2008
- Previous message: [maemo-commits] r16492 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
- Next message: [maemo-commits] r16494 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kris Date: 2008-10-27 14:41:22 +0200 (Mon, 27 Oct 2008) New Revision: 16493 Modified: projects/haf/trunk/gtk+/ChangeLog projects/haf/trunk/gtk+/gtk/gtktreeselection.c projects/haf/trunk/gtk+/gtk/tests/treeview-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 1 / 3 * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): when switching selection modes in edit mode, make sure the anchor is on a selected item, if not force it to be on the first selected item. * gtk/tests/treeview-hildon.c: add test. Modified: projects/haf/trunk/gtk+/ChangeLog =================================================================== --- projects/haf/trunk/gtk+/ChangeLog 2008-10-27 12:29:30 UTC (rev 16492) +++ projects/haf/trunk/gtk+/ChangeLog 2008-10-27 12:41:22 UTC (rev 16493) @@ -1,3 +1,15 @@ +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 + switching selection modes in edit mode, make sure the anchor is + on a selected item, if not force it to be on the first selected + item. + + * gtk/tests/treeview-hildon.c: add test. + 2008-10-16 Claudio Saavedra <csaavedra at igalia.com> Released 2:2.12.12-1maemo3 Modified: projects/haf/trunk/gtk+/gtk/gtktreeselection.c =================================================================== --- projects/haf/trunk/gtk+/gtk/gtktreeselection.c 2008-10-27 12:29:30 UTC (rev 16492) +++ projects/haf/trunk/gtk+/gtk/gtktreeselection.c 2008-10-27 12:41:22 UTC (rev 16493) @@ -220,6 +220,44 @@ } } +#ifdef MAEMO_CHANGES + if (!selected + && mode == HILDON_FREMANTLE + && selection->tree_view->priv->hildon_ui_mode == HILDON_UI_MODE_EDIT) + { + GList *rows; + + /* One item must stay selected; we look for the first selected + * item we can find, that one becomes the anchor. We silently + * assume here that there is at least *one* selected row, + * as mandated by any new-style edit mode. + */ + + if (anchor_path) + gtk_tree_path_free (anchor_path); + + /* FIXME: this can be obviously optimized by walking + * the selection tree ourselves; or probably having a _real + * variant of _get_selected_rows() that we can tell to stop + * as soon as a selected node is found. + */ + rows = gtk_tree_selection_get_selected_rows (selection, NULL); + anchor_path = gtk_tree_path_copy (rows->data); + g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); + g_list_free (rows); + + _gtk_tree_view_find_node (selection->tree_view, + anchor_path, + &tree, + &node); + + if (node && GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED)) + selected = TRUE; + + g_return_if_fail (selected == TRUE); + } +#endif /* MAEMO_CHANGES */ + /* We do this so that we unconditionally unset all rows */ tmp_func = selection->user_func; Modified: projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c =================================================================== --- projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c 2008-10-27 12:29:30 UTC (rev 16492) +++ projects/haf/trunk/gtk+/gtk/tests/treeview-hildon.c 2008-10-27 12:41:22 UTC (rev 16493) @@ -194,7 +194,30 @@ gtk_tree_path_free (path); } +static void +edit_multi_to_single (HildonTreeViewFixture *fixture, + gconstpointer test_data) +{ + GtkTreePath *path; + /* One item must be selected */ + g_assert (gtk_tree_selection_count_selected_rows (fixture->selection) == 1); + + /* 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_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); + + /* 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); +} + int main (int argc, char **argv) { @@ -226,5 +249,11 @@ edit_selection_multi, hildon_tree_view_fixture_teardown); + g_test_add ("/treeview/hildon/edit-multi-to-single-test", + HildonTreeViewFixture, NULL, + hildon_tree_view_fixture_edit_multi_setup, + edit_multi_to_single, + hildon_tree_view_fixture_teardown); + return g_test_run (); }
- Previous message: [maemo-commits] r16492 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
- Next message: [maemo-commits] r16494 - in projects/haf/trunk/gtk+: . gtk gtk/tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]