#include <gtk/gtk.h>
#include <goocanvas.h>

GtkWidget *window;

static gboolean on_rect_button_press (GooCanvasItem  *item, GooCanvasItem  *target, GdkEventButton *event, gpointer data)
{
    GtkWidget* dialog;
    dialog = gtk_dialog_new_with_buttons ("Message", GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, "OK", GTK_RESPONSE_NONE, NULL);
    g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
    gtk_dialog_run( GTK_DIALOG (dialog) );
    return TRUE;
}


int main(int argc, char* argv[])
{
    GtkWidget *canvas;
    GooCanvasItem *root, *rect_item; 

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
    gtk_widget_show (window);

    canvas = goo_canvas_new ();
    gtk_widget_set_size_request (canvas, 600, 450);
    goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
    gtk_widget_show (canvas);
    gtk_container_add (GTK_CONTAINER (window), canvas);

    root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

    rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
            "fill-color", "red",
            NULL);

    g_signal_connect (rect_item, "button_press_event", G_CALLBACK (on_rect_button_press), NULL);
    gtk_main ();

    return 0;
}
