/*
 * Build command:
 * $ cc `pkg-config --libs --cflags gtk+-2.0` -o testbed testbed.c
 */

#include <gtk/gtk.h>

static void
cb_activate (void)
{
    g_print("activate\n");
}

static gboolean
cb_key_release (GtkWidget *widget, GdkEventKey *key_event, gpointer data)
{
    g_print("keyval: %s\n", gdk_keyval_name(key_event->keyval));
    return FALSE;
}

static GtkWidget *
create_window (void)
{
    GtkWidget *window, *entry;

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window),
                                300, -1);

    entry = gtk_entry_new();
    gtk_container_add(GTK_CONTAINER(window), entry);
    g_signal_connect(entry, "activate",
                     G_CALLBACK(cb_activate), NULL);
    g_signal_connect(entry, "key-release-event",
                     G_CALLBACK(cb_key_release), NULL);
    gtk_widget_show(entry);

    return window;
}


static void
destroy_window_cb (GtkWidget *widget, gpointer data)
{
    gtk_main_quit();
}


int
main (int argc, char *argv[])
{
    GtkWidget *window;

    gtk_init(&argc, &argv);

    window = create_window();
    gtk_widget_show(window);
    g_signal_connect(G_OBJECT(window), "destroy",
                     G_CALLBACK(destroy_window_cb), window);

    gtk_main();

    return 0;
}
