/*
 * gcc -o socket -O0 -g socket.c `pkg-config --cflags --libs gtk+-3.0`
 */
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <gdk/gdkx.h>

GtkWidget *socket;

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);
    guint32 xid = atol(argv[1]);

    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    socket = gtk_socket_new();

    #if 1
    GtkWidget* vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    GtkWidget* drawing_area = gtk_drawing_area_new ();
    gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);

    gtk_widget_set_size_request (socket, -1, 100);
    gtk_box_pack_start (GTK_BOX (vbox), socket, FALSE, FALSE, 0);
    gtk_container_add(GTK_CONTAINER(wnd), vbox);
    #else
    gtk_container_add(GTK_CONTAINER(wnd), socket);
    #endif

    g_print("adding xid %d\n", xid);
    gtk_socket_add_id (GTK_SOCKET (socket), xid);

    gtk_window_set_default_size(GTK_WINDOW(wnd), 400, 300);
    gtk_widget_show_all(wnd);

    gtk_main();
    return 0;
}
