forked from AuroraMiddleware/gtk
Save a generic boxes source in GtkImageBorder
We used to special handle gradient, but we want to be able to store other sources (that will eventually resolve to cairo patterns). For instance, this is needed to handle win32 theme part sources.
This commit is contained in:
parent
361fcabbde
commit
e953465e33
@ -54,7 +54,8 @@ enum {
|
||||
|
||||
struct _GtkBorderImage {
|
||||
cairo_pattern_t *source;
|
||||
GtkGradient *source_gradient;
|
||||
gpointer source_boxed;
|
||||
GType boxed_type;
|
||||
|
||||
GtkBorder slice;
|
||||
GtkBorder *width;
|
||||
@ -90,18 +91,21 @@ _gtk_border_image_new (cairo_pattern_t *pattern,
|
||||
}
|
||||
|
||||
GtkBorderImage *
|
||||
_gtk_border_image_new_for_gradient (GtkGradient *gradient,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat)
|
||||
_gtk_border_image_new_for_boxed (GType boxed_type,
|
||||
gpointer boxed,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat)
|
||||
{
|
||||
GtkBorderImage *image;
|
||||
|
||||
image = g_slice_new0 (GtkBorderImage);
|
||||
|
||||
image->ref_count = 1;
|
||||
|
||||
if (gradient != NULL)
|
||||
image->source_gradient = gtk_gradient_ref (gradient);
|
||||
if (boxed != NULL)
|
||||
image->source_boxed = g_boxed_copy (boxed_type, boxed);
|
||||
image->boxed_type = boxed_type;
|
||||
|
||||
if (slice != NULL)
|
||||
image->slice = *slice;
|
||||
@ -137,8 +141,8 @@ _gtk_border_image_unref (GtkBorderImage *image)
|
||||
if (image->source != NULL)
|
||||
cairo_pattern_destroy (image->source);
|
||||
|
||||
if (image->source_gradient != NULL)
|
||||
gtk_gradient_unref (image->source_gradient);
|
||||
if (image->source_boxed != NULL)
|
||||
g_boxed_free (image->boxed_type, image->source_boxed);
|
||||
|
||||
if (image->width != NULL)
|
||||
gtk_border_free (image->width);
|
||||
@ -157,8 +161,8 @@ _gtk_border_image_unpack (const GValue *value,
|
||||
parameter[0].name = "border-image-source";
|
||||
|
||||
if ((image != NULL) &&
|
||||
(image->source_gradient != NULL))
|
||||
g_value_init (¶meter[0].value, GTK_TYPE_GRADIENT);
|
||||
(image->source_boxed != NULL))
|
||||
g_value_init (¶meter[0].value, image->boxed_type);
|
||||
else
|
||||
g_value_init (¶meter[0].value, CAIRO_GOBJECT_TYPE_PATTERN);
|
||||
|
||||
@ -173,8 +177,8 @@ _gtk_border_image_unpack (const GValue *value,
|
||||
|
||||
if (image != NULL)
|
||||
{
|
||||
if (image->source_gradient != NULL)
|
||||
g_value_set_boxed (¶meter[0].value, image->source_gradient);
|
||||
if (image->source_boxed != NULL)
|
||||
g_value_set_boxed (¶meter[0].value, image->source_boxed);
|
||||
else
|
||||
g_value_set_boxed (¶meter[0].value, image->source);
|
||||
|
||||
|
@ -42,7 +42,8 @@ GtkBorderImage * _gtk_border_image_new (cairo_pattern_t *sour
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat);
|
||||
GtkBorderImage * _gtk_border_image_new_for_gradient (GtkGradient *gradient,
|
||||
GtkBorderImage * _gtk_border_image_new_for_boxed (GType boxed_type,
|
||||
gpointer boxed,
|
||||
GtkBorder *slice,
|
||||
GtkBorder *width,
|
||||
GtkCssBorderImageRepeat *repeat);
|
||||
|
@ -1250,7 +1250,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
GValue temp = G_VALUE_INIT;
|
||||
cairo_pattern_t *pattern = NULL;
|
||||
GtkGradient *gradient = NULL;
|
||||
gconstpointer *boxed = NULL;
|
||||
GType boxed_type;
|
||||
GtkBorder slice, *width = NULL, *parsed_slice;
|
||||
GtkCssBorderImageRepeat repeat, *parsed_repeat;
|
||||
gboolean retval = FALSE;
|
||||
@ -1261,8 +1262,9 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
if (!pattern_value_parse (parser, base, &temp))
|
||||
return FALSE;
|
||||
|
||||
if (G_VALUE_TYPE (&temp) == GTK_TYPE_GRADIENT)
|
||||
gradient = g_value_dup_boxed (&temp);
|
||||
boxed_type = G_VALUE_TYPE (&temp);
|
||||
if (boxed_type != CAIRO_GOBJECT_TYPE_PATTERN)
|
||||
boxed = g_value_dup_boxed (&temp);
|
||||
else
|
||||
pattern = g_value_dup_boxed (&temp);
|
||||
|
||||
@ -1297,8 +1299,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
|
||||
g_value_unset (&temp);
|
||||
|
||||
if (gradient != NULL)
|
||||
image = _gtk_border_image_new_for_gradient (gradient, &slice, width, &repeat);
|
||||
if (boxed != NULL)
|
||||
image = _gtk_border_image_new_for_boxed (boxed_type, boxed, &slice, width, &repeat);
|
||||
else if (pattern != NULL)
|
||||
image = _gtk_border_image_new (pattern, &slice, width, &repeat);
|
||||
|
||||
@ -1312,8 +1314,8 @@ border_image_value_parse (GtkCssParser *parser,
|
||||
if (pattern != NULL)
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
if (gradient != NULL)
|
||||
gtk_gradient_unref (gradient);
|
||||
if (boxed != NULL)
|
||||
g_boxed_free (boxed_type, boxed);
|
||||
|
||||
if (width != NULL)
|
||||
gtk_border_free (width);
|
||||
|
Loading…
Reference in New Issue
Block a user