st-theme-node: Add support for -st-icon-style property
GTK+ added support for a -gtk-icon-style property in themes to enforce a particular icon style. Do the same for shell themes with an -st-icon-style property, with the same set of possible values as the GTK+ variant: 'requested' - use symbolic or fullcolor icon depending on the icon name (default) 'regular' - enforce fullcolor icons 'symbolic' - enforce symbolic icons https://bugzilla.gnome.org/show_bug.cgi?id=740447
This commit is contained in:
parent
deddac8748
commit
2940ef07e9
@ -842,16 +842,25 @@ st_texture_cache_load_gicon (StTextureCache *cache,
|
|||||||
GtkIconInfo *info;
|
GtkIconInfo *info;
|
||||||
StTextureCachePolicy policy;
|
StTextureCachePolicy policy;
|
||||||
StIconColors *colors = NULL;
|
StIconColors *colors = NULL;
|
||||||
|
StIconStyle icon_style = ST_ICON_STYLE_REQUESTED;
|
||||||
GtkIconLookupFlags lookup_flags;
|
GtkIconLookupFlags lookup_flags;
|
||||||
|
|
||||||
if (theme_node)
|
if (theme_node)
|
||||||
|
{
|
||||||
colors = st_theme_node_get_icon_colors (theme_node);
|
colors = st_theme_node_get_icon_colors (theme_node);
|
||||||
|
icon_style = st_theme_node_get_icon_style (theme_node);
|
||||||
|
}
|
||||||
|
|
||||||
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
/* Do theme lookups in the main thread to avoid thread-unsafety */
|
||||||
theme = cache->priv->icon_theme;
|
theme = cache->priv->icon_theme;
|
||||||
|
|
||||||
lookup_flags = GTK_ICON_LOOKUP_USE_BUILTIN;
|
lookup_flags = GTK_ICON_LOOKUP_USE_BUILTIN;
|
||||||
|
|
||||||
|
if (icon_style == ST_ICON_STYLE_REGULAR)
|
||||||
|
lookup_flags |= GTK_ICON_LOOKUP_FORCE_REGULAR;
|
||||||
|
else if (icon_style == ST_ICON_STYLE_SYMBOLIC)
|
||||||
|
lookup_flags |= GTK_ICON_LOOKUP_FORCE_SYMBOLIC;
|
||||||
|
|
||||||
if (clutter_get_default_text_direction () == CLUTTER_TEXT_DIRECTION_RTL)
|
if (clutter_get_default_text_direction () == CLUTTER_TEXT_DIRECTION_RTL)
|
||||||
lookup_flags |= GTK_ICON_LOOKUP_DIR_RTL;
|
lookup_flags |= GTK_ICON_LOOKUP_DIR_RTL;
|
||||||
else
|
else
|
||||||
@ -871,8 +880,8 @@ st_texture_cache_load_gicon (StTextureCache *cache,
|
|||||||
if (colors)
|
if (colors)
|
||||||
{
|
{
|
||||||
/* This raises some doubts about the practice of using string keys */
|
/* This raises some doubts about the practice of using string keys */
|
||||||
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
|
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,style=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
|
||||||
gicon_string, size, scale,
|
gicon_string, size, scale, icon_style,
|
||||||
colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
|
colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
|
||||||
colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
|
colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
|
||||||
colors->error.red, colors->error.blue, colors->error.green, colors->error.alpha,
|
colors->error.red, colors->error.blue, colors->error.green, colors->error.alpha,
|
||||||
@ -880,8 +889,8 @@ st_texture_cache_load_gicon (StTextureCache *cache,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d",
|
key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,style=%d",
|
||||||
gicon_string, size, scale);
|
gicon_string, size, scale, icon_style);
|
||||||
}
|
}
|
||||||
g_free (gicon_string);
|
g_free (gicon_string);
|
||||||
|
|
||||||
|
@ -2392,6 +2392,48 @@ st_theme_node_get_transition_duration (StThemeNode *node)
|
|||||||
return st_slow_down_factor * node->transition_duration;
|
return st_slow_down_factor * node->transition_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StIconStyle
|
||||||
|
st_theme_node_get_icon_style (StThemeNode *node)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ensure_properties (node);
|
||||||
|
|
||||||
|
for (i = node->n_properties - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
CRDeclaration *decl = node->properties[i];
|
||||||
|
|
||||||
|
if (strcmp (decl->property->stryng->str, "-st-icon-style") == 0)
|
||||||
|
{
|
||||||
|
CRTerm *term;
|
||||||
|
|
||||||
|
for (term = decl->value; term; term = term->next)
|
||||||
|
{
|
||||||
|
if (term->type != TERM_IDENT)
|
||||||
|
goto next_decl;
|
||||||
|
|
||||||
|
if (strcmp (term->content.str->stryng->str, "requested") == 0)
|
||||||
|
return ST_ICON_STYLE_REQUESTED;
|
||||||
|
else if (strcmp (term->content.str->stryng->str, "regular") == 0)
|
||||||
|
return ST_ICON_STYLE_REGULAR;
|
||||||
|
else if (strcmp (term->content.str->stryng->str, "symbolic") == 0)
|
||||||
|
return ST_ICON_STYLE_SYMBOLIC;
|
||||||
|
else
|
||||||
|
g_warning ("Unknown -st-icon-style \"%s\"",
|
||||||
|
term->content.str->stryng->str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next_decl:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->parent_node)
|
||||||
|
return st_theme_node_get_icon_style (node->parent_node);
|
||||||
|
|
||||||
|
return ST_ICON_STYLE_REQUESTED;
|
||||||
|
}
|
||||||
|
|
||||||
StTextDecoration
|
StTextDecoration
|
||||||
st_theme_node_get_text_decoration (StThemeNode *node)
|
st_theme_node_get_text_decoration (StThemeNode *node)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +94,12 @@ typedef enum {
|
|||||||
ST_GRADIENT_RADIAL
|
ST_GRADIENT_RADIAL
|
||||||
} StGradientType;
|
} StGradientType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ST_ICON_STYLE_REQUESTED,
|
||||||
|
ST_ICON_STYLE_REGULAR,
|
||||||
|
ST_ICON_STYLE_SYMBOLIC
|
||||||
|
} StIconStyle;
|
||||||
|
|
||||||
typedef struct _StThemeNodePaintState StThemeNodePaintState;
|
typedef struct _StThemeNodePaintState StThemeNodePaintState;
|
||||||
|
|
||||||
struct _StThemeNodePaintState {
|
struct _StThemeNodePaintState {
|
||||||
@ -220,6 +226,8 @@ int st_theme_node_get_max_height (StThemeNode *node);
|
|||||||
|
|
||||||
int st_theme_node_get_transition_duration (StThemeNode *node);
|
int st_theme_node_get_transition_duration (StThemeNode *node);
|
||||||
|
|
||||||
|
StIconStyle st_theme_node_get_icon_style (StThemeNode *node);
|
||||||
|
|
||||||
StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
|
StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
|
||||||
|
|
||||||
StTextAlign st_theme_node_get_text_align (StThemeNode *node);
|
StTextAlign st_theme_node_get_text_align (StThemeNode *node);
|
||||||
|
Loading…
Reference in New Issue
Block a user