Beispiel #1
0
void
st_icon_set_icon_name (StIcon      *icon,
                       const gchar *icon_name)
{
  StIconPrivate *priv = icon->priv;
  GIcon *gicon = NULL;

  g_return_if_fail (ST_IS_ICON (icon));

  if (icon_name)
    gicon = g_themed_icon_new_with_default_fallbacks (icon_name);

  if (g_icon_equal (priv->gicon, gicon)) /* do nothing */
    {
      g_object_unref (gicon);
      return;
    }

  if (priv->gicon)
    g_object_unref (priv->gicon);

  g_object_freeze_notify (G_OBJECT (icon));

  priv->gicon = gicon;

  g_object_notify (G_OBJECT (icon), "gicon");
  g_object_notify (G_OBJECT (icon), "icon-name");

  g_object_thaw_notify (G_OBJECT (icon));

  st_icon_update (icon);
}
Beispiel #2
0
static void
st_icon_style_changed (StWidget *widget)
{
  StIcon *self = ST_ICON (widget);
  StThemeNode *theme_node = st_widget_get_theme_node (widget);
  StIconPrivate *priv = self->priv;

  if (priv->shadow_spec)
    {
      st_shadow_unref (priv->shadow_spec);
      priv->shadow_spec = NULL;
    }

  if (priv->shadow_material)
    {
      cogl_handle_unref (priv->shadow_material);
      priv->shadow_material = COGL_INVALID_HANDLE;
    }

  priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");

  if (priv->shadow_spec && priv->shadow_spec->inset)
    {
      g_warning ("The icon-shadow property does not support inset shadows");
      st_shadow_unref (priv->shadow_spec);
      priv->shadow_spec = NULL;
    }

  priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
  st_icon_update_icon_size (self);
  st_icon_update (self);
}
Beispiel #3
0
/**
 * st_icon_set_gicon:
 * @icon: an icon
 * @gicon: (allow-none): a #GIcon to override :icon-name
 */
void
st_icon_set_gicon (StIcon *icon, GIcon *gicon)
{
  g_return_if_fail (ST_IS_ICON (icon));
  g_return_if_fail (G_IS_ICON (gicon));

  if (icon->priv->gicon == gicon) /* do nothing */
    return;

  if (icon->priv->gicon)
    {
      g_object_unref (icon->priv->gicon);
      icon->priv->gicon = NULL;
    }

  if (gicon)
    icon->priv->gicon = g_object_ref (gicon);

  if (icon->priv->icon_name)
    {
      g_free (icon->priv->icon_name);
      icon->priv->icon_name = NULL;
      g_object_notify (G_OBJECT (icon), "icon-name");
    }

  g_object_notify (G_OBJECT (icon), "gicon");

  st_icon_update (icon);
}
Beispiel #4
0
void
st_icon_set_icon_name (StIcon      *icon,
                       const gchar *icon_name)
{
  StIconPrivate *priv;

  g_return_if_fail (ST_IS_ICON (icon));

  priv = icon->priv;

  /* Check if there's no change */
  if (g_strcmp0 (priv->icon_name, icon_name) == 0)
    return;

  g_free (priv->icon_name);
  priv->icon_name = g_strdup (icon_name);

  if (priv->gicon)
    {
      g_object_unref (priv->gicon);
      priv->gicon = NULL;
      g_object_notify (G_OBJECT (icon), "gicon");
    }

  g_object_notify (G_OBJECT (icon), "icon-name");

  st_icon_update (icon);
}
Beispiel #5
0
/**
 * st_icon_set_icon_size:
 * @icon: an icon
 * @size: if positive, the new size, otherwise the size will be
 *   derived from the current style
 *
 * Sets an explicit size for the icon.
 */
void
st_icon_set_icon_size (StIcon *icon,
                       gint    size)
{
  StIconPrivate *priv;

  g_return_if_fail (ST_IS_ICON (icon));

  priv = icon->priv;
  if (priv->prop_icon_size != size)
    {
      priv->prop_icon_size = size;
      if (st_icon_update_icon_size (icon))
        st_icon_update (icon);
      g_object_notify (G_OBJECT (icon), "icon-size");
    }
}
Beispiel #6
0
/**
 * 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");
}
Beispiel #7
0
/**
 * st_icon_set_gicon:
 * @icon: an icon
 * @gicon: (allow-none): a #GIcon to override :icon-name
 */
void
st_icon_set_gicon (StIcon *icon, GIcon *gicon)
{
  g_return_if_fail (ST_IS_ICON (icon));
  g_return_if_fail (gicon == NULL || G_IS_ICON (gicon));

  if (g_icon_equal (icon->priv->gicon, gicon)) /* do nothing */
    return;

  if (icon->priv->gicon)
    {
      g_object_unref (icon->priv->gicon);
      icon->priv->gicon = NULL;
    }

  if (gicon)
    icon->priv->gicon = g_object_ref (gicon);

  g_object_notify (G_OBJECT (icon), "gicon");

  st_icon_update (icon);
}
Beispiel #8
0
static void
st_icon_style_changed (StWidget *widget)
{
  StIcon *self = ST_ICON (widget);
  StThemeNode *theme_node = st_widget_get_theme_node (widget);
  StIconPrivate *priv = self->priv;

  g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
  g_clear_pointer (&priv->shadow_spec, st_shadow_unref);

  priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");

  if (priv->shadow_spec && priv->shadow_spec->inset)
    {
      g_warning ("The icon-shadow property does not support inset shadows");
      st_shadow_unref (priv->shadow_spec);
      priv->shadow_spec = NULL;
    }

  priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
  st_icon_update_icon_size (self);
  st_icon_update (self);
}