[gtk+/rendering-cleanup: 82/95] style: Don't use gdk_pixmap_create_from_xpm



commit 9a6b1728f6f176650c7029fdbfcc13f29e17c416
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 6 16:02:24 2010 +0200

    style: Don't use gdk_pixmap_create_from_xpm
    
    Instead, do what that code did manually.

 gtk/gtkstyle.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 603b876..0783427 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -1247,9 +1247,33 @@ load_bg_image (GdkColormap *colormap,
     return (GdkPixmap*) GDK_PARENT_RELATIVE;
   else
     {
-      return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
-						  bg_color,
-						  filename);
+      GdkPixmap *pixmap;
+      GdkPixbuf *pixbuf;
+      cairo_t *cr;
+      GdkScreen *screen = gdk_colormap_get_screen (colormap);
+  
+      pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+      if (!pixbuf)
+        return NULL;
+
+      pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
+                               gdk_pixbuf_get_width (pixbuf),
+                               gdk_pixbuf_get_height (pixbuf),
+                               gdk_colormap_get_visual (colormap)->depth);
+      gdk_drawable_set_colormap (pixmap, colormap);
+  
+      cr = gdk_cairo_create (pixmap);
+
+      gdk_cairo_set_source_color (cr, bg_color);
+      cairo_paint (cr);
+
+      gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+      cairo_paint (cr);
+
+      cairo_destroy (cr);
+      g_object_unref (pixbuf);
+
+      return pixmap;
     }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]