Drop a grid combo example

This commit is contained in:
Matthias Clasen 2019-01-23 22:45:55 -05:00
parent 19dbc831c5
commit f87e40bccd

View File

@ -56,102 +56,6 @@ create_color_pixbuf (const char *color)
return pixbuf;
}
static GtkWidget *
create_combo_box_grid_demo (void)
{
GtkWidget *combo;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
GtkListStore *store;
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);
pixbuf = create_color_pixbuf ("green");
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
1, 1,
2, 1,
-1);
g_object_unref (pixbuf);
pixbuf = create_color_pixbuf ("blue");
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
1, 1,
2, 1,
-1);
g_object_unref (pixbuf);
/* second row */
pixbuf = create_color_pixbuf ("yellow");
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);
pixbuf = create_color_pixbuf ("black");
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);
/* third row */
pixbuf = create_color_pixbuf ("gray");
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, pixbuf,
1, 1,
2, 1,
-1);
g_object_unref (pixbuf);
pixbuf = create_color_pixbuf ("magenta");
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;
}
/* blaat */
static GtkTreeModel *
create_tree_blaat (void)
@ -1281,9 +1185,6 @@ main (int argc, char **argv)
boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (tmp), boom);
comboboxgrid = create_combo_box_grid_demo ();
gtk_container_add (GTK_CONTAINER (boom), comboboxgrid);
/* GtkComboBoxEntry */
tmp = gtk_frame_new ("GtkComboBox with entry");