st-icon: Add resource-scale support
This commit adds support for scaling the StIcon resource (the icon texture) according to the resource scale. https://bugzilla.gnome.org/show_bug.cgi?id=765011
This commit is contained in:
parent
aaf69b2898
commit
40e7638a4b
@ -210,6 +210,12 @@ st_icon_style_changed (StWidget *widget)
|
|||||||
st_icon_update (self);
|
st_icon_update (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
st_icon_resource_scale_changed (StWidget *widget)
|
||||||
|
{
|
||||||
|
st_icon_update (ST_ICON (widget));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_icon_class_init (StIconClass *klass)
|
st_icon_class_init (StIconClass *klass)
|
||||||
{
|
{
|
||||||
@ -226,6 +232,7 @@ st_icon_class_init (StIconClass *klass)
|
|||||||
actor_class->paint = st_icon_paint;
|
actor_class->paint = st_icon_paint;
|
||||||
|
|
||||||
widget_class->style_changed = st_icon_style_changed;
|
widget_class->style_changed = st_icon_style_changed;
|
||||||
|
widget_class->resource_scale_changed = st_icon_resource_scale_changed;
|
||||||
|
|
||||||
pspec = g_param_spec_object ("gicon",
|
pspec = g_param_spec_object ("gicon",
|
||||||
"GIcon",
|
"GIcon",
|
||||||
@ -344,6 +351,8 @@ st_icon_finish_update (StIcon *icon)
|
|||||||
g_signal_connect_object (priv->icon_texture, "notify::content",
|
g_signal_connect_object (priv->icon_texture, "notify::content",
|
||||||
G_CALLBACK (on_content_changed), icon, 0);
|
G_CALLBACK (on_content_changed), icon, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -366,9 +375,10 @@ st_icon_update (StIcon *icon)
|
|||||||
StIconPrivate *priv = icon->priv;
|
StIconPrivate *priv = icon->priv;
|
||||||
StThemeNode *theme_node;
|
StThemeNode *theme_node;
|
||||||
StTextureCache *cache;
|
StTextureCache *cache;
|
||||||
gint scale;
|
gint paint_scale;
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
StThemeContext *context;
|
StThemeContext *context;
|
||||||
|
float resource_scale;
|
||||||
|
|
||||||
if (priv->pending_texture)
|
if (priv->pending_texture)
|
||||||
{
|
{
|
||||||
@ -378,13 +388,16 @@ st_icon_update (StIcon *icon)
|
|||||||
priv->opacity_handler_id = 0;
|
priv->opacity_handler_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!st_widget_get_resource_scale (ST_WIDGET (icon), &resource_scale))
|
||||||
|
return;
|
||||||
|
|
||||||
theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
|
theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
|
||||||
if (theme_node == NULL)
|
if (theme_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
|
stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
|
||||||
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
|
||||||
g_object_get (context, "scale-factor", &scale, NULL);
|
g_object_get (context, "scale-factor", &paint_scale, NULL);
|
||||||
|
|
||||||
cache = st_texture_cache_get_default ();
|
cache = st_texture_cache_get_default ();
|
||||||
|
|
||||||
@ -393,16 +406,16 @@ st_icon_update (StIcon *icon)
|
|||||||
theme_node,
|
theme_node,
|
||||||
priv->gicon,
|
priv->gicon,
|
||||||
priv->icon_size,
|
priv->icon_size,
|
||||||
scale,
|
paint_scale,
|
||||||
1);
|
resource_scale);
|
||||||
|
|
||||||
if (priv->pending_texture == NULL && priv->fallback_gicon != NULL)
|
if (priv->pending_texture == NULL && priv->fallback_gicon != NULL)
|
||||||
priv->pending_texture = st_texture_cache_load_gicon (cache,
|
priv->pending_texture = st_texture_cache_load_gicon (cache,
|
||||||
theme_node,
|
theme_node,
|
||||||
priv->fallback_gicon,
|
priv->fallback_gicon,
|
||||||
priv->icon_size,
|
priv->icon_size,
|
||||||
scale,
|
paint_scale,
|
||||||
1);
|
resource_scale);
|
||||||
|
|
||||||
if (priv->pending_texture)
|
if (priv->pending_texture)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user