[gtk+/wip/css-icons: 9/13] css: Add a -gtk-icon-style property
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css-icons: 9/13] css: Add a -gtk-icon-style property
- Date: Sun, 11 May 2014 00:35:36 +0000 (UTC)
commit 0452f303abd8a208ae5914eeb22d0bc908ccf695
Author: Benjamin Otte <otte redhat com>
Date: Tue May 6 16:06:33 2014 +0200
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.
gtk/gtkcssenumvalue.c | 54 +++++++++++++++++++++++++++++++++++++++++
gtk/gtkcssenumvalueprivate.h | 4 +++
gtk/gtkcssstylepropertyimpl.c | 20 +++++++++++++++
gtk/gtkcsstypesprivate.h | 7 +++++
4 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 8151d58..a8c807b 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[] = {
+ { >K_CSS_VALUE_ICON_STYLE, 1, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
+ { >K_CSS_VALUE_ICON_STYLE, 1, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
+ { >K_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 == >K_CSS_VALUE_ICON_STYLE, GTK_CSS_ICON_STYLE_REQUESTED);
+
+ return value->value;
+}
diff --git a/gtk/gtkcssenumvalueprivate.h b/gtk/gtkcssenumvalueprivate.h
index c21df47..d0a5d3f 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 0195e44..c6dc864 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 7a4de90..88e5242 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]