On Mon, 2005-07-11 at 09:58 +0200, [EMAIL PROTECTED] wrote: > I'd like to create a lot of images from some values. > Values is in some type of tree (background, what in right upper > corner, what in ...). > Is it possible to reuse GdkGC for enother GdkDrawable then in > constructor? > > Something like: > > G_INLINE GdkGC *return_gc_background1(GdkDrawable *gd) { > static GdkGC *gc = NULL; > static GdkColor color; > if(G_UNLIKLY(!gc)) { //It's used many times but once init. > gc = gdk_gc_new(gd); > gdk_color_parse("ff0000", &color); //1 > gdk_gc_set_foreground(gc, &color); > } > return gc; //What will be happend if enother GdkDrawable > }
A GdkGC can be used with any drawable with the same depth and GdkScreen as the one for which is was created. However, drawing onto a drawable that interprets colors differently is likely not useful, so you really need the two drawables to have the same GdkColormap. Regards, Owen P.S.: G_INLINE isn't used like that. There is no significant value to G_UNLIKELY in this type of code; it reduces the readability of your code for a very tiny performance improvement.
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list