#include <gtk/gtk.h>


static gboolean
on_delete_event (GtkWidget *widget,
		 GdkEvent  *event,
		 gpointer   data)
{
    gtk_main_quit ();

    return TRUE;
}

int
main (int   argc,
      char *argv[])
{
    GtkWidget *window;
    GtkWidget *combo;
    GtkListStore *store;
    GtkTreePath *path;
    GtkTreeIter iter;
    GtkCellRenderer *cell;
    gint i;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Combo");

    g_signal_connect (window, "delete-event", G_CALLBACK (on_delete_event), NULL);

    g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    store = gtk_list_store_new (1, G_TYPE_STRING);

    for (i = 0; i < 40; i++)
    {
	// Add a new row to the model
	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    0, "Hello",
			    -1);
    }

    combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));

    gtk_container_add (GTK_CONTAINER (window), combo);

    /* Remove our reference from store to avoid memory leak. */
    g_object_unref( G_OBJECT( store ) );

    /* Create cell renderer. */
    cell = gtk_cell_renderer_text_new();

    /* Pack it into the combo box. */
    gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), cell, TRUE );

    /* Connect renderer to data source. */
    gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), cell, "text", 0, NULL );

    gtk_widget_show_all( window );

    gtk_main ();
    return 0;
}
