/*
 * compile with:
gcc -o gtk-spam `pkg-config --cflags --libs gtk+-3.0` gtk-spam.c
 */

#include <gtk/gtk.h>

static GtkWidget *
tree (void)
{
  GtkWidget *tree;
  GtkTreeStore *store;
  GtkTreeIter parent;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  gint i;

  store = gtk_tree_store_new (1, G_TYPE_STRING);
  gtk_tree_store_insert (store, &parent, NULL, 0);
  gtk_tree_store_set (store, &parent, 0, "click me", -1);

  for (i = 0; i < 5; i++)
    {
      GtkTreeIter iter;

      gtk_tree_store_insert (store, &iter, &parent, 0);
      gtk_tree_store_set (store, &iter, 0, "stuff", -1);
    }

  renderer = gtk_cell_renderer_text_new ();
  column =
    gtk_tree_view_column_new_with_attributes ("Text", renderer, "text", 0,
					      NULL);

  tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

  return tree;
}


int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *scroll;
  GtkWidget *dialog;
  GtkWidget *content_area;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (G_OBJECT (window), "destroy",
		    G_CALLBACK (gtk_main_quit), 0);
  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), 0);

  dialog = gtk_dialog_new ();
  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
  gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 200);

  g_signal_connect (G_OBJECT (dialog), "destroy",
		    G_CALLBACK (gtk_main_quit), 0);
  g_signal_connect (G_OBJECT (dialog), "delete_event",
		    G_CALLBACK (gtk_main_quit), 0);

  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scroll), tree ());

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_container_add (GTK_CONTAINER (content_area), scroll);

  gtk_widget_show (window);
  gtk_widget_show_all (dialog);

  gtk_main ();

  return 0;
}
