StIcon: Remove content-image capability

The ability to set a "content image" on an icon relies on the ability
to have custom theme properties of a "border image" (9-slice) type.
We don't have this, and the capability of a bordered image specified
by the theme can be achieved more naturally with standard CSS facilities.

https://bugzilla.gnome.org/show_bug.cgi?id=633865
This commit is contained in:
Owen W. Taylor 2010-10-30 20:08:49 -04:00
parent b0e713b775
commit a9a8b1ec6a

View File

@ -51,7 +51,6 @@ G_DEFINE_TYPE_WITH_CODE (StIcon, st_icon, ST_TYPE_WIDGET,
struct _StIconPrivate
{
ClutterActor *icon_texture;
gboolean is_content_image;
gchar *icon_name;
gint icon_size;
@ -70,13 +69,6 @@ st_stylable_iface_init (StStylableIface *iface)
is_initialized = TRUE;
pspec = g_param_spec_boxed ("x-st-content-image",
"Content Image",
"Image used as the button",
ST_TYPE_BORDER_IMAGE,
G_PARAM_READWRITE);
st_stylable_iface_install_property (iface, ST_TYPE_ICON, pspec);
pspec = g_param_spec_string ("x-st-icon-name",
"Icon name",
"Icon name to load from the theme",
@ -189,16 +181,11 @@ st_icon_get_preferred_height (ClutterActor *actor,
&width,
&height);
if (!priv->is_content_image)
{
if (width <= height)
pref_height = priv->icon_size;
else
pref_height = height / (gfloat)width * priv->icon_size;
}
else
pref_height = height;
}
else
pref_height = 0;
@ -230,16 +217,11 @@ st_icon_get_preferred_width (ClutterActor *actor,
&width,
&height);
if (!priv->is_content_image)
{
if (height <= width)
pref_width = priv->icon_size;
else
pref_width = width / (gfloat)height * priv->icon_size;
}
else
pref_width = width;
}
else
pref_width = 0;
@ -283,7 +265,6 @@ st_icon_paint (ClutterActor *actor)
StIconPrivate *priv = ST_ICON (actor)->priv;
/* Chain up to paint background */
if (!priv->is_content_image)
CLUTTER_ACTOR_CLASS (st_icon_parent_class)->paint (actor);
if (priv->icon_texture)
@ -352,13 +333,6 @@ st_icon_update (StIcon *icon)
{
StIconPrivate *priv = icon->priv;
if (priv->is_content_image)
{
priv->is_content_image = FALSE;
g_signal_connect (st_icon_theme_get_default (), "notify::theme-name",
G_CALLBACK (st_icon_notify_theme_name_cb), icon);
}
/* Get rid of the old one */
if (priv->icon_texture)
{
@ -393,49 +367,15 @@ st_icon_style_changed_cb (StWidget *widget)
StIcon *self = ST_ICON (widget);
StIconPrivate *priv = self->priv;
StBorderImage *content_image = NULL;
gboolean changed = FALSE;
gchar *icon_name = NULL;
gint icon_size = -1;
st_stylable_get (ST_STYLABLE (widget),
"x-st-content-image", &content_image,
"x-st-icon-name", &icon_name,
"x-st-icon-size", &icon_size,
NULL);
/* Content-image overrides drawing of the icon, so
* don't bother reading those properties if it's set.
*/
if (content_image)
{
GError *error = NULL;
priv->is_content_image = TRUE;
g_signal_handlers_disconnect_by_func (st_icon_theme_get_default (),
st_icon_notify_theme_name_cb,
self);
if (priv->icon_texture)
clutter_actor_destroy (priv->icon_texture);
priv->icon_texture = clutter_texture_new_from_file (content_image->uri,
&error);
if (priv->icon_texture)
clutter_actor_set_parent (priv->icon_texture, CLUTTER_ACTOR (widget));
if (error)
{
g_warning ("Could not load content image: %s", error->message);
g_error_free (error);
}
g_boxed_free (ST_TYPE_BORDER_IMAGE, content_image);
g_free (icon_name);
return;
}
if (icon_name && (!priv->icon_name ||
!g_str_equal (icon_name, priv->icon_name)))
{