[gtk+/rendering-cleanup: 68/140] API: image: Remove ability to set image from a pixmap



commit 4e9d291fd7975d330a6f3a19e2bc8253482ac91c
Author: Benjamin Otte <otte redhat com>
Date:   Wed Aug 25 16:50:14 2010 +0200

    API: image: Remove ability to set image from a pixmap

 gtk/gtk.symbols                |    3 -
 gtk/gtkimage.c                 |  337 +++++-----------------------------------
 gtk/gtkimage.h                 |   17 --
 modules/other/gail/gailimage.c |    7 -
 4 files changed, 39 insertions(+), 325 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 11f495c..ccb520c 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1752,7 +1752,6 @@ gtk_image_get_icon_name
 gtk_image_get_icon_set
 gtk_image_get_pixbuf
 gtk_image_get_pixel_size
-gtk_image_get_pixmap
 gtk_image_get_stock
 gtk_image_get_gicon
 gtk_image_get_storage_type
@@ -1768,7 +1767,6 @@ gtk_image_new_from_file_utf8
 gtk_image_new_from_icon_name
 gtk_image_new_from_icon_set
 gtk_image_new_from_pixbuf
-gtk_image_new_from_pixmap
 gtk_image_new_from_stock
 gtk_image_new_from_gicon
 gtk_image_set_from_animation
@@ -1781,7 +1779,6 @@ gtk_image_set_from_file_utf8
 gtk_image_set_from_icon_name
 gtk_image_set_from_icon_set
 gtk_image_set_from_pixbuf
