static gboolean value_is_done_parsing (GtkCssParser *parser) { return _gtk_css_parser_is_eof (parser) || _gtk_css_parser_begins_with (parser, ';') || _gtk_css_parser_begins_with (parser, '}'); }
static gboolean pattern_value_parse (GtkCssParser *parser, GFile *base, GValue *value) { if (_gtk_css_parser_begins_with (parser, '-')) { g_value_unset (value); g_value_init (value, GTK_TYPE_GRADIENT); return gradient_value_parse (parser, base, value); } else { GError *error = NULL; gchar *path; GdkPixbuf *pixbuf; GFile *file; cairo_surface_t *surface; cairo_pattern_t *pattern; cairo_t *cr; cairo_matrix_t matrix; file = _gtk_css_parse_url (parser, base); if (file == NULL) return FALSE; path = g_file_get_path (file); g_object_unref (file); pixbuf = gdk_pixbuf_new_from_file (path, &error); g_free (path); if (pixbuf == NULL) { _gtk_css_parser_take_error (parser, error); return FALSE; } surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); cr = cairo_create (surface); gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); pattern = cairo_pattern_create_for_surface (surface); cairo_matrix_init_scale (&matrix, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); cairo_pattern_set_matrix (pattern, &matrix); cairo_surface_destroy (surface); cairo_destroy (cr); g_object_unref (pixbuf); g_value_take_boxed (value, pattern); } return TRUE; }