Esempio n. 1
0
static gboolean
gtk_css_image_gradient_parse (GtkCssImage  *image,
                              GtkCssParser *parser)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);

  gradient->gradient = _gtk_gradient_parse (parser);

  return gradient->gradient != NULL;
}
Esempio n. 2
0
static void
gtk_css_image_gradient_print (GtkCssImage *image,
                              GString     *string)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);
  char *s;

  s = gtk_gradient_to_string (gradient->gradient);
  g_string_append (string, s);
  g_free (s);
}
Esempio n. 3
0
static GtkCssImage *
gtk_css_image_gradient_transition (GtkCssImage *start_image,
                                   GtkCssImage *end_image,
                                   guint        property_id,
                                   double       progress)
{
  GtkGradient *start_gradient, *end_gradient, *gradient;
  cairo_pattern_t *start_pattern, *end_pattern;
  GtkCssImageGradient *result;

  start_gradient = GTK_CSS_IMAGE_GRADIENT (start_image)->gradient;
  start_pattern = GTK_CSS_IMAGE_GRADIENT (start_image)->pattern;
  if (end_image == NULL)
    {
      end_gradient = NULL;
      end_pattern = NULL;
    }
  else
    {
      if (!GTK_IS_CSS_IMAGE_GRADIENT (end_image))
        return GTK_CSS_IMAGE_CLASS (_gtk_css_image_gradient_parent_class)->transition (start_image, end_image, property_id, progress);

      end_gradient = GTK_CSS_IMAGE_GRADIENT (end_image)->gradient;
      end_pattern = GTK_CSS_IMAGE_GRADIENT (end_image)->pattern;
    }

  gradient = _gtk_gradient_transition (start_gradient, end_gradient, property_id, progress);
  if (gradient == NULL)
    return GTK_CSS_IMAGE_CLASS (_gtk_css_image_gradient_parent_class)->transition (start_image, end_image, property_id, progress);

  result = g_object_new (GTK_TYPE_CSS_IMAGE_GRADIENT, NULL);
  result->gradient = gradient;
  result->pattern = transition_pattern (start_pattern, end_pattern, progress);

  return GTK_CSS_IMAGE (result);
}
Esempio n. 4
0
static GtkCssImage *
gtk_css_image_gradient_compute (GtkCssImage     *image,
                                GtkStyleContext *context)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);
  GtkCssImageGradient *copy;

  if (gradient->pattern)
    return g_object_ref (gradient);

  copy = g_object_new (GTK_TYPE_CSS_IMAGE_GRADIENT, NULL);
  copy->gradient = gtk_gradient_ref (gradient->gradient);
  copy->pattern = gtk_gradient_resolve_for_context (copy->gradient, context);

  return GTK_CSS_IMAGE (copy);
}
Esempio n. 5
0
static void
gtk_css_image_gradient_dispose (GObject *object)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (object);

  if (gradient->gradient)
    {
      gtk_gradient_unref (gradient->gradient);
      gradient->gradient = NULL;
    }
  if (gradient->pattern)
    {
      cairo_pattern_destroy (gradient->pattern);
      gradient->pattern = NULL;
    }

  G_OBJECT_CLASS (_gtk_css_image_gradient_parent_class)->dispose (object);
}
Esempio n. 6
0
static void
gtk_css_image_gradient_draw (GtkCssImage        *image,
                             cairo_t            *cr,
                             double              width,
                             double              height)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);

  if (!gradient->pattern)
    {
      g_warning ("trying to paint unresolved gradient");
      return;
    }

  cairo_scale (cr, width, height);

  cairo_rectangle (cr, 0, 0, 1, 1);
  cairo_set_source (cr, gradient->pattern);
  cairo_fill (cr);
}
Esempio n. 7
0
static GtkCssImage *
gtk_css_image_gradient_compute (GtkCssImage             *image,
                                guint                    property_id,
                                GtkStyleProviderPrivate *provider,
                                GtkCssComputedValues    *values,
                                GtkCssComputedValues    *parent_values,
                                GtkCssDependencies      *dependencies)
{
  GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);
  GtkCssImageGradient *copy;

  if (gradient->pattern)
    return g_object_ref (gradient);

  copy = g_object_new (GTK_TYPE_CSS_IMAGE_GRADIENT, NULL);
  copy->gradient = gtk_gradient_ref (gradient->gradient);
  copy->pattern = _gtk_gradient_resolve_full (copy->gradient, provider, values, parent_values, dependencies);

  return GTK_CSS_IMAGE (copy);
}