#include <gtk/gtk.h>

void check_active_text (GtkButton *button, gpointer data)
{
    gchar *text = 
	gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(data));

    fprintf(stderr, "gtk_combo_box_text_get_active_text: '%s'\n", text);
    g_free(text);
}

int main (int argc, char **argv)
{
    GtkWidget *w, *hbox;
    GtkWidget *combo, *button;
    GtkWidget *entry;

    gtk_init(&argc, &argv);

    w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(w), 5);
    gtk_window_set_has_resize_grip(GTK_WINDOW(w), FALSE);
    g_signal_connect(G_OBJECT(w), "destroy",
		     gtk_main_quit, NULL);

    hbox = gtk_hbox_new(FALSE, 5);

    combo = gtk_combo_box_text_new_with_entry();
    entry = gtk_bin_get_child(GTK_BIN(combo));
    gtk_entry_set_text(GTK_ENTRY(entry), "foo");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "bar");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "baz");

    button = gtk_button_new_with_label("Show active text on stderr");
    g_signal_connect(G_OBJECT(button), "clicked",
		     G_CALLBACK(check_active_text), combo);
    
    gtk_container_add(GTK_CONTAINER(hbox), combo);
    gtk_container_add(GTK_CONTAINER(hbox), button);
    gtk_container_add(GTK_CONTAINER(w), hbox);

    gtk_widget_show_all(w);
    gtk_main();

    return 0;
}
