gtk/gtkimage.c: use accessor functions to access GtkWidget

This commit is contained in:
Javier Jardón 2010-08-11 23:10:44 +02:00
parent ec2f2c3daf
commit a48d28848e

View File

@ -1521,13 +1521,15 @@ animation_timeout (gpointer data)
delay = gdk_pixbuf_animation_iter_get_delay_time (priv->data.anim.iter); delay = gdk_pixbuf_animation_iter_get_delay_time (priv->data.anim.iter);
if (delay >= 0) if (delay >= 0)
{ {
GtkWidget *widget = GTK_WIDGET (image);
priv->data.anim.frame_timeout = priv->data.anim.frame_timeout =
gdk_threads_add_timeout (delay, animation_timeout, image); gdk_threads_add_timeout (delay, animation_timeout, image);
gtk_widget_queue_draw (GTK_WIDGET (image)); gtk_widget_queue_draw (widget);
if (gtk_widget_is_drawable (GTK_WIDGET (image))) if (gtk_widget_is_drawable (widget))
gdk_window_process_updates (GTK_WIDGET (image)->window, TRUE); gdk_window_process_updates (gtk_widget_get_window (widget), TRUE);
} }
return FALSE; return FALSE;
@ -1792,6 +1794,7 @@ gtk_image_expose (GtkWidget *widget,
if (gtk_widget_get_mapped (widget) && if (gtk_widget_get_mapped (widget) &&
priv->storage_type != GTK_IMAGE_EMPTY) priv->storage_type != GTK_IMAGE_EMPTY)
{ {
GtkAllocation allocation;
GtkMisc *misc; GtkMisc *misc;
GdkRectangle area, image_bound; GdkRectangle area, image_bound;
gint x, y, mask_x, mask_y; gint x, y, mask_x, mask_y;
@ -1812,8 +1815,10 @@ gtk_image_expose (GtkWidget *widget,
*/ */
if (priv->need_calc_size) if (priv->need_calc_size)
gtk_image_calc_size (image); gtk_image_calc_size (image);
if (!gdk_rectangle_intersect (&area, &widget->allocation, &area)) gtk_widget_get_allocation (widget, &allocation);
if (!gdk_rectangle_intersect (&area, &allocation, &area))
return FALSE; return FALSE;
gtk_misc_get_alignment (misc, &xalign, &yalign); gtk_misc_get_alignment (misc, &xalign, &yalign);
@ -1822,10 +1827,8 @@ gtk_image_expose (GtkWidget *widget,
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
xalign = 1.0 - xalign; xalign = 1.0 - xalign;
x = floor (widget->allocation.x + xpad x = floor (allocation.x + xpad + ((allocation.width - priv->required_width) * xalign));
+ ((widget->allocation.width - priv->required_width) * xalign)); y = floor (allocation.y + ypad + ((allocation.height - priv->required_height) * yalign));
y = floor (widget->allocation.y + ypad
+ ((widget->allocation.height - priv->required_height) * yalign));
mask_x = x; mask_x = x;
mask_y = y; mask_y = y;
@ -1901,7 +1904,7 @@ gtk_image_expose (GtkWidget *widget,
case GTK_IMAGE_ICON_SET: case GTK_IMAGE_ICON_SET:
pixbuf = pixbuf =
gtk_icon_set_render_icon (priv->data.icon_set.icon_set, gtk_icon_set_render_icon (priv->data.icon_set.icon_set,
widget->style, gtk_widget_get_style (widget),
gtk_widget_get_direction (widget), gtk_widget_get_direction (widget),
gtk_widget_get_state (widget), gtk_widget_get_state (widget),
priv->icon_size, priv->icon_size,
@ -2010,8 +2013,8 @@ gtk_image_expose (GtkWidget *widget,
gtk_icon_source_set_size (source, gtk_icon_source_set_size (source,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_icon_source_set_size_wildcarded (source, FALSE); gtk_icon_source_set_size_wildcarded (source, FALSE);
rendered = gtk_style_render_icon (widget->style, rendered = gtk_style_render_icon (gtk_widget_get_style (widget),
source, source,
gtk_widget_get_direction (widget), gtk_widget_get_direction (widget),
gtk_widget_get_state (widget), gtk_widget_get_state (widget),
@ -2028,7 +2031,7 @@ gtk_image_expose (GtkWidget *widget,
if (pixbuf) if (pixbuf)
{ {
cairo_t *cr = gdk_cairo_create (widget->window); cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
gdk_cairo_rectangle (cr, &image_bound); gdk_cairo_rectangle (cr, &image_bound);
cairo_fill (cr); cairo_fill (cr);
@ -2043,7 +2046,7 @@ gtk_image_expose (GtkWidget *widget,
switch (priv->storage_type) switch (priv->storage_type)
{ {
case GTK_IMAGE_PIXMAP: case GTK_IMAGE_PIXMAP:
cr = gdk_cairo_create (widget->window); cr = gdk_cairo_create (gtk_widget_get_window (widget));
if (mask) if (mask)
{ {
@ -2066,7 +2069,6 @@ gtk_image_expose (GtkWidget *widget,
cairo_destroy (cr); cairo_destroy (cr);
break; break;
case GTK_IMAGE_PIXBUF: case GTK_IMAGE_PIXBUF:
case GTK_IMAGE_STOCK: case GTK_IMAGE_STOCK:
case GTK_IMAGE_ICON_SET: case GTK_IMAGE_ICON_SET:
@ -2247,7 +2249,7 @@ gtk_image_calc_size (GtkImage *image)
case GTK_IMAGE_ICON_SET: case GTK_IMAGE_ICON_SET:
pixbuf = gtk_icon_set_render_icon (priv->data.icon_set.icon_set, pixbuf = gtk_icon_set_render_icon (priv->data.icon_set.icon_set,
widget->style, gtk_widget_get_style (widget),
gtk_widget_get_direction (widget), gtk_widget_get_direction (widget),
gtk_widget_get_state (widget), gtk_widget_get_state (widget),
priv->icon_size, priv->icon_size,