Just use gtk_image_set_from_pixbuf() which allows you to set and/or update
the pixbuf displayed by a GtkImage .

Regards,
Dov

2008/12/31 George Brink <[email protected]>

> I need to draw several tool buttons with colored circles and rectangles on
> them.
> I thought of doing something like:
> ----------
> GtkToolItems *color_buttons[COUNT_OF_COLORS];
> GtkWidgets *color_icons[COUNT_OF_COLORS];
> GdkColors colors[COUNT_OF_COLORS] = {.....};
> ..... /// here is initialization of tool buttons
> for( i = 0; i<COUNT_OF_COLORS; i++) {
>       GdkPixbuf *icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 40,
> 40);
>       GdkDrawable *dicon = ????
>       //// how to get GdkDrawable from GdkPixbuf???
>       GdkGC *gc = gdk_gc_new(dicon);
>       gdk_gc_set_rgb_fg_color(gc, &(colors[i]));
>       gdk_draw_rectangle(dicon, gc, TRUE, 2, 2, 36, 36);
>       color_icons[i] = gtk_image_new_from_pixbuf(icon);
>       g_object_unref(G_OBJECT(dicon));
>       g_object_unref(G_OBJECT(icon));
>       g_object_unref(G_OBJECT(gc));
>       gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(color_buttons[i]),
> color_icons[i]);
> }
> ------------
> And I am stuck on converting GdkPixbuf to GdkDrawable...
>
> What is the easiest way to make a brand new GtkImage and draw something on
> it in runtime?
>
>
>
> _______________________________________________
> gtk-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to