forked from AuroraMiddleware/gtk
cssvalue: Add GtkCssArea to the enum values
... and get rid of its GType. This makes it non-queryable using gtk_style_context_get() but it used to be a private struct anyway.
This commit is contained in:
parent
8e17f9c233
commit
4ba9be5b97
@ -256,3 +256,55 @@ _gtk_css_font_weight_value_get (const GtkCssValue *value)
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkCssArea */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue area_values[] = {
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_BORDER_BOX, "border-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_area_value_new (GtkCssArea area)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (area_values[i].value == area)
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_area_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, area_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkCssArea
|
||||
_gtk_css_area_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_AREA, GTK_CSS_AREA_BORDER_BOX);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "gtkenums.h"
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -42,6 +43,9 @@ GtkCssValue * _gtk_css_font_weight_value_new (PangoWeight weight
|
||||
GtkCssValue * _gtk_css_font_weight_value_try_parse (GtkCssParser *parser);
|
||||
PangoWeight _gtk_css_font_weight_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_area_value_new (GtkCssArea area);
|
||||
GtkCssValue * _gtk_css_area_value_try_parse (GtkCssParser *parser);
|
||||
GtkCssArea _gtk_css_area_value_get (const GtkCssValue *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -511,10 +511,13 @@ parse_background (GtkCssShorthandProperty *shorthand,
|
||||
values[1] = _gtk_css_value_new_from_enum (GTK_TYPE_CSS_BACKGROUND_REPEAT, enum_value);
|
||||
}
|
||||
else if ((values[2] == NULL || values[3] == NULL) &&
|
||||
_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_AREA, &enum_value))
|
||||
(values[3] = _gtk_css_area_value_try_parse (parser)))
|
||||
{
|
||||
guint idx = values[2] == NULL ? 2 : 3;
|
||||
values[idx] = _gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, enum_value);
|
||||
if (values[2] == NULL)
|
||||
{
|
||||
values[2] = values[3];
|
||||
values[3] = NULL;
|
||||
}
|
||||
}
|
||||
else if (values[4] == NULL)
|
||||
{
|
||||
|
@ -417,15 +417,12 @@ parse_css_area (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
int value;
|
||||
GtkCssValue *value = _gtk_css_area_value_try_parse (parser);
|
||||
|
||||
if (!_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_AREA, &value))
|
||||
{
|
||||
if (value == NULL)
|
||||
_gtk_css_parser_error (parser, "unknown value for property");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
@ -1543,25 +1540,25 @@ _gtk_css_style_property_init_properties (void)
|
||||
_gtk_css_value_new_from_int (0));
|
||||
|
||||
gtk_css_style_property_register ("background-clip",
|
||||
GTK_TYPE_CSS_AREA,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
parse_css_area,
|
||||
NULL,
|
||||
NULL,
|
||||
query_simple,
|
||||
assign_simple,
|
||||
NULL,
|
||||
_gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, GTK_CSS_AREA_BORDER_BOX));
|
||||
NULL,
|
||||
NULL,
|
||||
_gtk_css_area_value_new (GTK_CSS_AREA_BORDER_BOX));
|
||||
gtk_css_style_property_register ("background-origin",
|
||||
GTK_TYPE_CSS_AREA,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
parse_css_area,
|
||||
NULL,
|
||||
NULL,
|
||||
query_simple,
|
||||
assign_simple,
|
||||
NULL,
|
||||
_gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, GTK_CSS_AREA_PADDING_BOX));
|
||||
NULL,
|
||||
NULL,
|
||||
_gtk_css_area_value_new (GTK_CSS_AREA_PADDING_BOX));
|
||||
gtk_css_style_property_register ("background-size",
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
|
@ -81,7 +81,7 @@ typedef enum {
|
||||
GTK_CSS_REPEAT_STYLE_SPACE
|
||||
} GtkCssBorderRepeatStyle;
|
||||
|
||||
typedef enum {
|
||||
typedef enum /*< skip >*/ {
|
||||
GTK_CSS_AREA_BORDER_BOX,
|
||||
GTK_CSS_AREA_PADDING_BOX,
|
||||
GTK_CSS_AREA_CONTENT_BOX
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "gtkthemingbackgroundprivate.h"
|
||||
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcssimagevalueprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkthemingengineprivate.h"
|
||||
@ -54,9 +55,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
|
||||
GtkCssArea origin;
|
||||
cairo_rectangle_t image_rect;
|
||||
|
||||
gtk_style_context_get (bg->context, bg->flags,
|
||||
"background-origin", &origin,
|
||||
NULL);
|
||||
origin = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
|
||||
|
||||
/* The default size of the background image depends on the
|
||||
background-origin value as this affects the top left
|
||||
@ -91,11 +90,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
|
||||
static void
|
||||
_gtk_theming_background_apply_clip (GtkThemingBackground *bg)
|
||||
{
|
||||
GtkCssArea clip;
|
||||
|
||||
gtk_style_context_get (bg->context, bg->flags,
|
||||
"background-clip", &clip,
|
||||
NULL);
|
||||
GtkCssArea clip = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
|
||||
|
||||
if (clip == GTK_CSS_AREA_PADDING_BOX)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user