Commit Graph

24 Commits

Author SHA1 Message Date
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Matthias Clasen
2f17ab3ce7 Avoid mime sniffing where possible
When we are loading symbolic pngs or svgs, we know
that we need to the png or svg loader, so there is
no need to go through (surprisingly expensive) mime
sniffing to find the right loader.
2020-02-08 10:22:54 -05:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Timm Bäder
d9652675ef cssimagerecolor: Implement is_computed() 2020-01-24 06:08:39 +01:00
Timm Bäder
67991ed0f4 Remove GtkCssRgbaValue
The differenciation between a literal color value and an RGBA value
caused problems in various situations. Just treat the two the same but
don't allow access to the rgba value of a non-literal color value.

This gets rid of around 1.6k rgba values in the widget-factory.
2020-01-18 08:49:51 +01:00
Timm Bäder
07d1ea4356 cssimagerecolor: Avoid copying colors 2019-11-14 09:15:58 +01:00
Benjamin Otte
0886ade182 cssparser: Make gsk_renderer_consume_url() return a string
We don't want to return a GFile because GFile can't handle can't deal
with data: urls.
That makes the code a bit more complicated that doesn't deal with those
URLs, but it makes the other code actually work.

GtkCssImageUrl also now decodes data urls immediately instead of only at
the first load. So don't use data urls if you care about performance.
2019-05-12 17:28:19 +02:00
Matthias Clasen
69f12ed6a5 Avoid a crash without librsvg
gtk_css_image_recolor_load_texture may leave
recolor->text as NULL without setting error.
No need to crash for that.
2019-04-18 00:13:53 +00:00
Benjamin Otte
1cd9396154 css: Review error messages
... and move them from _gtk_css_parser_error() to the proper new error
message.
2019-04-12 19:34:28 +02:00
Benjamin Otte
607502ef43 cssparser: Add gtk_css_parser_consume_url()
Another slight renaming and semantics change.
2019-04-12 19:34:28 +02:00
Benjamin Otte
45bc4ed321 cssimagerecolor: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
a938c14d11 build: Add gtk-css static library
This library is meant to be the new CSS library that gets used from GDK,
GSK and GTK for string printing and parsing.

As a first step, move GtkCssProviderError into it.

While doing so, split it into GtkCssParserError (for critical problems)
and GtkCssParserWarning (for non-critical problems).
2019-04-12 19:34:28 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Benjamin Otte
3faa7e04db cssimage: Add GtkCssImagePaintable
This type can hold any GdkPaintable.

Use it to replace GtkCssImageSurface, which used to hold a GdkTexture.
2018-03-16 06:04:44 +01:00
Matthias Clasen
2edd3741f6 Use the new texture utils here
One less place where we juggle pixbufs.
2017-11-30 07:54:52 -05:00
Matthias Clasen
7aa236fbb2 Fix a compiler warning 2017-11-08 22:09:34 -05:00
Matthias Clasen
c83665005a Use color matrices for -gtk-recolor
Use the same approach we take for recoloring in GtkIconHelper now.
As part of this change, GtkCsSImageRecolor is changed to not derive
from GtkCssImageUrl anymore.
2017-11-08 10:04:38 -05:00
Benjamin Otte
83fb7a649f css: Merge GtkStyleProviderPrivate into GtkStyleProvider
This is just lots of renaming.

The interface remains private, so the public API does not change, apart
from removing the definition of the Interface object to avoid
subclassing.
2017-10-31 04:33:54 +01:00
Benjamin Otte
ed6643cf69 cssimage: Use textures in GtkCssImageSurface
We now use textures instead of surfaces and implement the snapshot()
vfunc instead of draw().
2016-12-20 18:01:10 +01:00
Matthias Clasen
0fe468c789 Emit an error if image loading fails
Instead of spamming stderr with g_warning, use the new
emit_error method of the GtkStyleProviderPrivate interface
to emit an error if loading an image fails.
2016-01-30 00:29:04 -05:00
Matthias Clasen
b281c9d740 css image recolor: Load images at the proper scale
We should not hardcode a scale of 1, this leads to
pixellated upscaled images at scale=2, even if the source
is an svg. By passing the proper scale, we can load the
svg at the correct size.
2016-01-29 17:30:10 -05:00
Matthias Clasen
77a6d976b2 css: Fix refcounting thinko in -gtk-recolor
gtk_css_style_get_value does not return a reference.
So don't unref the return value without taking one.
2016-01-21 08:42:55 -05:00
Matthias Clasen
419f2c670d css: Handle image loading errors graciously
If we fail to load the image for a -gtk-recolor() expression,
fall back to using the image-missing icon instead of crashing,
and include more details in the warning message.
2016-01-21 08:19:37 -05:00
Matthias Clasen
beec55a22b Add a way to load recolored icons in CSS
This can come in handy to load images that are not in an icon theme,
but still benefit from symbolic recoloring.

https://bugzilla.gnome.org/show_bug.cgi?id=760536
2016-01-14 13:51:15 -05:00