예제 #1
0
static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue             *value,
                             guint                    property_id,
                             GtkStyleProviderPrivate *provider,
                             GtkCssComputedValues    *values,
                             GtkCssComputedValues    *parent_values,
                             GtkCssDependencies      *dependencies)
{
  GtkCssImage *image, *computed;
  
  image = _gtk_css_image_value_get_image (value);

  if (image == NULL)
    return _gtk_css_value_ref (value);

  computed = _gtk_css_image_compute (image, property_id, provider, values, parent_values, dependencies);

  if (computed == image)
    {
      g_object_unref (computed);
      return _gtk_css_value_ref (value);
    }

  return _gtk_css_image_value_new (computed);
}
예제 #2
0
static GtkCssImage *
gtk_css_image_fallback_compute (GtkCssImage             *image,
                                guint                    property_id,
                                GtkStyleProviderPrivate *provider,
                                GtkCssStyle             *style,
                                GtkCssStyle             *parent_style)
{
  GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
  GtkCssImageFallback *copy;
  int i;

  if (fallback->used < 0)
    {
      copy = g_object_new (_gtk_css_image_fallback_get_type (), NULL);
      copy->n_images = fallback->n_images;
      copy->images = g_new (GtkCssImage *, fallback->n_images);
      for (i = 0; i < fallback->n_images; i++)
        {
          copy->images[i] = _gtk_css_image_compute (fallback->images[i],
                                                    property_id,
                                                    provider,
                                                    style,
                                                    parent_style);

          /* Assume that failing to load an image leaves a 0x0 surface image */
          if (GTK_IS_CSS_IMAGE_SURFACE (copy->images[i]) &&
              _gtk_css_image_get_width (copy->images[i]) == 0 &&
              _gtk_css_image_get_height (copy->images[i]) == 0)
            continue;

          if (copy->used < 0)
            copy->used = i;
        }

      if (fallback->color)
        copy->color = _gtk_css_value_compute (fallback->color,
                                              property_id,
                                              provider,
                                              style,
                                              parent_style);
      else
        copy->color = NULL;

      return GTK_CSS_IMAGE (copy);
    }
예제 #3
0
static GtkCssImage *
gtk_css_image_fallback_compute (GtkCssImage      *image,
                                guint             property_id,
                                GtkStyleProvider *provider,
                                GtkCssStyle      *style,
                                GtkCssStyle      *parent_style)
{
  GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
  GtkCssImageFallback *copy;
  int i;

  if (fallback->used < 0)
    {
      copy = g_object_new (_gtk_css_image_fallback_get_type (), NULL);
      copy->n_images = fallback->n_images;
      copy->images = g_new (GtkCssImage *, fallback->n_images);
      for (i = 0; i < fallback->n_images; i++)
        {
          copy->images[i] = _gtk_css_image_compute (fallback->images[i],
                                                    property_id,
                                                    provider,
                                                    style,
                                                    parent_style);

          if (gtk_css_image_is_invalid (copy->images[i]))
            continue;

          if (copy->used < 0)
            copy->used = i;
        }

      if (fallback->color)
        copy->color = _gtk_css_value_compute (fallback->color,
                                              property_id,
                                              provider,
                                              style,
                                              parent_style);
      else
        copy->color = NULL;

      return GTK_CSS_IMAGE (copy);
    }
예제 #4
0
static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue      *value,
                             guint             property_id,
                             GtkStyleProvider *provider,
                             GtkCssStyle      *style,
                             GtkCssStyle      *parent_style)
{
  GtkCssImage *image, *computed;
  
  image = _gtk_css_image_value_get_image (value);

  if (image == NULL)
    return _gtk_css_value_ref (value);

  computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);

  if (computed == image)
    {
      g_object_unref (computed);
      return _gtk_css_value_ref (value);
    }

  return _gtk_css_image_value_new (computed);
}