-gtk_image_set_from_pixmap
 gtk_image_set_from_stock
 gtk_image_set_from_gicon
 gtk_image_set_pixel_size
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 2a41329..c07d186 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -131,11 +131,9 @@ struct _GtkImagePriv
 {
   GtkIconSize           icon_size;      /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ICON_NAME */
   GtkImageType          storage_type;
-  GdkBitmap            *mask;           /* Only used with GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE */
 
   union
   {
-    GtkImagePixmapData     pixmap;
     GtkImagePixbufData     pixbuf;
     GtkImageStockData      stock;
     GtkImageIconSetData    icon_set;
@@ -187,8 +185,6 @@ enum
 {
   PROP_0,
   PROP_PIXBUF,
-  PROP_PIXMAP,
-  PROP_MASK,
   PROP_FILE,
   PROP_STOCK,
   PROP_ICON_SET,
@@ -236,22 +232,6 @@ gtk_image_class_init (GtkImageClass *class)
                                                         GTK_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class,
-                                   PROP_PIXMAP,
-                                   g_param_spec_object ("pixmap",
-                                                        P_("Pixmap"),
-                                                        P_("A GdkPixmap to display"),
-                                                        GDK_TYPE_PIXMAP,
-                                                        GTK_PARAM_READWRITE));
-
-  g_object_class_install_property (gobject_class,
-                                   PROP_MASK,
-                                   g_param_spec_object ("mask",
-                                                        P_("Mask"),
-                                                        P_("Mask bitmap to use with GdkPixmap"),
-                                                        GDK_TYPE_PIXMAP,
-                                                        GTK_PARAM_READWRITE));
-  
-  g_object_class_install_property (gobject_class,
                                    PROP_FILE,
                                    g_param_spec_string ("file",
                                                         P_("Filename"),
@@ -369,7 +349,6 @@ gtk_image_init (GtkImage *image)
 
   priv->storage_type = GTK_IMAGE_EMPTY;
   priv->icon_size = DEFAULT_ICON_SIZE;
-  priv->mask = NULL;
 
   priv->pixel_size = -1;
 
@@ -401,30 +380,6 @@ gtk_image_set_property (GObject      *object,
       gtk_image_set_from_pixbuf (image,
                                  g_value_get_object (value));
       break;
-    case PROP_PIXMAP:
-      gtk_image_set_from_pixmap (image,
-                                 g_value_get_object (value),
-                                 priv->mask);
-      break;
-    case PROP_MASK:
-      if (priv->storage_type == GTK_IMAGE_PIXMAP)
-        gtk_image_set_from_pixmap (image,
-                                   priv->data.pixmap.pixmap,
-                                   g_value_get_object (value));
-      else
-        {
-          GdkBitmap *mask;
-
-          mask = g_value_get_object (value);
-
-          if (mask)
-            g_object_ref (mask);
-
-          gtk_image_clear (image);
-
-          priv->mask = mask;
-        }
-      break;
     case PROP_FILE:
       gtk_image_set_from_file (image, g_value_get_string (value));
       break;
@@ -503,16 +458,6 @@ gtk_image_get_property (GObject     *object,
         g_value_set_object (value,
                             gtk_image_get_pixbuf (image));
       break;
-    case PROP_PIXMAP:
-      if (priv->storage_type != GTK_IMAGE_PIXMAP)
-        g_value_set_object (value, NULL);
-      else
-        g_value_set_object (value,
-                            priv->data.pixmap.pixmap);
-      break;
-    case PROP_MASK:
-      g_value_set_object (value, priv->mask);
-      break;
     case PROP_FILE:
       g_value_set_string (value, priv->filename);
       break;
@@ -569,32 +514,6 @@ gtk_image_get_property (GObject     *object,
 
 
 /**
- * gtk_image_new_from_pixmap:
- * @pixmap: (allow-none): a #GdkPixmap, or %NULL
- * @mask: (allow-none): a #GdkBitmap, or %NULL
- *
- * Creates a #GtkImage widget displaying @pixmap with a @mask.
- * A #GdkPixmap is a server-side image buffer in the pixel format of the
- * current display. The #GtkImage does not assume a reference to the
- * pixmap or mask; you still need to unref them if you own references.
- * #GtkImage will add its own reference rather than adopting yours.
- * 
- * Return value: a new #GtkImage
- **/
-GtkWidget*
-gtk_image_new_from_pixmap (GdkPixmap *pixmap,
-                           GdkBitmap *mask)
-{
-  GtkImage *image;
-
-  image = g_object_new (GTK_TYPE_IMAGE, NULL);
-
-  gtk_image_set_from_pixmap (image, pixmap, mask);
-
-  return GTK_WIDGET (image);
-}
-
-/**
  * gtk_image_new_from_file:
  * @filename: a filename
  * 
@@ -800,61 +719,6 @@ gtk_image_new_from_gicon (GIcon *icon,
 }
 
 /**
- * gtk_image_set_from_pixmap:
- * @image: a #GtkImage
- * @pixmap: (allow-none): a #GdkPixmap or %NULL
- * @mask: (allow-none): a #GdkBitmap or %NULL
- *
- * See gtk_image_new_from_pixmap() for details.
- **/
-void
-gtk_image_set_from_pixmap (GtkImage  *image,
-                           GdkPixmap *pixmap,
-                           GdkBitmap *mask)
-{
-  GtkImagePriv *priv;
-
-  g_return_if_fail (GTK_IS_IMAGE (image));
-  g_return_if_fail (pixmap == NULL ||
-                    GDK_IS_PIXMAP (pixmap));
-  g_return_if_fail (mask == NULL ||
-                    GDK_IS_PIXMAP (mask));
-
-  priv = image->priv;
-
-  g_object_freeze_notify (G_OBJECT (image));
-  
-  if (pixmap)
-    g_object_ref (pixmap);
-
-  if (mask)
-    g_object_ref (mask);
-
-  gtk_image_clear (image);
-
-  priv->mask = mask;
-
-  if (pixmap)
-    {
-      int width;
-      int height;
-
-      priv->storage_type = GTK_IMAGE_PIXMAP;
-
-      priv->data.pixmap.pixmap = pixmap;
-
-      gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
-
-      gtk_image_update_size (image, width, height);
-    }
-
-  g_object_notify (G_OBJECT (image), "pixmap");
-  g_object_notify (G_OBJECT (image), "mask");
-  
-  g_object_thaw_notify (G_OBJECT (image));
-}
-
-/**
  * gtk_image_set_from_file:
  * @image: a #GtkImage
  * @filename: (allow-none): a filename or %NULL
@@ -1204,41 +1068,6 @@ gtk_image_get_storage_type (GtkImage *image)
 }
 
 /**
- * gtk_image_get_pixmap:
- * @image: a #GtkImage
- * @pixmap: (out) (transfer none) (allow-none): location to store the
- *     pixmap, or %NULL
- * @mask: (out) (transfer none) (allow-none): location to store the
- *     mask, or %NULL
- *
- * Gets the pixmap and mask being displayed by the #GtkImage.
- * The storage type of the image must be %GTK_IMAGE_EMPTY or
- * %GTK_IMAGE_PIXMAP (see gtk_image_get_storage_type()).
- * The caller of this function does not own a reference to the
- * returned pixmap and mask.
- **/
-void
-gtk_image_get_pixmap (GtkImage   *image,
-                      GdkPixmap **pixmap,
-                      GdkBitmap **mask)
-{
-  GtkImagePriv *priv;
-
-  g_return_if_fail (GTK_IS_IMAGE (image));
-
-  priv = image->priv;
-
-  g_return_if_fail (priv->storage_type == GTK_IMAGE_PIXMAP ||
-                    priv->storage_type == GTK_IMAGE_EMPTY);
-
-  if (pixmap)
-    *pixmap = priv->data.pixmap.pixmap;
-
-  if (mask)
-    *mask = priv->mask;
-}
-
-/**
  * gtk_image_get_pixbuf:
  * @image: a #GtkImage
  *
@@ -1791,10 +1620,9 @@ gtk_image_expose (GtkWidget      *widget,
     {
       GtkMisc *misc;
       GdkRectangle area, image_bound;
-      gint x, y, mask_x, mask_y;
+      gint x, y;
       gint xpad, ypad;
       gfloat xalign, yalign;
-      GdkBitmap *mask;
       GdkPixbuf *pixbuf;
       GtkStateType state;
       gboolean needs_state_transform;
@@ -1823,41 +1651,16 @@ gtk_image_expose (GtkWidget      *widget,
 		 + ((widget->allocation.width - widget->requisition.width) * xalign));
       y = floor (widget->allocation.y + ypad
 		 + ((widget->allocation.height - widget->requisition.height) * yalign));
-      mask_x = x;
-      mask_y = y;
       
       image_bound.x = x;
       image_bound.y = y;      
       image_bound.width = 0;
       image_bound.height = 0;      
 
-      mask = NULL;
-      pixbuf = NULL;
       needs_state_transform = gtk_widget_get_state (widget) != GTK_STATE_NORMAL;
       
       switch (priv->storage_type)
         {
-        case GTK_IMAGE_PIXMAP:
-          mask = priv->mask;
-          gdk_drawable_get_size (priv->data.pixmap.pixmap,
-                                 &image_bound.width,
-                                 &image_bound.height);
-	  if (rectangle_intersect_even (&area, &image_bound) &&
-	      needs_state_transform)
-            {
-              pixbuf = gdk_pixbuf_get_from_drawable (NULL,
-                                                     priv->data.pixmap.pixmap,
-                                                     gtk_widget_get_colormap (widget),
-                                                     image_bound.x - x, image_bound.y - y,
-						     0, 0,
-                                                     image_bound.width,
-                                                     image_bound.height);
-
-	      x = image_bound.x;
-	      y = image_bound.y;
-            }
-	  
-          break;
 
         case GTK_IMAGE_PIXBUF:
           image_bound.width = gdk_pixbuf_get_width (priv->data.pixbuf.pixbuf);
@@ -1986,99 +1789,53 @@ gtk_image_expose (GtkWidget      *widget,
 	  
         case GTK_IMAGE_EMPTY:
           g_assert_not_reached ();
+          pixbuf = NULL;
           break;
         }
 
-      if (rectangle_intersect_even (&area, &image_bound))
+      if (pixbuf &&
+          rectangle_intersect_even (&area, &image_bound))
         {
-          if (pixbuf)
-            {
-              if (needs_state_transform)
-                {
-                  GtkIconSource *source;
-                  GdkPixbuf *rendered;
-
-                  source = gtk_icon_source_new ();
-                  gtk_icon_source_set_pixbuf (source, pixbuf);
-                  /* The size here is arbitrary; since size isn't
-                   * wildcarded in the souce, it isn't supposed to be
-                   * scaled by the engine function
-                   */
-                  gtk_icon_source_set_size (source,
-                                            GTK_ICON_SIZE_SMALL_TOOLBAR);
-                  gtk_icon_source_set_size_wildcarded (source, FALSE);
-                  
-                  rendered = gtk_style_render_icon (widget->style,
-                                                    source,
-                                                    gtk_widget_get_direction (widget),
-                                                    gtk_widget_get_state (widget),
-                                                    /* arbitrary */
-                                                    (GtkIconSize)-1,
-                                                    widget,
-                                                    "gtk-image");
-
-                  gtk_icon_source_free (source);
-
-                  g_object_unref (pixbuf);
-                  pixbuf = rendered;
-                }
-
-              if (pixbuf)
-                {
-                  cairo_t *cr = gdk_cairo_create (widget->window);
-                  gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
-                  gdk_cairo_rectangle (cr, &image_bound);
-                  cairo_fill (cr);
-                  cairo_destroy (cr);
-                }
-            }
-          else
+          cairo_t *cr;
+
+          if (needs_state_transform)
             {
-              cairo_t *cr;
-              cairo_pattern_t *mask_pattern;
-
-              switch (priv->storage_type)
-                {
-                case GTK_IMAGE_PIXMAP:
-                  cr = gdk_cairo_create (widget->window);
-
-                  if (mask)
-                    {
-                      /* hack to get the mask pattern */
-                      gdk_cairo_set_source_pixmap (cr, mask, mask_x, mask_y);
-                      mask_pattern = cairo_get_source (cr);
-                      cairo_pattern_reference (mask_pattern);
-
-                      gdk_cairo_set_source_pixmap (cr, priv->data.pixmap.pixmap, x, y);
-                      gdk_cairo_rectangle (cr, &image_bound);
-                      cairo_clip (cr);
-                      cairo_mask (cr, mask_pattern);
-                    }
-                  else 
-                    {
-                      gdk_cairo_set_source_pixmap (cr, priv->data.pixmap.pixmap, x, y);
-                      gdk_cairo_rectangle (cr, &image_bound);
-                      cairo_fill (cr);
-                    }
-
-                  cairo_destroy (cr);
-                  break;
+              GtkIconSource *source;
+              GdkPixbuf *rendered;
+
+              source = gtk_icon_source_new ();
+              gtk_icon_source_set_pixbuf (source, pixbuf);
+              /* The size here is arbitrary; since size isn't
+               * wildcarded in the souce, it isn't supposed to be
+               * scaled by the engine function
+               */
+              gtk_icon_source_set_size (source,
+                                        GTK_ICON_SIZE_SMALL_TOOLBAR);
+              gtk_icon_source_set_size_wildcarded (source, FALSE);
               
-                case GTK_IMAGE_PIXBUF:
-                case GTK_IMAGE_STOCK:
-                case GTK_IMAGE_ICON_SET:
-                case GTK_IMAGE_ANIMATION:
-		case GTK_IMAGE_ICON_NAME:
-                case GTK_IMAGE_EMPTY:
-		case GTK_IMAGE_GICON:
-                  g_assert_not_reached ();
-                  break;
-                }
+              rendered = gtk_style_render_icon (widget->style,
+                                                source,
+                                                gtk_widget_get_direction (widget),
+                                                gtk_widget_get_state (widget),
+                                                /* arbitrary */
+                                                (GtkIconSize)-1,
+                                                widget,
+                                                "gtk-image");
+
+              gtk_icon_source_free (source);
+
+              g_object_unref (pixbuf);
+              pixbuf = rendered;
             }
+
+          cr = gdk_cairo_create (widget->window);
+          gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+          gdk_cairo_rectangle (cr, &image_bound);
+          cairo_fill (cr);
+          cairo_destroy (cr);
         } /* if rectangle intersects */      
 
-      if (pixbuf)
-	g_object_unref (pixbuf);
+      g_object_unref (pixbuf);
 
     } /* if widget is drawable */
 
@@ -2095,13 +1852,6 @@ gtk_image_reset (GtkImage *image)
   if (priv->storage_type != GTK_IMAGE_EMPTY)
     g_object_notify (G_OBJECT (image), "storage-type");
 
-  if (priv->mask)
-    {
-      g_object_unref (priv->mask);
-      priv->mask = NULL;
-      g_object_notify (G_OBJECT (image), "mask");
-    }
-
   if (priv->icon_size != DEFAULT_ICON_SIZE)
     {
       priv->icon_size = DEFAULT_ICON_SIZE;
@@ -2110,15 +1860,6 @@ gtk_image_reset (GtkImage *image)
   
   switch (priv->storage_type)
     {
-    case GTK_IMAGE_PIXMAP:
-
-      if (priv->data.pixmap.pixmap)
-        g_object_unref (priv->data.pixmap.pixmap);
-      priv->data.pixmap.pixmap = NULL;
-      
-      g_object_notify (G_OBJECT (image), "pixmap");
-      
-      break;
 
     case GTK_IMAGE_PIXBUF:
 
diff --git a/gtk/gtkimage.h b/gtk/gtkimage.h
index 0a02219..f55b75c 100644
--- a/gtk/gtkimage.h
+++ b/gtk/gtkimage.h
@@ -50,8 +50,6 @@ typedef struct _GtkImage       GtkImage;
 typedef struct _GtkImagePriv   GtkImagePriv;
 typedef struct _GtkImageClass  GtkImageClass;
 
-typedef struct _GtkImagePixmapData  GtkImagePixmapData;
-typedef struct _GtkImageImageData   GtkImageImageData;
 typedef struct _GtkImagePixbufData  GtkImagePixbufData;
 typedef struct _GtkImageStockData   GtkImageStockData;
 typedef struct _GtkImageIconSetData GtkImageIconSetData;
@@ -59,11 +57,6 @@ typedef struct _GtkImageAnimationData GtkImageAnimationData;
 typedef struct _GtkImageIconNameData  GtkImageIconNameData;
 typedef struct _GtkImageGIconData     GtkImageGIconData;
 
-struct _GtkImagePixmapData
-{
-  GdkPixmap *pixmap;
-};
-
 struct _GtkImagePixbufData
 {
   GdkPixbuf *pixbuf;
@@ -103,7 +96,6 @@ struct _GtkImageGIconData
 /**
  * GtkImageType:
  * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
- * @GTK_IMAGE_PIXMAP: the widget contains a #GdkPixmap
  * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
  * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see
  *  <xref linkend="gtk3-Stock-Items"/>)
@@ -125,7 +117,6 @@ struct _GtkImageGIconData
 typedef enum
 {
   GTK_IMAGE_EMPTY,
-  GTK_IMAGE_PIXMAP,
   GTK_IMAGE_PIXBUF,
   GTK_IMAGE_STOCK,
   GTK_IMAGE_ICON_SET,
@@ -168,8 +159,6 @@ struct _GtkImageClass
 GType      gtk_image_get_type (void) G_GNUC_CONST;
 
 GtkWidget* gtk_image_new                (void);
-GtkWidget* gtk_image_new_from_pixmap    (GdkPixmap       *pixmap,
-                                         GdkBitmap       *mask);
 GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
 GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
@@ -183,9 +172,6 @@ GtkWidget* gtk_image_new_from_gicon     (GIcon           *icon,
 					 GtkIconSize      size);
 
 void gtk_image_clear              (GtkImage        *image);
-void gtk_image_set_from_pixmap    (GtkImage        *image,
-                                   GdkPixmap       *pixmap,
-                                   GdkBitmap       *mask);
 void gtk_image_set_from_file      (GtkImage        *image,
                                    const gchar     *filename);
 void gtk_image_set_from_pixbuf    (GtkImage        *image,
@@ -209,9 +195,6 @@ void gtk_image_set_pixel_size     (GtkImage        *image,
 
 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
 
-void       gtk_image_get_pixmap   (GtkImage         *image,
-                                   GdkPixmap       **pixmap,
-                                   GdkBitmap       **mask);
 GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
 void       gtk_image_get_stock    (GtkImage         *image,
                                    gchar           **stock_id,
diff --git a/modules/other/gail/gailimage.c b/modules/other/gail/gailimage.c
index 8fcfa47..38d0c58 100644
--- a/modules/other/gail/gailimage.c
+++ b/modules/other/gail/gailimage.c
@@ -207,13 +207,6 @@ gail_image_get_image_size (AtkImage *image,
   image_type = gtk_image_get_storage_type(gtk_image);
  
   switch(image_type) {
-    case GTK_IMAGE_PIXMAP:
-    {	
-      GdkPixmap *pixmap;
-      gtk_image_get_pixmap(gtk_image, &pixmap, NULL);
-      gdk_drawable_get_size (pixmap, width, height);
-      break;
-    }
     case GTK_IMAGE_PIXBUF:
     {
       GdkPixbuf *pixbuf;



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