X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkthemingbackground.c;h=579d2be4dea32abe70be40ad73cd70fa39cd87b1;hb=6f1476edd3fbe31259e59ca3f03a01bf0f8ff67b;hp=650516c1785f33a9990a08744eccd95594fe1442;hpb=5e7949c47b520941e47ea0312c6eb80cee7038b9;p=~andy%2Fgtk diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c index 650516c17..579d2be4d 100644 --- a/gtk/gtkthemingbackground.c +++ b/gtk/gtkthemingbackground.c @@ -42,10 +42,6 @@ */ #include "fallback-c89.c" -typedef struct { - gint idx; -} GtkThemingBackgroundLayer; - static const GtkRoundedBox * gtk_theming_background_get_box (GtkThemingBackground *bg, GtkCssArea area) @@ -86,7 +82,7 @@ _gtk_theming_background_paint_color (GtkThemingBackground *bg, static void _gtk_theming_background_paint_layer (GtkThemingBackground *bg, - GtkThemingBackgroundLayer *layer, + guint idx, cairo_t *cr) { GtkCssRepeatStyle hrepeat, vrepeat; @@ -96,27 +92,27 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg, double image_width, image_height; double width, height; - pos = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION), layer->idx); - repeat = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), layer->idx); + pos = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION), idx); + repeat = _gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_REPEAT), idx); hrepeat = _gtk_css_background_repeat_value_get_x (repeat); vrepeat = _gtk_css_background_repeat_value_get_y (repeat); image = _gtk_css_image_value_get_image ( _gtk_css_array_value_get_nth ( _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE), - layer->idx)); + idx)); origin = gtk_theming_background_get_box ( bg, _gtk_css_area_value_get ( _gtk_css_array_value_get_nth ( _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_ORIGIN), - layer->idx))); + idx))); width = origin->box.width; height = origin->box.height; if (image == NULL || width <= 0 || height <= 0) return; - _gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE), layer->idx), + _gtk_css_bg_size_value_compute_size (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE), idx), image, width, height, @@ -141,7 +137,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg, _gtk_css_area_value_get ( _gtk_css_array_value_get_nth ( _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP), - layer->idx))), + idx))), cr); cairo_clip (cr); @@ -276,21 +272,14 @@ _gtk_theming_background_apply_shadow (GtkThemingBackground *bg, &bg->padding_box); } -static void -_gtk_theming_background_init_layer (GtkThemingBackground *bg, - GtkThemingBackgroundLayer *layer, - gint idx) -{ - layer->idx = idx; -} - static void _gtk_theming_background_init_context (GtkThemingBackground *bg) { GtkStateFlags flags = gtk_style_context_get_state (bg->context); + GtkBorder border, padding; - gtk_style_context_get_border (bg->context, flags, &bg->border); - gtk_style_context_get_padding (bg->context, flags, &bg->padding); + gtk_style_context_get_border (bg->context, flags, &border); + gtk_style_context_get_padding (bg->context, flags, &padding); gtk_style_context_get_background_color (bg->context, flags, &bg->bg_color); /* In the CSS box model, by default the background positioning area is @@ -306,13 +295,13 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg) bg->padding_box = bg->border_box; _gtk_rounded_box_shrink (&bg->padding_box, - bg->border.top, bg->border.right, - bg->border.bottom, bg->border.left); + border.top, border.right, + border.bottom, border.left); bg->content_box = bg->padding_box; _gtk_rounded_box_shrink (&bg->content_box, - bg->padding.top, bg->padding.right, - bg->padding.bottom, bg->padding.left); + padding.top, padding.right, + padding.bottom, padding.left); } void @@ -362,7 +351,6 @@ _gtk_theming_background_render (GtkThemingBackground *bg, cairo_t *cr) { gint idx; - GtkThemingBackgroundLayer layer; GtkCssValue *background_image; background_image = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE); @@ -374,8 +362,7 @@ _gtk_theming_background_render (GtkThemingBackground *bg, for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--) { - _gtk_theming_background_init_layer (bg, &layer, idx); - _gtk_theming_background_paint_layer (bg, &layer, cr); + _gtk_theming_background_paint_layer (bg, idx, cr); } _gtk_theming_background_apply_shadow (bg, cr);