st/icon: Add :is-symbolic property
It can be useful to know whether an icon displays a symbolic (rather than just requesting it). Add a new :is-symbolic property for that purpose, backed by private API on StImageContent that allows the texture cache to shuffle that information through to the icon. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3296>
This commit is contained in:
parent
fe24de3ef2
commit
56cc755bf6
@ -31,6 +31,7 @@
|
||||
#include "st-texture-cache.h"
|
||||
#include "st-theme-context.h"
|
||||
#include "st-private.h"
|
||||
#include "st-image-content-private.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -43,6 +44,8 @@ enum
|
||||
PROP_ICON_SIZE,
|
||||
PROP_FALLBACK_ICON_NAME,
|
||||
|
||||
PROP_IS_SYMBOLIC,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -62,6 +65,7 @@ struct _StIconPrivate
|
||||
GIcon *fallback_gicon;
|
||||
gboolean needs_update;
|
||||
gboolean is_themed;
|
||||
gboolean is_symbolic;
|
||||
|
||||
StIconColors *colors;
|
||||
|
||||
@ -155,6 +159,10 @@ st_icon_get_property (GObject *gobject,
|
||||
g_value_set_string (value, st_icon_get_fallback_icon_name (icon));
|
||||
break;
|
||||
|
||||
case PROP_IS_SYMBOLIC:
|
||||
g_value_set_boolean (value, st_icon_get_is_symbolic (icon));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -359,6 +367,18 @@ st_icon_class_init (StIconClass *klass)
|
||||
NULL,
|
||||
ST_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* StIcon:symbolic:
|
||||
*
|
||||
* Whether the #StIcon is symbolic.
|
||||
*/
|
||||
props[PROP_IS_SYMBOLIC] =
|
||||
g_param_spec_boolean ("is-symbolic",
|
||||
"Is Symbolic",
|
||||
"Whether the icon is symbolic",
|
||||
FALSE,
|
||||
ST_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||
}
|
||||
|
||||
@ -428,12 +448,33 @@ st_icon_update_shadow_pipeline (StIcon *icon)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_icon_update_is_symbolic (StIcon *icon)
|
||||
{
|
||||
StIconPrivate *priv = icon->priv;
|
||||
gboolean is_symbolic = FALSE;
|
||||
ClutterContent *content = NULL;
|
||||
|
||||
if (priv->icon_texture)
|
||||
content = clutter_actor_get_content (priv->icon_texture);
|
||||
|
||||
if (ST_IS_IMAGE_CONTENT (content))
|
||||
is_symbolic = st_image_content_get_is_symbolic (ST_IMAGE_CONTENT (content));
|
||||
|
||||
if (priv->is_symbolic != is_symbolic)
|
||||
{
|
||||
priv->is_symbolic = is_symbolic;
|
||||
g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_IS_SYMBOLIC]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_content_changed (ClutterActor *actor,
|
||||
GParamSpec *pspec,
|
||||
StIcon *icon)
|
||||
{
|
||||
st_icon_clear_shadow_pipeline (icon);
|
||||
st_icon_update_is_symbolic (icon);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -459,6 +500,7 @@ st_icon_finish_update (StIcon *icon)
|
||||
g_object_unref (priv->icon_texture);
|
||||
|
||||
st_icon_clear_shadow_pipeline (icon);
|
||||
st_icon_update_is_symbolic (icon);
|
||||
|
||||
g_signal_connect_object (priv->icon_texture, "notify::content",
|
||||
G_CALLBACK (on_content_changed), icon, 0);
|
||||
@ -879,3 +921,17 @@ st_icon_set_fallback_icon_name (StIcon *icon,
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (icon));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_get_is_symbolic:
|
||||
* @icon: an #StIcon
|
||||
*
|
||||
* Returns: Whether the displayed icon is symbolic
|
||||
*/
|
||||
gboolean
|
||||
st_icon_get_is_symbolic (StIcon *icon)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_ICON (icon), FALSE);
|
||||
|
||||
return icon->priv->is_symbolic;
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ gint st_icon_get_icon_size (StIcon *icon);
|
||||
void st_icon_set_icon_size (StIcon *icon,
|
||||
gint size);
|
||||
|
||||
gboolean st_icon_get_is_symbolic (StIcon *icon);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _ST_ICON */
|
||||
|
30
src/st/st-image-content-private.h
Normal file
30
src/st/st-image-content-private.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* st-image-content-private.h: Private StImageContent methods
|
||||
*
|
||||
* Copyright 2024 Red Hat, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU Lesser General Public License,
|
||||
* version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "st-image-content.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void st_image_content_set_is_symbolic (StImageContent *content,
|
||||
gboolean is_symbolic);
|
||||
|
||||
gboolean st_image_content_get_is_symbolic (StImageContent *content);
|
||||
|
||||
G_END_DECLS
|
@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "st-image-content.h"
|
||||
#include "st-image-content-private.h"
|
||||
#include "st-private.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
@ -34,6 +34,7 @@ struct _StImageContentPrivate
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
gboolean is_symbolic;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -346,3 +347,26 @@ st_image_content_new_with_preferred_size (int width,
|
||||
"preferred-height", height,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
st_image_content_set_is_symbolic (StImageContent *content,
|
||||
gboolean is_symbolic)
|
||||
{
|
||||
StImageContentPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_IMAGE_CONTENT (content));
|
||||
|
||||
priv = st_image_content_get_instance_private (content);
|
||||
priv->is_symbolic = is_symbolic;
|
||||
}
|
||||
|
||||
gboolean
|
||||
st_image_content_get_is_symbolic (StImageContent *content)
|
||||
{
|
||||
StImageContentPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (ST_IS_IMAGE_CONTENT (content), FALSE);
|
||||
|
||||
priv = st_image_content_get_instance_private (content);
|
||||
return priv->is_symbolic;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "st-image-content.h"
|
||||
#include "st-image-content-private.h"
|
||||
#include "st-texture-cache.h"
|
||||
#include "st-private.h"
|
||||
#include "st-settings.h"
|
||||
@ -724,6 +724,10 @@ finish_texture_load (AsyncTextureLoadData *data,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (data->icon_info)
|
||||
st_image_content_set_is_symbolic (ST_IMAGE_CONTENT (image),
|
||||
st_icon_info_is_symbolic (data->icon_info));
|
||||
|
||||
for (iter = data->actors; iter; iter = iter->next)
|
||||
{
|
||||
ClutterActor *actor = iter->data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user