#include <gtk/gtk.h>

static void
on_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
  g_debug ("%s: size-request: %dx%d", G_OBJECT_TYPE_NAME (widget),
	   requisition->width, requisition->height);
}

static void
on_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
  g_debug ("%s: size-allocate: %dx%d", G_OBJECT_TYPE_NAME (widget),
	   allocation->width, allocation->height);
}

int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *label;
  GtkListStore *store;
  GtkTreeIter iter;
  GtkWidget *treeview;
  GtkTreeViewColumn *col;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), 0);

  store = gtk_list_store_new (1, G_TYPE_STRING);
  gtk_list_store_insert_with_values (store, &iter, -1, 0, "Foo", -1);

  treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
  col = gtk_tree_view_column_new_with_attributes (NULL,
						  gtk_cell_renderer_text_new (),
						  "text", 0,
						  NULL);
  label = gtk_label_new ("Longish title");
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_tree_view_column_set_widget (col, label);
  gtk_widget_show (label);

  g_object_set (col,
		"alignment", 0.0,
		"sizing",    GTK_TREE_VIEW_COLUMN_FIXED,
		"min-width", 100,
		NULL);
  gtk_tree_view_column_set_fixed_width (col, 100);

  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);

  gtk_container_add (GTK_CONTAINER (window), treeview);

  /* setup debuggin */
  g_signal_connect_after (col->button, "size-request", G_CALLBACK (on_size_request), NULL);
  g_signal_connect (col->button, "size-allocate", G_CALLBACK (on_size_allocate), NULL);
  g_signal_connect_after (label, "size-request", G_CALLBACK (on_size_request), NULL);
  g_signal_connect (label, "size-allocate", G_CALLBACK (on_size_allocate), NULL);
  g_signal_connect_after (label->parent, "size-request", G_CALLBACK (on_size_request), NULL);
  g_signal_connect (label->parent, "size-allocate", G_CALLBACK (on_size_allocate), NULL);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

