#include <gtk/gtk.h>

void
populate_model (GtkListStore * model)
{
	GtkTreeIter iter;

	gtk_list_store_append (model, &iter);
	gtk_list_store_set (model, &iter,
			    0, 1,
			    1, 1,
			    2, "One",
			    -1);

	gtk_list_store_append (model, &iter);
	gtk_list_store_set (model, &iter,
			    0, 2,
			    1, 2,
			    2, "Two",
			    -1);

	gtk_list_store_append (model, &iter);
	gtk_list_store_set (model, &iter,
			    0, 3,
			    1, 3,
			    2, "Three",
			    -1);
}

GtkWidget *
create_combo (GtkTreeModel * model)
{
	GtkWidget * combo;
	GtkCellRenderer * renderer;
    
	combo = gtk_combo_box_entry_new_with_model (model, 1);
    
	/* Create a renderer for the 3rd column ( the string column ) */
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
					"text", 2, NULL);
    
	return combo;
}

int
main (int argc,
      char *argv[])
{
	GtkListStore * model;
	GtkWidget * window;
	GtkWidget * combo;

	gtk_init (&argc, &argv);

	model = gtk_list_store_new (3, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);

	populate_model (model);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

	combo = create_combo (GTK_TREE_MODEL (model));
	gtk_container_add (GTK_CONTAINER (window), combo);

	gtk_widget_show_all (window);
	gtk_main ();

	return 0;
}
