summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Boles <dboles@src.gnome.org>2017-10-04 10:45:49 +0100
committerDaniel Boles <dboles@src.gnome.org>2017-10-04 11:04:52 +0100
commit3783934436dfe8b75c540a00a6bf688d416b40e7 (patch)
treea202e23a046dd48ae4ea9b1e2db9c0f14aec9068
parent4163a536309591915575bf625015dad3c09f946e (diff)
downloadgtk+-3783934436dfe8b75c540a00a6bf688d416b40e7.tar.gz
testcombo: Test grid :row- and :column-span-column
Ditch two items that were white and so weren’t visible on our standard theme anyway, and use the new space to test extra grid-mode properties. Note that if we do this then, as before, we set the ListStore on the ComboBox before appending to it, that produced runtime warnings like: Gtk-CRITICAL **: gtk_menu_attach: assertion 'left_attach < right_attach' failed I didn’t look into that yet, but it may indicate that attaching items vs. recognising their spans don’t occur in the correct order. For the purposes of testing this, I just create the CB after filling its model.
-rw-r--r--tests/testcombo.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/tests/testcombo.c b/tests/testcombo.c
index 34864d1ed7..44469bfdf1 100644
--- a/tests/testcombo.c
+++ b/tests/testcombo.c
@@ -65,21 +65,15 @@ create_combo_box_grid_demo (void)
GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
GtkListStore *store;
- store = gtk_list_store_new (1, GDK_TYPE_PIXBUF);
-
- combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
- cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
- cell, "pixbuf", 0, NULL);
- gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (combo),
- 3);
+ store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
/* first row */
pixbuf = create_color_pixbuf ("red");
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
+ 1, 1, /* row span */
+ 2, 1, /* column span */
-1);
g_object_unref (pixbuf);
@@ -87,6 +81,8 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
+ 1, 1,
+ 2, 1,
-1);
g_object_unref (pixbuf);
@@ -94,6 +90,8 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
+ 1, 1,
+ 2, 1,
-1);
g_object_unref (pixbuf);
@@ -102,6 +100,8 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
+ 1, 1,
+ 2, 2, /* Span 2 columns */
-1);
g_object_unref (pixbuf);
@@ -109,13 +109,8 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
- -1);
- g_object_unref (pixbuf);
-
- pixbuf = create_color_pixbuf ("white");
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- 0, pixbuf,
+ 1, 2, /* Span 2 rows */
+ 2, 1,
-1);
g_object_unref (pixbuf);
@@ -124,13 +119,8 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
- -1);
- g_object_unref (pixbuf);
-
- pixbuf = create_color_pixbuf ("snow");
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- 0, pixbuf,
+ 1, 1,
+ 2, 1,
-1);
g_object_unref (pixbuf);
@@ -138,11 +128,25 @@ create_combo_box_grid_demo (void)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
+ 1, 1,
+ 2, 1,
-1);
g_object_unref (pixbuf);
+ /* Create ComboBox after model to avoid gtk_menu_attach() warnings(?) */
+ combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
g_object_unref (store);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
+ cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+ cell, "pixbuf", 0, NULL);
+
+ /* Set wrap-width != 0 to enforce grid mode */
+ gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (combo), 3);
+ gtk_combo_box_set_row_span_column (GTK_COMBO_BOX (combo), 1);
+ gtk_combo_box_set_column_span_column (GTK_COMBO_BOX (combo), 2);
+
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
return combo;