Ejemplo n.º 1
0
static void
mx_combo_box_style_changed (MxComboBox *combo, MxStyleChangedFlags flags)
{
  MxBorderImage *marker_filename;
  gint spacing;

  MxComboBoxPrivate *priv = combo->priv;

  mx_stylable_get (MX_STYLABLE (combo),
                   "x-mx-spacing", &spacing,
                   "x-mx-marker-image", &marker_filename,
                   NULL);

  if (spacing != priv->spacing)
    priv->spacing = spacing;

  if (priv->marker)
    {
      clutter_actor_destroy (priv->marker);
      priv->marker = NULL;
    }

  if (marker_filename)
    {
      MxTextureCache *cache = mx_texture_cache_get_default ();
      priv->marker = (ClutterActor *)
        mx_texture_cache_get_texture (cache, marker_filename->uri);
      if (priv->marker)
        clutter_actor_add_child (CLUTTER_ACTOR (combo), priv->marker);

      g_boxed_free (MX_TYPE_BORDER_IMAGE, marker_filename);
    }

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

  /* make sure the popup is also up-to-date */
  mx_stylable_style_changed (MX_STYLABLE (mx_widget_get_menu (MX_WIDGET (combo))),
                             flags | MX_STYLE_CHANGED_FORCE);

  clutter_actor_queue_relayout (CLUTTER_ACTOR (combo));
}
Ejemplo n.º 2
0
Archivo: mx-button.c Proyecto: danni/mx
static void
mx_button_style_changed (MxWidget *widget)
{
  MxButton *button = MX_BUTTON (widget);
  MxButtonPrivate *priv = button->priv;
  MxBorderImage *content_image = NULL;

  /* update the label styling */
  mx_button_update_label_style (button);

  g_free (priv->style_icon_name);
  mx_stylable_get (MX_STYLABLE (widget),
                   "x-mx-content-image", &content_image,
                   "x-mx-icon-name", &priv->style_icon_name,
                   "x-mx-icon-size", &priv->style_icon_size,
                   NULL);

  if (content_image && content_image->uri)
    {
      if (priv->content_image)
        {
          clutter_actor_remove_child (CLUTTER_ACTOR (widget),
                                      priv->content_image);
        }

      priv->content_image =
        (ClutterActor*) mx_texture_cache_get_texture (mx_texture_cache_get_default (),
                                                      content_image->uri);

      if (priv->content_image)
        clutter_actor_add_child (CLUTTER_ACTOR (widget), priv->content_image);
      else
        g_warning ("Could not load content image \"%s\"", content_image->uri);

      g_boxed_free (MX_TYPE_BORDER_IMAGE, content_image);

      return;
    }
  else
    {
      /* remove any previous content image */
      if (priv->content_image)
        {
          clutter_actor_remove_child (CLUTTER_ACTOR (widget),
                                      priv->content_image);
          priv->content_image = NULL;
        }

      if (content_image)
        g_boxed_free (MX_TYPE_BORDER_IMAGE, content_image);
    }

  if (priv->icon_size == 0)
    mx_icon_set_icon_size (MX_ICON (priv->icon), priv->style_icon_size);

  if (priv->style_icon_name && !priv->icon_name)
    {
      mx_icon_set_icon_name (MX_ICON (priv->icon), priv->style_icon_name);
      mx_button_update_contents (button);
    }
}