Hi
I'm trying to change the background color of a window randomly, but I always get a black filled window, even though I get random values from g_rand.
(I'm trying this as an exercise in learning GTK.)
What would be the best way to achieve this effect ?
static int configure_event_cb(GtkWidget * w, GdkEvent * e, gpointer p) {
GdkColor color; GdkEventConfigure * cfg = (GdkEventConfigure*)e;
width = cfg->width; height = cfg->height;
color.red = g_rand_int_range(rand,0,256); color.green = g_rand_int_range(rand,0,256); color.blue = g_rand_int_range(rand,0,256); g_print("1.red=%d green=%d blue=%d\n", color.red,color.green,color.blue);
gtk_widget_modify_bg(w,GTK_STATE_NORMAL,&color);
color = w->style->bg[GTK_STATE_NORMAL]; g_print("2.red=%d green=%d blue=%d\n", color.red,color.green,color.blue);
gtk_widget_queue_draw(w);
return TRUE;
}
static int expose_event_cb(GtkWidget * w, GdkEvent * e, gpointer p) { GdkGC * gc = w->style->bg_gc[GTK_STATE_NORMAL]; gdk_draw_rectangle(w->window,gc,TRUE,0,0,width,height); return TRUE; }
_______________________________________________ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list