summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-05-06 16:06:33 +0200
committerBenjamin Otte <otte@redhat.com>2014-05-14 04:28:34 +0200
commit109fcb987bdf3be00220a064f9ead23fb5a568a8 (patch)
treeb942a5aca7ee7dbbd574d88fe9b5fe428116b1a8
parent55f473f4e6cc6fa35f36e7ab9c4586ea1873df88 (diff)
downloadgtk+-109fcb987bdf3be00220a064f9ead23fb5a568a8.tar.gz
css: Add a -gtk-icon-style property
The values can be: "requested" - the style as requested "regular" - use a regular full-color icon "symbolic" - use a symbolic icon The property defaults to "requested", so no changes should be seen unless CSS overrides it. It is also inherited, so that using this CSS .toolbar { -gtk-icon-style: symbolic; } is enough to force the whole toolbar to use symbolic icons.
-rw-r--r--gtk/gtkcssenumvalue.c54
-rw-r--r--gtk/gtkcssenumvalueprivate.h4
-rw-r--r--gtk/gtkcssstylepropertyimpl.c20
-rw-r--r--gtk/gtkcsstypesprivate.h7
4 files changed, 85 insertions, 0 deletions
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 8151d58de2..a8c807b155 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -706,3 +706,57 @@ _gtk_css_image_effect_value_get (const GtkCssValue *value)
return value->value;
}
+
+/* GtkCssIconStyle */
+
+static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {
+ gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
+ gtk_css_value_enum_equal,
+ gtk_css_value_enum_transition,
+ gtk_css_value_enum_print
+};
+
+static GtkCssValue icon_style_values[] = {
+ { &GTK_CSS_VALUE_ICON_STYLE, 1, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
+ { &GTK_CSS_VALUE_ICON_STYLE, 1, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
+ { &GTK_CSS_VALUE_ICON_STYLE, 1, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
+};
+
+GtkCssValue *
+_gtk_css_icon_style_value_new (GtkCssIconStyle icon_style)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
+ {
+ if (icon_style_values[i].value == icon_style)
+ return _gtk_css_value_ref (&icon_style_values[i]);
+ }
+
+ g_return_val_if_reached (NULL);
+}
+
+GtkCssValue *
+_gtk_css_icon_style_value_try_parse (GtkCssParser *parser)
+{
+ guint i;
+
+ g_return_val_if_fail (parser != NULL, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
+ {
+ if (_gtk_css_parser_try (parser, icon_style_values[i].name, TRUE))
+ return _gtk_css_value_ref (&icon_style_values[i]);
+ }
+
+ return NULL;
+}
+
+GtkCssIconStyle
+_gtk_css_icon_style_value_get (const GtkCssValue *value)
+{
+ g_return_val_if_fail (value->class == &GTK_CSS_VALUE_ICON_STYLE, GTK_CSS_ICON_STYLE_REQUESTED);
+
+ return value->value;
+}
diff --git a/gtk/gtkcssenumvalueprivate.h b/gtk/gtkcssenumvalueprivate.h
index c21df476b7..d0a5d3fd20 100644
--- a/gtk/gtkcssenumvalueprivate.h
+++ b/gtk/gtkcssenumvalueprivate.h
@@ -68,6 +68,10 @@ GtkCssValue * _gtk_css_image_effect_value_new (GtkCssImageEffect imag
GtkCssValue * _gtk_css_image_effect_value_try_parse (GtkCssParser *parser);
GtkCssImageEffect _gtk_css_image_effect_value_get (const GtkCssValue *value);
+GtkCssValue * _gtk_css_icon_style_value_new (GtkCssIconStyle icon_style);
+GtkCssValue * _gtk_css_icon_style_value_try_parse (GtkCssParser *parser);
+GtkCssIconStyle _gtk_css_icon_style_value_get (const GtkCssValue *value);
+
G_END_DECLS
#endif /* __GTK_CSS_ENUM_VALUE_PRIVATE_H__ */
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 0195e44944..c6dc8644c1 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -478,6 +478,18 @@ image_effect_parse (GtkCssStyleProperty *property,
}
static GtkCssValue *
+icon_style_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser)
+{
+ GtkCssValue *value = _gtk_css_icon_style_value_try_parse (parser);
+
+ if (value == NULL)
+ _gtk_css_parser_error (parser, "unknown value for property");
+
+ return value;
+}
+
+static GtkCssValue *
bindings_value_parse_one (GtkCssParser *parser)
{
char *name;
@@ -981,6 +993,14 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
_gtk_css_shadows_value_new_none ());
+ gtk_css_style_property_register ("-gtk-icon-style",
+ GTK_CSS_PROPERTY_ICON_STYLE,
+ G_TYPE_NONE,
+ GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_NO_RESIZE,
+ icon_style_parse,
+ NULL,
+ NULL,
+ _gtk_css_icon_style_value_new (GTK_CSS_ICON_STYLE_REQUESTED));
gtk_css_style_property_register ("-gtk-icon-transform",
GTK_CSS_PROPERTY_ICON_TRANSFORM,
G_TYPE_NONE,
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 7a4de907d6..88e52425c6 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -82,6 +82,7 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_ICON_SOURCE,
GTK_CSS_PROPERTY_ICON_SHADOW,
+ GTK_CSS_PROPERTY_ICON_STYLE,
GTK_CSS_PROPERTY_ICON_TRANSFORM,
GTK_CSS_PROPERTY_BOX_SHADOW,
GTK_CSS_PROPERTY_MARGIN_TOP,
@@ -178,6 +179,12 @@ typedef enum /*< skip >*/ {
} GtkCssImageEffect;
typedef enum /*< skip >*/ {
+ GTK_CSS_ICON_STYLE_REQUESTED,
+ GTK_CSS_ICON_STYLE_REGULAR,
+ GTK_CSS_ICON_STYLE_SYMBOLIC
+} GtkCssIconStyle;
+
+typedef enum /*< skip >*/ {
/* relative font sizes */
GTK_CSS_FONT_SIZE_SMALLER,
GTK_CSS_FONT_SIZE_LARGER,