Exemple #1
0
static void
mex_tile_style_changed_cb (MexTile *self, MxStyleChangedFlags flags)
{
  MexTilePrivate *priv = self->priv;
  MxBorderImage *image;

  if (priv->header_padding)
    {
      g_boxed_free (MX_TYPE_PADDING, priv->header_padding);
      priv->header_padding = NULL;
    }

  if (priv->header_background_color)
    {
      g_boxed_free (CLUTTER_TYPE_COLOR, priv->header_background_color);
      priv->header_background_color = NULL;
    }

  mx_stylable_get (MX_STYLABLE (self),
                   "x-mex-header-background", &image,
                   "x-mex-header-background-color", &priv->header_background_color,
                   "x-mex-header-padding", &priv->header_padding,
                   NULL);

  mx_stylable_apply_clutter_text_attributes (MX_STYLABLE (self),
                                             CLUTTER_TEXT (priv->label));

  mx_stylable_apply_clutter_text_attributes (MX_STYLABLE (self),
                                             CLUTTER_TEXT (priv->secondary_label));

  if (image && image->uri)
    {
      CoglObject *background;

      background =
        mx_texture_cache_get_cogl_texture (mx_texture_cache_get_default (),
                                           image->uri);
      cogl_material_set_layer (priv->material, 0, background);
    }
  else
    {
      if (cogl_material_get_n_layers (priv->material))
        cogl_material_remove_layer (priv->material, 0);
    }

  if (image)
    g_boxed_free (MX_TYPE_BORDER_IMAGE, image);

  if (priv->icon1)
    mx_stylable_style_changed (MX_STYLABLE (priv->icon1), flags);

  if (priv->icon2)
    mx_stylable_style_changed (MX_STYLABLE (priv->icon2), flags);

  clutter_actor_queue_redraw (CLUTTER_ACTOR (self));
}
Exemple #2
0
/**
 * mx_icon_theme_lookup:
 * @theme: an #MxIconTheme
 * @icon_name: The name of the icon
 * @size: The desired size of the icon
 *
 * If the icon is available, returns a #CoglHandle of the icon.
 *
 * Return value: (transfer none): a #CoglHandle of the icon, or %NULL.
 */
CoglHandle
mx_icon_theme_lookup (MxIconTheme *theme,
                      const gchar *icon_name,
                      gint         size)
{
  MxTextureCache *texture_cache;
  MxIconData *icon_data;

  g_return_val_if_fail (MX_IS_ICON_THEME (theme), NULL);
  g_return_val_if_fail (icon_name, NULL);
  g_return_val_if_fail (size > 0, NULL);

  if (!(icon_data = mx_icon_theme_lookup_internal (theme, icon_name, size)))
    return NULL;

  texture_cache = mx_texture_cache_get_default ();
  return mx_texture_cache_get_cogl_texture (texture_cache, icon_data->path);
}
Exemple #3
0
static void
mx_tooltip_style_changed (MxWidget *self)
{
  ClutterColor *color = NULL;
  MxTooltipPrivate *priv;
  gchar *font_name;
  gchar *font_string;
  gint font_size;
  MxBorderImage *border_image;

  priv = MX_TOOLTIP (self)->priv;

  mx_stylable_get (MX_STYLABLE (self),
                   "color", &color,
                   "font-family", &font_name,
                   "font-size", &font_size,
                   "border-image", &border_image,
                   NULL);

  if (color)
    {
      clutter_text_set_color (CLUTTER_TEXT (priv->label), color);
      clutter_color_free (color);
    }

  if (font_name || font_size)
    {
      if (font_name && font_size)
        {
          font_string = g_strdup_printf ("%s %dpx", font_name, font_size);
          g_free (font_name);
        }
      else
      if (font_size)
        font_string = g_strdup_printf ("%dpx", font_size);
      else
        font_string = font_name;

      clutter_text_set_font_name (CLUTTER_TEXT (priv->label), font_string);

      g_free (font_string);
    }


  /* remove existing border image */
  if (priv->border_image)
    {
      g_boxed_free (MX_TYPE_BORDER_IMAGE, priv->border_image);
      priv->border_image = NULL;
    }


  if (priv->border_image_texture)
    {
      cogl_handle_unref (priv->border_image_texture);
      priv->border_image_texture = NULL;
    }

  if (border_image)
    {
      priv->border_image_texture =
        mx_texture_cache_get_cogl_texture (mx_texture_cache_get_default (),
                                           border_image->uri);

      priv->border_image = border_image;
    }

  clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
}