After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 165706 - Strange gdk_gc_set_rgb_fg_color() warning when calling gdk_draw_layout()
Strange gdk_gc_set_rgb_fg_color() warning when calling gdk_draw_layout()
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: X11
2.6.x
Other Linux
: Normal minor
: Small fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-01-30 13:56 UTC by Gustavo Carneiro
Modified: 2010-08-25 04:51 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10



Description Gustavo Carneiro 2005-01-30 13:56:03 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:

  • #2 gdk_gc_get_colormap_warn
    at gdkgc.c line 653
  • #3 IA__gdk_gc_set_rgb_fg_color
    at gdkgc.c line 686
  • #4 get_gc
    at gdkpango.c line 255
  • #5 gdk_pango_renderer_draw_glyphs
    at gdkpango.c line 307
  • #6 pango_renderer_draw_glyphs
    at pango-renderer.c line 596
  • #7 pango_renderer_draw_layout_line
    at pango-renderer.c line 528
  • #8 pango_renderer_draw_layout
    at pango-renderer.c line 182
  • #9 IA__gdk_draw_layout_with_colors
    at gdkpango.c line 1069
  • #10 _wrap_gdk_draw_layout
    at gdk.override line 3625

Comment 1 Owen Taylor 2005-01-30 18:06:14 UTC
Which of pixmap.get_colormap() fg_gc.get_colormap() bg_gc.get_colormap()
are None?
Comment 2 Gustavo Carneiro 2005-01-31 00:39:40 UTC
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.
Comment 3 Matthias Clasen 2005-02-03 14:37:53 UTC
bitmaps don't have colormaps, we have a vague plan to change that

*** This bug has been marked as a duplicate of 75497 ***
Comment 4 Owen Taylor 2005-02-03 16:57:32 UTC
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.
Comment 5 Elijah Newren 2005-02-10 20:57:18 UTC
Is bug 166873 a duplicate of this bug?
Comment 6 Owen Taylor 2005-02-10 21:07:50 UTC
No. No bitmaps involved in that.
Comment 7 Matthias Clasen 2010-08-25 04:51:46 UTC
This is long obsolete, and gcs have been removed from GTK3