#include <gtk/gtk.h>

static GtkWidget *
init_window(void)
{
    GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(win), "tabdemo.c");
    g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    
    GtkWidget *notebook = gtk_notebook_new();
    gtk_container_add(GTK_CONTAINER(win), notebook);
    
    int min_w, nat_w;
    GtkWidget *small_label = gtk_label_new("Some Text");
    gtk_label_set_ellipsize(GTK_LABEL(small_label), PANGO_ELLIPSIZE_MIDDLE);
    gtk_widget_get_preferred_width(small_label, &min_w, &nat_w);
    
    char *caption = g_strdup_printf("Minimum width: %d\nNatural width: %d",
            min_w, nat_w);
    GtkWidget *big_label = gtk_label_new(caption);
    gtk_widget_set_size_request(big_label, 320, 320);
    
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), big_label, small_label);
    
    gtk_widget_show_all(win);
    
    return win;
}

int
main(int argc, char **argv)
{
    gtk_init(&argc, &argv);
    init_window();
    gtk_main();
    return 0;
}
