GNOME Bugzilla – Bug 318074
gtk_default_draw_flat_box ignore style->bg_pixmap (gtk_entry)
Last modified: 2011-02-04 16:10:27 UTC
Distribution/Version: slackware/10.2 it is not possible to set a pixmap to the gtk_entry background. Reason: on expose event the entry draw a colored rectangle instead of the pixmap. the bad code: gtk_default_draw_flat_box() (gtkstyle.c) line: if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] || GDK_IS_PIXMAP (window)) even if the first equation is false, second will/could be true -> no pixmap background if i remove the second equation the pixmap will be draw. actually i do not know for what the second equation stands ... it could maybe look like that: if (!style->bg_pixmap[state_type] && ( gc1 != style->bg_gc[state_type] || GDK_IS_PIXMAP (window))) gtk-demo do not show any weird output with this change. test code: #include <gtk/gtk.h> GdkPixmap *pixmap; void set_background (GtkWidget *widget, GdkPixmap *pixmap) { GtkRcStyle *rc_style; GtkStyle *style; style = gtk_style_copy (widget->style); if (style->bg_pixmap[0]) g_object_unref (style->bg_pixmap[0]); style->bg_pixmap[0] = g_object_ref (pixmap); gtk_widget_set_style (widget, style); g_object_unref (style); } int main( int argc, char *argv[] ) { GtkWidget *window1; GtkWidget *entry; gtk_init (&argc, &argv); window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "Hello"); gtk_container_add (GTK_CONTAINER (window1), entry); gtk_widget_realize (window1); gtk_widget_realize (entry); pixmap= gdk_pixmap_create_from_xpm (GDK_DRAWABLE(entry->window), NULL, NULL, "/etc/X11/xdm/pixmaps/xorg.xpm"); g_assert (pixmap != NULL); set_background (entry, pixmap); gtk_widget_show (entry); gtk_widget_show (window1); gtk_main (); return 0; }
update: if (!style->bg_pixmap[state_type] && !GDK_IS_PIXMAP (window)) { //rectangle else //pixmap my old code broke tooltip window. i removed the gc equation cause both cases can occur (verify this !). gtk-demo looks good.
This needs a careful look to figure out what is going on with the various gc's there. Its probably best to not change this in the middle of a stable series.
Could this be reviewed ? It would allow deskbar-applet to have a transparent entry in the panel. See #318638
You can certainly write a theme engine that does what this patch proposes...
I tend to wontfix this and leave it to theme engines to enable transparent entries.
Yes you can wontfix this, but what i really wanted, and maybe is not related to this bug ( i don't really know), is a way to get the entry external corners to be transparent, that way when you put the entry in the panel, it looks rounded, and not like a big rectangle block, with a little gray on the 'fake' rounded borders..