summaryrefslogtreecommitdiff
path: root/gtk/gtkiconhelper.c
Commit message (Collapse)AuthorAgeFilesLines
* iconhelper: Handle GtkSymbolicPaintableMatthias Clasen2023-01-221-1/+2
| | | | | If we are given a GtkSymbolicPaintable, treat it as symbolic.
* iconhelper: Fix the paintable implementationMatthias Clasen2021-07-311-1/+1
| | | | | | get_current_image was recursing due to an obvious typo. Fixes: #4140
* Reduce use of GtkStyleContextMatthias Clasen2021-01-281-1/+0
| | | | | | Remove some unnecessary uses of GtkStyleContext where we can directly go to the GtkCssStyle, and and drop unnnecessary includes.
* iconhelper: Recreate the texture when neededMatthias Clasen2021-01-111-1/+2
| | | | | | | | | When the icon size changes, we want to reload themed icons. This was showing up as the GtkImage in about dialogs getting a big size with the same small icon upon changing -gtk-icon-size in the inspector.
* gtk: Remove unused header includeBenjamin Otte2020-10-201-1/+0
| | | | | gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in gadgets, and gadgets are gone now.
* Replace "gchar" with "char"Benjamin Otte2020-07-251-2/+2
|
* Replace "gint" with "int"Benjamin Otte2020-07-251-5/+5
|
* css: Drop the -gtk-icon-theme propertyMatthias Clasen2020-04-221-1/+1
| | | | | We want to always use the current icon theme, and only have the minimum amount of custom properties.
* Stop using the -gtk-icon-theme style propertyMatthias Clasen2020-04-221-1/+0
| | | | We want to just use the current icon theme, always.
* Rename GTK_ICON_LOOKUP_LOAD_IN_THREAD to GTK_ICON_LOOKUP_PRELOADAlexander Larsson2020-02-101-1/+1
|
* GtkIconHelper: Trigger preload when css sizes is validAlexander Larsson2020-02-071-5/+14
| | | | | | | | | When the css is validated we know the css size, so we can create the paintable at that point, and we do so passing the LOAD_IN_THREAD flag. This causes us to load most icons early on, in parallel instead of during the first snapshot.
* Remove unnecessary image-missing fallbacksAlexander Larsson2020-02-061-7/+0
| | | | | We now always return something from icon theme lookups, so no need to do custom fallbacks.
* IconTheme: Simplify icon scalingAlexander Larsson2020-02-061-21/+0
| | | | | | | | | | | | | | | | | | | | | We had a pretty complex setup where we tried to avoid scaling up themes from dirs that specified a size. However, not only was it very complex, but it didn't quite work with window scales, because when using e.g. a size 32 directory for 16@2x the dir size is wrong anyway. Additionally it turns out most code either picks an existing icon size, or uses the FORCE_SIZE flags, so it doesn't seem like a useful behaviour. This change drops the FORCE_SIZE flags, and always scales icons. Additionally it moves the scaling of the icon to rendering, which seems more modern, and allows us to (later) share icons loaded for different sizes that happened to use the same source file (at different scales). Note that this changes the behaviour of gtk_icon_paintable_download_texture() is it now returns the unscaled source icon. However, ignore thats, as I plan to remove this function and replace it with a way to render a paintable to a cairo-surface instead.
* GtkIconPaintable: Always recolor when snapshotting.Alexander Larsson2020-02-061-8/+4
| | | | | | | | | | | | | | | It never makes sense to paint a texture that needs recoloring. If you call the regular snapshot on a symbolic texture we just use the default recoloring colors. To support this we also change gtk_css_style_snapshot_icon_paintable() to call gtk_icon_paintable_snapshot_with_colors() for IconPaintables so that we get the correct colors, and we make it not emit the color matrix. Since we now rely on the icon to do the recoloring we also drop the recolor argument in gtk_icon_paintable_snapshot_with_colors() as its not needed anymore.
* Rename GtkIcon to GtkIconPaintableAlexander Larsson2020-02-041-2/+2
|
* icontheme: Remove GENERIC_FALLBACKSBenjamin Otte2020-02-041-1/+1
| | | | | | | | | Instead, rely on people passing fallbacks explicitly. Alternatively, GThemedIcon provides the functionality to create fallbacks, which is what GtkImage and the testsuite now use. That method is slightly better, too, so the expected test results have been updated accordingly.
* icontheme: Pass fallbacks as optional argument to lookup_icon()Benjamin Otte2020-02-041-0/+1
| | | | This way, we can remove gtk_icon_theme_choose_icon() completely.
* icontheme: Remove GTK_ICON_LOOKUP_USE_BUILTINBenjamin Otte2020-02-041-2/+2
| | | | It's unused.
* icontheme: Make text direction a lookup argumentBenjamin Otte2020-02-041-11/+7
| | | | | | Most users were just forgetting to set the proper flags. And flags aren't the right way to set this anyway, it was just acceptable as a workaround during GTK3 to not break API.
* icontheme: Remove async APIsBenjamin Otte2020-02-041-78/+0
| | | | | | | Widgets would not use them properly. In fact, the only user was using them wrong. As icons are loaded async by default, this call isn't necessary.
* GtkIconHelper: Preload icons for mapped widgets with higher priorityAlexander Larsson2020-01-301-1/+24
| | | | | | | | | We look at whether a widget will be mapped (the actual state is not yet set, so we can't rely on that at css validation time) and use that to set the i/o priority of the async task. This means that its likely that widgets that will be displayed soon are loaded before those that are not yet going to be needed.
* IconHelper: Only preload icons onceAlexander Larsson2020-01-301-0/+7
| | | | | | | This limits the amount of preloading we to, which can for instance avoid trashing if the icon cache is full, and in general do less work when its likely to be wasted such as when e.g. background-color for an icon helper changes.
* icon-theme: Add i/o priority to choose_icon_async()Alexander Larsson2020-01-301-1/+1
| | | | | This is set on the GTask and lower priority will be loaded before, this can be used to prioritize some icons for preloading.
* Remove final references to "icon info" with just "icon"Alexander Larsson2020-01-301-6/+6
|
* GtkImage: Preload icons during css validationAlexander Larsson2020-01-301-0/+48
| | | | | | | | | | | | | | | | | | At the end of GtkImage css validation (during style-updated) when the css properties (like the icon size) are valid we call _gtk_icon_helper_preload which does an async icon theme lookup and load. This will happen on a thread in parallel with the rest of the css machinery, and hopefully by the time we need the icon it will be ready. If not we will block when we need it, but during that blocking all the other icons will be loaded. Testing widget-factory this changes the time of snapshot() from 31 to 25 msec, but on the other hand we also load a few more icons that we didn't before causing the css validation phase to be about 8 msec slower. This is because we're preloading all the images in the window, not only the ones that are visible. Unfortunately we still load a bunch of icons in snapshot(), from GtkCssImageIconTheme, and ideally we should try to preload those also.
* icon helper: Remove profiler markAlexander Larsson2020-01-301-10/+0
| | | | | This was hitting every time we looked up an icon, and we already log the actual load of the icon in the icon theme.
* icon-theme: Drop the _for_scale() versions and always take scaleAlexander Larsson2020-01-301-5/+5
|
* icon-theme: Rename GtkIconInfo to GtkIconAlexander Larsson2020-01-301-2/+2
|
* GtkIconHelper use GtkIconInfo as paintableAlexander Larsson2020-01-291-13/+1
|
* Use style values directlyMatthias Clasen2020-01-291-4/+3
| | | | | | | 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.
* css: Update affects flags for iconsMatthias Clasen2020-01-241-8/+13
| | | | | | We want to differentiate what requires recreating the texture and what doesn't. In particular, the current flags are not handling symbolic icons right.
* iconhelper: Add profiler marks around icon loadingMatthias Clasen2020-01-221-0/+11
| | | | | These mainly happen during the first frame, causing it to be longer than 'normal' frames.
* icontheme: Remove gtk_icon_info_load_textureTimm Bäder2019-09-091-1/+1
| | | | It's the same as load_icon now.
* icontheme: Add error argument to _load_textureTimm Bäder2019-09-091-1/+1
| | | | Loading an icon might fail.
* iconhelper: Don't snapshot 0 sized iconsTimm Bäder2019-08-091-1/+4
| | | | | | This is happening for me when snapshotting small thumbnails in the file chooser. The GtkScaler will scale the 1px height/width by 2, resulting in nothing being drawn at all.
* iconhelper: Try to avoid some save/restore callsTimm Bäder2019-07-071-17/+44
| | | | | GtkImage already does something similar so we often end up with 0/0 here. Avoid the save()/restore() calls in GtkSnapshot in that case.
* iconhelper: Use new snapshot transformsBenjamin Otte2019-02-211-4/+6
|
* iconhelper: Fix drawing of empty and paintable helpersBenjamin Otte2018-09-051-2/+6
| | | | | Empty helpers did try to draw a NULL paintable (not good) and in the non-null case code used the wrong width/height.
* iconhelper: Plug memleakBenjamin Otte2018-07-041-0/+2
|
* image: size request is always CONSTANT_SIZEBenjamin Otte2018-07-041-16/+0
| | | | | It's always -gtk-icon-size in both directions, even for paintables. There's no width-for-height happening.
* iconhelper: Always size contents to icon sizeBenjamin Otte2018-06-101-226/+44
| | | | | No more special casing for paintables. If you want the special case for paintables, you should use GtkPicture.
* Fix comment typo introduced in a32725bc9abRobert Ancell2018-05-091-1/+1
|
* image: Actually report a request modeBenjamin Otte2018-04-051-0/+16
| | | | | | This makes height-for-width actually work for GtkImage. I'm kinda ashamed I didn't notice it not working before.
* Fix some leaksKrzesimir Nowak2018-03-271-1/+6
|
* iconhelper: Apply scale to paintableBenjamin Otte2018-03-261-29/+10
| | | | | | Instead of fiddling around with scale in the iconhelper (and getting it wrong), create a GtkScaler around the paintable that takes care of the scaling.
* cellrendererpixbuf: Store the texture in the iconhelper paintableBenjamin Otte2018-03-161-47/+0
| | | | | | | | | That's kinda weird but allows us to delete the texture case from GtkIconHelper and GTK_IMAGE_TEXTURE from the GtkImageType enum. And it doesn't cause any other problems because the cell renderer can't deal with paintables - otherwise it would mirror GtkImage and have a "paintable" property instead.
* image: Add gtk_image_set_keep_aspect_ratio()Benjamin Otte2018-03-161-5/+35
| | | | | | | | If set, the image will draw its contents while keeping their aspect ratio. That means empty areas show up on the top/bottom or left/right. Also move the special-case snapshotting code for icons to GtkIconHelper. That's where it belongs.
* iconhelper: Implement GdkPaintableBenjamin Otte2018-03-161-131/+245
| | | | | | | | This only implements the vfuncs, but does not actually emit signals yet. It's also not useed for anything other than snapshot() so far, this will come in later commits.
* image: Don't handle surfaces anymoreBenjamin Otte2018-03-161-102/+1
| | | | | | | Lots of special cases that are no longer needed because no code uses surfaces. Also remove the GdkCellRendererPixbuf:surface property.
* image: Load resources and files into texturesBenjamin Otte2018-03-161-1/+1
| | | | | | | | | | Instead of loading them into surfaces (which we want to get rid of), we load into textures. In fact, we introduce a new paintable subclass called a GtkScaler that takes care of tracking scaling. This also ideally gets rid of an extra conversion once renderers learn to render textures directly.