Re: GtkImage changes



Havoc Pennington <hp@redhat.com> writes:

> This is GtkImage hacked to be a general-purpose image-display widget, 
> i.e. it's no longer just for displaying GdkImage.
[snip]

> typedef struct _GtkImagePixmapData  GtkImagePixmapData;
> typedef struct _GtkImageImageData   GtkImageImageData;
> typedef struct _GtkImagePixbufData  GtkImagePixbufData;
> typedef struct _GtkImageStockData   GtkImageStockData;
> typedef struct _GtkImageIconSetData GtkImageIconSetData;

Can we make the GtkImage structure opaque?  Otherwise some people who
should hopefully be put in a mental institution and sent back through
time to find virus samples and who find lions walking on top of public
buildings and eat spiders and

Oh, wait.  I'm digressing.  Let's try that again.

If the structure is made opaque, then people won't do the horrible
hack of loading an image widget and then fetching a pixmap from it.

> struct _GtkImageClass
> {
>   GtkMiscClass parent_class;
> };

Can we please make it a plain GtkWidget instead of a misc?  If people
need fancy positioning, they can wrap things in a GtkAlignment.

(Computing a misc's alignment offsets inside the code is a minor but
painful pain, and makes the widget harder to maintain).

> > void       gtk_image_get_pixmap   (GtkImage         *image,
>                                    GdkPixmap       **pixmap,
>                                    GdkBitmap       **mask);
> void       gtk_image_get_image    (GtkImage         *image,
>                                    GdkImage        **gdk_image,
>                                    GdkBitmap       **mask);
> GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
> void       gtk_image_get_stock    (GtkImage         *image,
>                                    gchar           **stock_id,
>                                    GtkIconSizeType  *size);
> void       gtk_image_get_icon_set (GtkImage         *image,
>                                    GtkIconSet      **icon_set,
>                                    GtkIconSizeType  *size);

You should be able to get the type of thing you set.  Did I set a
pixbuf or an icon set?

> /* These three are deprecated */
> GtkWidget* gtk_image_new      (GdkImage   *val,
> 			       GdkBitmap  *mask);
> void       gtk_image_set      (GtkImage   *image,
> 			       GdkImage   *val,
> 			       GdkBitmap  *mask);
> void       gtk_image_get      (GtkImage   *image,
> 			       GdkImage  **val,
> 			       GdkBitmap **mask);

Just kill these.

And do we really need set_image()?  People who create GdkImages by
hand should maybe also be put in a mental institution :-)

> static gint
> gtk_image_expose (GtkWidget      *widget,
> 		  GdkEventExpose *event)
> {
[snip]
>             case GTK_IMAGE_PIXBUF:
>               gdk_pixbuf_render_to_drawable_alpha (image->data.pixbuf.pixbuf,
>                                                    widget->window,
>                                                    image_bound.x - x, image_bound.y - y,
>                                                    image_bound.x, image_bound.y,
>                                                    image_bound.width, image_bound.height,
>                                                    GDK_PIXBUF_ALPHA_FULL,
>                                                    128,
>                                                    GDK_RGB_DITHER_NORMAL,
>                                                    0, 0);
>               break;
> 
>             case GTK_IMAGE_STOCK: /* fall thru */
>             case GTK_IMAGE_ICON_SET:
>               if (stock_pixbuf)
>                 {
>                   gdk_pixbuf_render_to_drawable_alpha (stock_pixbuf,
>                                                        widget->window,
>                                                        image_bound.x - x, image_bound.y - y,
>                                                        image_bound.x, image_bound.y,
>                                                        image_bound.width, image_bound.height,
>                                                        GDK_PIXBUF_ALPHA_FULL,
>                                                        128,
>                                                        GDK_RGB_DITHER_NORMAL,
>                                                        0, 0);
>                   
>                   g_object_unref (G_OBJECT (stock_pixbuf));
>                 }
>               break;

Ugh.  Can we do something fancier if we can get the theme's background
pixbuf?  It would rock to be able to composite the actual pixbuf on
the widget's background.

  Federico




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