/* @_WIN @_UNIX */

#include <stdlib.h>
#include "gtk/gtk.h"

int main( int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget* treeview;
  GtkTreeViewColumn* column_text;
  GtkTreeViewColumn* column_pixbuf;
  GtkListStore* liststore;
  GtkTreeIter iter;
  GtkCellRenderer* renderer_text;
  GtkCellRenderer* renderer_pixbuf;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "CellRendererPixbuf Example");
  gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);

  liststore=gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set(liststore, &iter, 0, "New", 1, "gtk-new", -1);
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set(liststore, &iter, 0, "Play", 1, "gtk-media-play", -1);
  gtk_list_store_append(liststore, &iter);
  gtk_list_store_set(liststore, &iter, 0, "Jump to", 1, "gtk-jump-to", -1);

  treeview=gtk_tree_view_new();
  gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));

  renderer_text=gtk_cell_renderer_text_new();

  column_text=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column_text, "Text");
  gtk_tree_view_column_pack_start(column_text, renderer_text, TRUE);
  gtk_tree_view_column_add_attribute(column_text, renderer_text, "text", 0);
  gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column_text);

  renderer_pixbuf=gtk_cell_renderer_pixbuf_new();

  column_pixbuf=gtk_tree_view_column_new();
  gtk_tree_view_column_set_title(column_pixbuf, "Image");
  gtk_tree_view_column_pack_start(column_pixbuf, renderer_pixbuf, TRUE);
  gtk_tree_view_column_add_attribute(column_pixbuf, renderer_pixbuf, "stock-id", 1);
  gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column_pixbuf);
  
  gtk_container_add(GTK_CONTAINER(window), treeview);

  gtk_widget_show_all(window);

  g_signal_connect_swapped(G_OBJECT(window), "destroy",
      G_CALLBACK(gtk_main_quit), NULL);

  gtk_main();

  return 0;
}
