#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <cairo.h>

static void on_realize(GtkWidget* area, gpointer data)
{
    gdk_window_ensure_native(area->window);
}

static void on_expose(GtkWidget* area, gpointer data)
{
    guint width, height;
    cairo_t *cr;

    gdk_window_get_size(area->window, &width, &height);

    cr = gdk_cairo_create(area->window);
    cairo_set_source_rgb(cr, 1, 0, 0);
    cairo_rectangle(cr, 0, 0, width, height);
    cairo_fill(cr);

    cairo_destroy(cr);
}



int main(int argc, char** argv)
{
    GtkWidget *label;
    GtkWidget *area;
    GtkWidget *window;
    GtkWidget *hbox;

    gtk_init (&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    hbox = gtk_hbox_new(0, 0);
    label = gtk_label_new("Hello");
    area = gtk_drawing_area_new();
    gtk_widget_set_size_request(label, 200, 200);
    gtk_widget_set_size_request(area, 200, 200);
    gtk_box_pack_start((GtkBox*)hbox, label, 0, 0, 0);
    gtk_box_pack_start((GtkBox*)hbox, area, 1, 1, 0);
    gtk_container_add((GtkContainer*)window, hbox);
    g_signal_connect(G_OBJECT(area), "expose-event",
                     G_CALLBACK(on_expose), NULL);
    g_signal_connect(G_OBJECT(area), "realize",
                     G_CALLBACK(on_realize), NULL);

    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}
