#include <gtk/gtk.h>


const int num_cols = 3;
const int index_col_a = 0;
const int index_col_b = 1;
const int index_col_c = 2;

static gboolean window_on_delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer   data )
{
    gtk_main_quit ();
    return FALSE;
}

int main(int argc, char**argv)
{
  GtkWindow* window = 0;
  GtkTreeView* treeview = 0;
  GtkListStore* liststore = 0;
  GtkTreeIter iter;

  gtk_init(&argc, &argv);

  window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
  treeview = GTK_TREE_VIEW (gtk_tree_view_new ());
  gtk_widget_show (GTK_WIDGET (treeview) );
  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (treeview));


  liststore = gtk_list_store_new(num_cols, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT);

  /* Append rows and fill them with some data */
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      index_col_a, FALSE,
                      index_col_b, "One",
                      index_col_c, 123,
                      -1);
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      index_col_a, TRUE,
                      index_col_b, "Two",
                      index_col_c, 234,
                      -1);
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      index_col_a, FALSE,
                      index_col_b, "Three",
                      index_col_c, 456,
                      -1);

  gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (liststore));
  
  /* Append the view rows to render the model rows: */

  gtk_tree_view_append_column_default_renderer_editable (treeview, "Column A",
    GTK_TREE_MODEL (liststore), index_col_a);
  gtk_tree_view_append_column_default_renderer_editable (treeview, "Column B",
    GTK_TREE_MODEL (liststore), index_col_b);
  gtk_tree_view_append_column_default_renderer_editable (treeview, "Column B",
    GTK_TREE_MODEL (liststore), index_col_c);

  gtk_widget_show (GTK_WIDGET (window) );

  g_signal_connect (G_OBJECT (window), "delete_event",
                      G_CALLBACK (window_on_delete_event), NULL);

  gtk_main();

  return 0;
}

