#include <gtk/gtk.h>

static void
fill_treeview (GtkTreeView *treeview,
               gint         items)
{
    GtkListStore *store;
    GtkTreeIter iter;
    GtkTreeViewColumn *column;
    GtkCellRenderer *cell;
    gint i;

    column = gtk_tree_view_column_new ();
    cell = gtk_cell_renderer_text_new ();

    gtk_tree_view_column_pack_start (column, cell, FALSE);
    gtk_tree_view_column_add_attribute (column, cell, "text", 0);
    gtk_tree_view_append_column (treeview, column);

    store = GTK_LIST_STORE (gtk_tree_view_get_model (treeview));
    store = gtk_list_store_new (1, G_TYPE_STRING);
    gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (store));
    g_object_unref (store);

    for (i = 0; i < items; i++) {
        char item[16];

        sprintf (item, "Item %d", i + 1);
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter, 0, item, -1);
    }
}

int
main (int   argc,
      char *argv[])
{
    GtkWidget *window;
    GtkWidget *scrolled_window;
    GtkWidget *treeview;
    GtkTreeViewColumn *column;
    GtkCellRenderer *cell;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_title(GTK_WINDOW(window), "Scroll Treeview");

    gtk_window_set_default_size (GTK_WINDOW (window),
                                 450, 450);

    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);

    treeview = gtk_tree_view_new ();
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (treeview), TRUE);

    gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
    gtk_container_add (GTK_CONTAINER (window), scrolled_window);
    
    fill_treeview (GTK_TREE_VIEW (treeview), 100);

    gtk_widget_show_all (window);
    gtk_main ();

    return 0;
}
