1
votes

I work with GTK+ 2.24 in Windows 7 64-bit and Fedora 21 64-bit. I painted a drawing area to white, using Cairo. It works in Fedora, but not in Windows. Does anyone know the reason?

Here is my code:

static gboolean draw_background_cb(GtkWidget *widget _U_, cairo_t *cr, gpointer data _U_)
{
    /* Set background color */
    cairo_set_source_rgb(cr, 1, 1, 1);
    cairo_rectangle(cr, 0, 0, 300, 300);
    cairo_paint(cr);
    return FALSE;
}

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

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    g_signal_connect(window, "draw", G_CALLBACK (draw_background), NULL);

    gtk_widget_show(window);

    gtk_main();

    return 0;
}
1
Could you upload a minimal testable sample program somewhere?meskobalazs
What about this uses GtkDrawingArea? You're trying to draw directly on a GtkWindow instead (which will still work, but it doesn't match your question title). Also you're using GTK+ 3 if you're using the "draw" signal, not GTK+ 2. If you're getting this from a tutorial, you'll need to find a GTK+ 2 tutorial to use instead, or upgrade to GTK+ 3.andlabs
@andlabs Thanks your comment. I found that GTK+2 use not "draw" but "expose-event" and It works. Thanks a lot,,finchpark
@andlabs, do you mind posting as an answer? Since it solved the OP's problem, I think it would be best to have as an answer.oldtechaa

1 Answers

0
votes

GTK+ 2 uses expose-event instead of draw for drawing. I don't know what the other differences are; sorry.