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 318074 - gtk_default_draw_flat_box ignore style->bg_pixmap (gtk_entry)
gtk_default_draw_flat_box ignore style->bg_pixmap (gtk_entry)
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 318638
 
 
Reported: 2005-10-06 01:37 UTC by Jochen Baier
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12



Description Jochen Baier 2005-10-06 01:37:17 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;

}
Comment 1 Jochen Baier 2005-10-07 03:35:16 UTC
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.
Comment 2 Matthias Clasen 2005-10-25 19:24:00 UTC
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.
Comment 3 Raphael Slinckx 2006-02-12 17:43:56 UTC
Could this be reviewed ?
It would allow deskbar-applet to have a transparent entry in the panel. See #318638

Comment 4 Matthias Clasen 2006-03-15 21:34:41 UTC
You can certainly write a theme engine that does what this patch proposes...
Comment 5 Matthias Clasen 2006-04-18 22:36:48 UTC
I tend to wontfix this and leave it to theme engines to enable transparent 
entries.
Comment 6 Raphael Slinckx 2006-04-18 23:30:46 UTC
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..