diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-04-29 15:24:30 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-04-29 15:24:30 +0000 |
commit | 748f0aed6337cec54cdb48169baf8a024fa8202a (patch) | |
tree | e08641f993054c8fb038fb2559a252642682fd3e /tests/testiconview.c | |
parent | 5ce761a2e61a484e76e74a0b058cbc6b7740c6ee (diff) | |
download | gtk+-748f0aed6337cec54cdb48169baf8a024fa8202a.tar.gz |
Add some more tests.
2005-04-29 Matthias Clasen <mclasen@redhat.com>
* tests/testiconview.c: Add some more tests.
* gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash
if the path does not point to a row in the model. (#300909,
Mathias Hasselmann)
(gtk_icon_view_rows_reordered): Re-layout here. (#301009,
Mathias Hasselmann)
Diffstat (limited to 'tests/testiconview.c')
-rw-r--r-- | tests/testiconview.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/testiconview.c b/tests/testiconview.c index 988864bda9..9d53083e19 100644 --- a/tests/testiconview.c +++ b/tests/testiconview.c @@ -63,7 +63,7 @@ fill_model (GtkTreeModel *model) g_free (str2); i++; } - + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 2, GTK_SORT_ASCENDING); } @@ -104,6 +104,21 @@ foreach_selected_remove (GtkWidget *button, GtkIconView *icon_list) static void +swap_rows (GtkWidget *button, GtkIconView *icon_list) +{ + GtkTreeIter iter, iter2; + GtkTreeModel *model; + + model = gtk_icon_view_get_model (icon_list); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), -2, GTK_SORT_ASCENDING); + + gtk_tree_model_get_iter_first (model, &iter); + iter2 = iter; + gtk_tree_model_iter_next (model, &iter2); + gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter2); +} + +static void add_n_items (GtkIconView *icon_list, gint n) { static gint count = NUMBER_OF_ITEMS; @@ -218,6 +233,15 @@ select_all (GtkWidget *button, GtkIconView *icon_list) } static void +select_nonexisting (GtkWidget *button, GtkIconView *icon_list) +{ + GtkTreePath *path = gtk_tree_path_new_from_indices (999999, -1); + gtk_icon_view_select_path (icon_list, path); + gtk_tree_path_free (path); + gtk_icon_view_select_all (icon_list); +} + +static void unselect_all (GtkWidget *button, GtkIconView *icon_list) { gtk_icon_view_unselect_all (icon_list); @@ -404,6 +428,10 @@ main (gint argc, gchar **argv) g_signal_connect (button, "clicked", G_CALLBACK (foreach_selected_remove), icon_list); gtk_box_pack_start_defaults (GTK_BOX (bbox), button); + button = gtk_button_new_with_label ("Swap"); + g_signal_connect (button, "clicked", G_CALLBACK (swap_rows), icon_list); + gtk_box_pack_start_defaults (GTK_BOX (bbox), button); + bbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); @@ -416,6 +444,10 @@ main (gint argc, gchar **argv) g_signal_connect (button, "clicked", G_CALLBACK (unselect_all), icon_list); gtk_box_pack_start_defaults (GTK_BOX (bbox), button); + button = gtk_button_new_with_label ("Select nonexisting"); + g_signal_connect (button, "clicked", G_CALLBACK (select_nonexisting), icon_list); + gtk_box_pack_start_defaults (GTK_BOX (bbox), button); + gtk_paned_pack1 (GTK_PANED (paned), vbox, TRUE, FALSE); icon_list = gtk_icon_view_new (); |