st: Remove StIconType
GTK+ works by explicitly specifying a -symbolic suffix for all icons. Do the same here. https://bugzilla.gnome.org/show_bug.cgi?id=682540
This commit is contained in:
@ -59,8 +59,7 @@ function init() {
|
||||
x_fill: true,
|
||||
y_fill: false,
|
||||
track_hover: true });
|
||||
let icon = new St.Icon({ icon_name: 'system-run',
|
||||
icon_type: St.IconType.SYMBOLIC,
|
||||
let icon = new St.Icon({ icon_name: 'system-run-symbolic',
|
||||
style_class: 'system-status-icon' });
|
||||
|
||||
button.set_child(icon);
|
||||
|
@ -172,8 +172,7 @@ show_capslock_feedback (StEntry *entry)
|
||||
{
|
||||
ClutterActor *icon = g_object_new (ST_TYPE_ICON,
|
||||
"style-class", "capslock-warning",
|
||||
"icon-type", ST_ICON_SYMBOLIC,
|
||||
"icon-name", "dialog-warning",
|
||||
"icon-name", "dialog-warning-symbolic",
|
||||
NULL);
|
||||
|
||||
st_entry_set_secondary_icon (entry, icon);
|
||||
|
@ -37,7 +37,6 @@ enum
|
||||
|
||||
PROP_GICON,
|
||||
PROP_ICON_NAME,
|
||||
PROP_ICON_TYPE,
|
||||
PROP_ICON_SIZE
|
||||
};
|
||||
|
||||
@ -53,7 +52,6 @@ struct _StIconPrivate
|
||||
guint opacity_handler_id;
|
||||
|
||||
GIcon *gicon;
|
||||
StIconType icon_type;
|
||||
gint prop_icon_size; /* icon size set as property */
|
||||
gint theme_icon_size; /* icon size from theme node */
|
||||
gint icon_size; /* icon size we are using */
|
||||
@ -68,7 +66,6 @@ static void st_icon_update (StIcon *icon);
|
||||
static gboolean st_icon_update_icon_size (StIcon *icon);
|
||||
|
||||
#define DEFAULT_ICON_SIZE 48
|
||||
#define DEFAULT_ICON_TYPE ST_ICON_SYMBOLIC
|
||||
|
||||
static void
|
||||
st_icon_set_property (GObject *gobject,
|
||||
@ -88,10 +85,6 @@ st_icon_set_property (GObject *gobject,
|
||||
st_icon_set_icon_name (icon, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON_TYPE:
|
||||
st_icon_set_icon_type (icon, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON_SIZE:
|
||||
st_icon_set_icon_size (icon, g_value_get_int (value));
|
||||
break;
|
||||
@ -120,10 +113,6 @@ st_icon_get_property (GObject *gobject,
|
||||
g_value_set_string (value, st_icon_get_icon_name (icon));
|
||||
break;
|
||||
|
||||
case PROP_ICON_TYPE:
|
||||
g_value_set_enum (value, st_icon_get_icon_type (icon));
|
||||
break;
|
||||
|
||||
case PROP_ICON_SIZE:
|
||||
g_value_set_int (value, st_icon_get_icon_size (icon));
|
||||
break;
|
||||
@ -343,14 +332,6 @@ st_icon_class_init (StIconClass *klass)
|
||||
NULL, ST_PARAM_READWRITE | G_PARAM_DEPRECATED);
|
||||
g_object_class_install_property (object_class, PROP_ICON_NAME, pspec);
|
||||
|
||||
pspec = g_param_spec_enum ("icon-type",
|
||||
"Icon type",
|
||||
"The type of icon that should be used",
|
||||
ST_TYPE_ICON_TYPE,
|
||||
DEFAULT_ICON_TYPE,
|
||||
ST_PARAM_READWRITE | G_PARAM_DEPRECATED);
|
||||
g_object_class_install_property (object_class, PROP_ICON_TYPE, pspec);
|
||||
|
||||
pspec = g_param_spec_int ("icon-size",
|
||||
"Icon size",
|
||||
"The size if the icon, if positive. Otherwise the size will be derived from the current style",
|
||||
@ -366,7 +347,6 @@ st_icon_init (StIcon *self)
|
||||
|
||||
self->priv->icon_size = DEFAULT_ICON_SIZE;
|
||||
self->priv->prop_icon_size = -1;
|
||||
self->priv->icon_type = DEFAULT_ICON_TYPE;
|
||||
|
||||
self->priv->shadow_material = COGL_INVALID_HANDLE;
|
||||
self->priv->shadow_width = -1;
|
||||
@ -564,12 +544,7 @@ st_icon_set_icon_name (StIcon *icon,
|
||||
g_object_unref (priv->gicon);
|
||||
|
||||
if (icon_name)
|
||||
{
|
||||
if (priv->icon_type == ST_ICON_SYMBOLIC)
|
||||
priv->gicon = _st_make_symbolic_themed_icon (icon_name);
|
||||
else
|
||||
priv->gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
|
||||
}
|
||||
priv->gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
|
||||
else
|
||||
priv->gicon = NULL;
|
||||
|
||||
@ -579,52 +554,6 @@ st_icon_set_icon_name (StIcon *icon,
|
||||
st_icon_update (icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_get_icon_type:
|
||||
* @icon: a #StIcon
|
||||
*
|
||||
* Gets the type of icon we'll look up to display in the actor.
|
||||
* See st_icon_set_icon_type().
|
||||
*
|
||||
* Return value: the icon type.
|
||||
*/
|
||||
StIconType
|
||||
st_icon_get_icon_type (StIcon *icon)
|
||||
{
|
||||
g_return_val_if_fail (ST_IS_ICON (icon), DEFAULT_ICON_TYPE);
|
||||
|
||||
return icon->priv->icon_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_set_icon_type:
|
||||
* @icon: a #StIcon
|
||||
* @icon_type: the type of icon to use
|
||||
*
|
||||
* Sets the type of icon we'll look up to display in the actor.
|
||||
* The icon type determines whether we use a symbolic icon or
|
||||
* a full color icon and also is used for specific handling for
|
||||
* application and document icons.
|
||||
*/
|
||||
void
|
||||
st_icon_set_icon_type (StIcon *icon,
|
||||
StIconType icon_type)
|
||||
{
|
||||
StIconPrivate *priv;
|
||||
|
||||
g_return_if_fail (ST_IS_ICON (icon));
|
||||
|
||||
priv = icon->priv;
|
||||
|
||||
if (icon_type == priv->icon_type)
|
||||
return;
|
||||
|
||||
priv->icon_type = icon_type;
|
||||
st_icon_update (icon);
|
||||
|
||||
g_object_notify (G_OBJECT (icon), "icon-type");
|
||||
}
|
||||
|
||||
/**
|
||||
* st_icon_get_gicon:
|
||||
* @icon: an icon
|
||||
|
@ -88,9 +88,6 @@ ClutterActor* st_icon_new (void);
|
||||
const gchar *st_icon_get_icon_name (StIcon *icon);
|
||||
void st_icon_set_icon_name (StIcon *icon, const gchar *icon_name);
|
||||
|
||||
void st_icon_set_icon_type (StIcon *icon, StIconType icon_type);
|
||||
StIconType st_icon_get_icon_type (StIcon *icon);
|
||||
|
||||
gint st_icon_get_icon_size (StIcon *icon);
|
||||
void st_icon_set_icon_size (StIcon *icon, gint size);
|
||||
|
||||
|
@ -691,55 +691,3 @@ _st_paint_shadow_with_opacity (StShadow *shadow_spec,
|
||||
shadow_box.x2, shadow_box.y2,
|
||||
0, 0, 1, 1);
|
||||
}
|
||||
|
||||
/* generates names like g_themed_icon_new_with_default_fallbacks(),
|
||||
* but *only* symbolic names
|
||||
*/
|
||||
static char **
|
||||
symbolic_names_for_icon (const char *name)
|
||||
{
|
||||
char **parts, **names;
|
||||
int i, numnames;
|
||||
|
||||
parts = g_strsplit (name, "-", -1);
|
||||
numnames = g_strv_length (parts);
|
||||
names = g_new (char *, numnames + 1);
|
||||
for (i = 0; parts[i]; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
names[i] = g_strdup_printf ("%s-symbolic", parts[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
names[i] = g_strdup_printf ("%.*s-%s-symbolic",
|
||||
(int) (strlen (names[i - 1]) - strlen ("-symbolic")),
|
||||
names[i - 1], parts[i]);
|
||||
}
|
||||
}
|
||||
names[i] = NULL;
|
||||
|
||||
g_strfreev (parts);
|
||||
|
||||
/* need to reverse here, because longest (most specific)
|
||||
name has to come first */
|
||||
for (i = 0; i < (numnames / 2); i++) {
|
||||
char *tmp = names[i];
|
||||
names[i] = names[numnames - i - 1];
|
||||
names[numnames - i - 1] = tmp;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
GIcon *
|
||||
_st_make_symbolic_themed_icon (const char *icon_name)
|
||||
{
|
||||
char **names;
|
||||
GIcon *themed;
|
||||
|
||||
names = symbolic_names_for_icon (icon_name);
|
||||
themed = g_themed_icon_new_from_names (names, -1);
|
||||
g_strfreev (names);
|
||||
|
||||
return themed;
|
||||
}
|
||||
|
@ -79,6 +79,4 @@ void _st_paint_shadow_with_opacity (StShadow *shadow_spec,
|
||||
ClutterActorBox *box,
|
||||
guint8 paint_opacity);
|
||||
|
||||
GIcon *_st_make_symbolic_themed_icon (const char *icon_name);
|
||||
|
||||
#endif /* __ST_PRIVATE_H__ */
|
||||
|
@ -1121,29 +1121,15 @@ st_texture_cache_load_sliced_image (StTextureCache *cache,
|
||||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* StIconType:
|
||||
* @ST_ICON_SYMBOLIC: a symbolic (ie, mostly monochrome) icon
|
||||
* @ST_ICON_FULLCOLOR: a full-color icon
|
||||
*
|
||||
* Describes what style of icon is desired in a call to
|
||||
* st_texture_cache_load_icon_name() or st_texture_cache_load_gicon().
|
||||
* Use %ST_ICON_SYMBOLIC for symbolic icons (eg, for the panel and
|
||||
* much of the rest of the shell chrome) or %ST_ICON_FULLCOLOR for a
|
||||
* full-color icon.
|
||||
*/
|
||||
|
||||
/**
|
||||
* st_texture_cache_load_icon_name:
|
||||
* @cache: The texture cache instance
|
||||
* @theme_node: (allow-none): a #StThemeNode
|
||||
* @name: Name of a themed icon
|
||||
* @icon_type: the type of icon to load
|
||||
* @size: Size of themed icon
|
||||
*
|
||||
* Load a themed icon into a texture. See the #StIconType documentation
|
||||
* for an explanation of how @icon_type affects the returned icon. The
|
||||
* colors used for symbolic icons are derived from @theme_node.
|
||||
* Load a themed icon into a texture. The colors used for symbolic
|
||||
* icons are derived from @theme_node.
|
||||
*
|
||||
* Return Value: (transfer none): A new #ClutterTexture for the icon
|
||||
*/
|
||||
@ -1151,47 +1137,23 @@ ClutterActor *
|
||||
st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
StThemeNode *theme_node,
|
||||
const char *name,
|
||||
StIconType icon_type,
|
||||
gint size)
|
||||
{
|
||||
ClutterActor *texture;
|
||||
GIcon *themed;
|
||||
|
||||
g_return_val_if_fail (!(icon_type == ST_ICON_SYMBOLIC && theme_node == NULL), NULL);
|
||||
themed = g_themed_icon_new_with_default_fallbacks (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size,
|
||||
theme_node ? st_theme_node_get_icon_colors (theme_node) : NULL);
|
||||
g_object_unref (themed);
|
||||
|
||||
switch (icon_type)
|
||||
if (texture == NULL)
|
||||
{
|
||||
case ST_ICON_SYMBOLIC:
|
||||
themed = _st_make_symbolic_themed_icon (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size,
|
||||
st_theme_node_get_icon_colors (theme_node));
|
||||
g_object_unref (themed);
|
||||
if (texture == NULL)
|
||||
{
|
||||
/* We don't have an equivalent of image-missing
|
||||
* for the symbolic icon theme, so just create a blank
|
||||
* actor. */
|
||||
texture = (ClutterActor *) create_default_texture ();
|
||||
clutter_actor_set_size (texture, size, size);
|
||||
}
|
||||
|
||||
return texture;
|
||||
break;
|
||||
case ST_ICON_FULLCOLOR:
|
||||
themed = g_themed_icon_new_with_default_fallbacks (name);
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
if (texture == NULL)
|
||||
{
|
||||
themed = g_themed_icon_new ("image-missing");
|
||||
texture = load_gicon_with_colors (cache, themed, size, NULL);
|
||||
g_object_unref (themed);
|
||||
}
|
||||
return texture;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
texture = (ClutterActor *) create_default_texture ();
|
||||
clutter_actor_set_size (texture, size, size);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,6 @@ ClutterActor *st_texture_cache_bind_pixbuf_property (StTextureCache *cache,
|
||||
ClutterActor *st_texture_cache_load_icon_name (StTextureCache *cache,
|
||||
StThemeNode *theme_node,
|
||||
const char *name,
|
||||
StIconType icon_type,
|
||||
gint size);
|
||||
|
||||
ClutterActor *st_texture_cache_load_gicon (StTextureCache *cache,
|
||||
|
@ -40,11 +40,6 @@ typedef enum {
|
||||
ST_ALIGN_END
|
||||
} StAlign;
|
||||
|
||||
typedef enum {
|
||||
ST_ICON_SYMBOLIC,
|
||||
ST_ICON_FULLCOLOR
|
||||
} StIconType;
|
||||
|
||||
typedef enum {
|
||||
ST_BACKGROUND_SIZE_AUTO,
|
||||
ST_BACKGROUND_SIZE_CONTAIN,
|
||||
|
Reference in New Issue
Block a user