Commit da6beb99 authored by Benjamin Otte's avatar Benjamin Otte

css: Add ability to specify icontheme in CSS

-gtk-icontheme: "oxygen" works now.

This is a very crude implementation. It's meant for testing only.
parent e1d74f7c
......@@ -76,22 +76,14 @@ gtk_css_value_icon_theme_compute (GtkCssValue *icon_theme,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *result;
GtkIconTheme *icontheme;
icontheme = gtk_icon_theme_get_for_screen (_gtk_settings_get_screen (_gtk_style_provider_private_get_settings (provider)));
result = g_object_get_data (G_OBJECT (icontheme), "-gtk-css-value");
if (result)
return _gtk_css_value_ref (result);
result = _gtk_css_icon_theme_value_new ();
result->icontheme = g_object_ref (icontheme);
g_object_set_data (G_OBJECT (icontheme), "-gtk-css-value", result);
result->changed_id = g_signal_connect (icontheme, "changed", G_CALLBACK (gtk_css_value_icon_theme_changed_cb), result);
if (icon_theme->icontheme)
icontheme = icon_theme->icontheme;
else
icontheme = gtk_icon_theme_get_for_screen (_gtk_settings_get_screen (_gtk_style_provider_private_get_settings (provider)));
return result;
return gtk_css_icon_theme_value_new (icontheme);
}
static gboolean
......@@ -125,10 +117,49 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_THEME = {
gtk_css_value_icon_theme_print
};
static GtkCssValue default_icon_theme_value = { &GTK_CSS_VALUE_ICON_THEME, 1, NULL, 0 };
GtkCssValue *
_gtk_css_icon_theme_value_new (void)
gtk_css_icon_theme_value_new (GtkIconTheme *icontheme)
{
return _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_ICON_THEME);
GtkCssValue *result;
if (icontheme == NULL)
return _gtk_css_value_ref (&default_icon_theme_value);
result = g_object_get_data (G_OBJECT (icontheme), "-gtk-css-value");
if (result)
return _gtk_css_value_ref (result);
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_ICON_THEME);
result->icontheme = g_object_ref (icontheme);
g_object_set_data (G_OBJECT (icontheme), "-gtk-css-value", result);
result->changed_id = g_signal_connect (icontheme, "changed", G_CALLBACK (gtk_css_value_icon_theme_changed_cb), result);
return result;
}
GtkCssValue *
gtk_css_icon_theme_value_parse (GtkCssParser *parser)
{
GtkIconTheme *icontheme;
GtkCssValue *result;
char *s;
s = _gtk_css_parser_read_string (parser);
if (s == NULL)
return NULL;
icontheme = gtk_icon_theme_new ();
gtk_icon_theme_set_custom_theme (icontheme, s);
result = gtk_css_icon_theme_value_new (icontheme);
g_object_unref (icontheme);
g_free (s);
return result;
}
GtkIconTheme *
......
......@@ -27,9 +27,11 @@
G_BEGIN_DECLS
GtkCssValue * _gtk_css_icon_theme_value_new (void);
GtkCssValue * gtk_css_icon_theme_value_new (GtkIconTheme *icontheme);
GtkIconTheme * gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value);
GtkCssValue * gtk_css_icon_theme_value_parse (GtkCssParser *parser);
GtkIconTheme * gtk_css_icon_theme_value_get_icon_theme (GtkCssValue *value);
G_END_DECLS
......
......@@ -987,9 +987,7 @@ static GtkCssValue *
icon_theme_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
_gtk_css_parser_error (parser, "Only 'inherit', 'initial' or 'unset' are allowed");
return NULL;
return gtk_css_icon_theme_value_parse (parser);
}
/*** REGISTRATION ***/
......@@ -1028,9 +1026,6 @@ _gtk_css_style_property_init_properties (void)
query_length_as_double,
assign_length_from_double,
_gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
/* properties that aren't referenced when computing values
* start here */
gtk_css_style_property_register ("-gtk-icon-theme",
GTK_CSS_PROPERTY_ICON_THEME,
G_TYPE_NONE,
......@@ -1039,7 +1034,10 @@ _gtk_css_style_property_init_properties (void)
icon_theme_value_parse,
NULL,
NULL,
_gtk_css_icon_theme_value_new());
gtk_css_icon_theme_value_new (NULL));
/* properties that aren't referenced when computing values
* start here */
gtk_css_style_property_register ("background-color",
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GDK_TYPE_RGBA,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment