GNOME Bugzilla – Bug 165706
Strange gdk_gc_set_rgb_fg_color() warning when calling gdk_draw_layout()
Last modified: 2010-08-25 04:51:46 UTC
I don't think I'm doing anything wrong with the following pygtk code: # (...) darea is a gtk.Window darea.set_size_request(width, height) darea.realize() pixmap = gtk.gdk.Pixmap(darea.window, width, height) #pixmap.set_colormap(darea.window.get_colormap()) fg_gc = gdk.GC(pixmap); fg_gc.copy(darea.style.fg_gc[gtk.STATE_NORMAL]) bg_gc = gdk.GC(pixmap); bg_gc.copy(darea.style.fg_gc[gtk.STATE_NORMAL]) fg_gc.set_foreground(darea.get_colormap().alloc_color(fgcolor)) bg_gc.set_background(darea.get_colormap().alloc_color(bgcolor)) pixmap.draw_rectangle(bg_gc, True, 0, 0, width, height) pixmap.draw_layout(fg_gc, off_x, off_y, layout) However, I get a Gdk warning: (gosd.py:12689): Gdk-WARNING **: gdk_gc_set_rgb_fg_color() and gdk_gc_set_rgb_bg_color() can only be used on GC's with a colormap. A GC will have a colormap if it is created for a drawable with a colormap, or if a colormap has been set explicitly with gdk_gc_set_colormap. Besides this warning, the program works fine. This warning didn't occur in gtk+ 2.4.x. Stack trace:
+ Trace 55092
Which of pixmap.get_colormap() fg_gc.get_colormap() bg_gc.get_colormap() are None?
OK, the full story. I use draw_layout twice. First on a pixmap. For the pixmap, pixmap.get_colormap() fg_gc.get_colormap() bg_gc.get_colormap() are all non-None. Then I draw the same string to a bitmap, prepared with this code: bitmap = gtk.gdk.Pixmap(darea.window, width, height, 1) fg_gc = gdk.GC(bitmap) bg_gc = gdk.GC(bitmap) fg_gc.set_foreground(gdk.Color(pixel=-1)) bg_gc.set_background(gdk.Color(pixel=0)) In this case, bitmap.get_colormap(), fg_gc.get_colormap() and bg_gc.get_colormap() are all None. I honestly don't know what I'm doing wrong here, and the application works fine, so it must be gtk+ being excessively rigorous.
bitmaps don't have colormaps, we have a vague plan to change that *** This bug has been marked as a duplicate of 75497 ***
I'm not sure that this actually is a duplicate ... this may be a regress from 2.4 to 2.6 ... we used to have some horrible hack code to draw text onto bitmaps, and that may have been lost with the move to PangoRenderer.
Is bug 166873 a duplicate of this bug?
No. No bitmaps involved in that.
This is long obsolete, and gcs have been removed from GTK3