Commit Graph

77 Commits

Author SHA1 Message Date
Benjamin Otte
1f6efbf669 iconhelper: Queue resize on invalidation
When things change in the iconhelper, queue a resize on the owner widget
so that it automatically resizes.

Only do this for iconhelpers that are used as gadgets though, not for
temporary helpers - and to check this, check if the node is transient.
2015-12-15 08:41:16 -05:00
Benjamin Otte
4586503e93 iconhelper: Finish gadget conversion
Implement missing vfuncs
2015-12-15 08:41:16 -05:00
Benjamin Otte
b79a187d47 iconhelper: Handle invalidation
When CSS, direction or scale factor change, handle the invalidation
inside the iconhelper.
This way the widgets using them don't have to.
2015-12-15 08:41:16 -05:00
Benjamin Otte
de6dca4f81 iconhelper: Use the gadget's node
... instead of looking at the widget's style context.

This removes all calls to the style context.
2015-12-15 08:41:16 -05:00
Benjamin Otte
ad22612ab2 iconhelper: Require passing a cssnode to the constructor
Note that we don't use it yet.
2015-12-15 08:41:16 -05:00
Benjamin Otte
7075d00958 iconhelper: Use the gadget's owner property
Don't keep the owner widget ourselves.
2015-12-15 08:41:16 -05:00
Benjamin Otte
25ecd8cd37 iconhelper: Turn into gadget
This is just the basic conversion to inheriting from
GTK_TYPE_CSS_GADGET.
2015-12-15 08:41:16 -05:00
Benjamin Otte
861ac8e373 iconhelper_ Don't use deprecated functions
Use gtk_widget_get_direction() instead of
gtk_style_context_get_direction().
2015-12-09 13:30:40 +01:00
Benjamin Otte
ccfc4d3f12 iconhelper: Remove the context argument
Instead, use the widget's context.
2015-12-09 13:30:40 +01:00
Benjamin Otte
e95e2d5048 iconhelper: Get rid of _gtk_icon_helper_set_window()
Instead use the window of the owner widget.
2015-12-09 13:30:40 +01:00
Benjamin Otte
c9d1a45d30 iconhelper: Require a widget as construction argument
Note that the caller needs to ensure the widget lives as long as the
iconhelper as the iconhelper will not ref the widget.
2015-12-09 13:30:40 +01:00
Benjamin Otte
01387428a3 iconhelper: Pass only the CssStyle when loading pixbufs 2015-12-09 13:30:40 +01:00
Benjamin Otte
6afeab4313 iconhelper: Remove unused GtkStyleContext parameters 2015-12-09 13:30:40 +01:00
Benjamin Otte
cf77c1695d iconhelper: Pass only the CssStyle when loading iconsets 2015-12-09 13:30:40 +01:00
Benjamin Otte
ee6e685478 iconhelper: Pass only the CssStyle when loading icons
This is the first step in replacing StyleContext usage with CssNode
usage.
2015-12-09 13:30:39 +01:00
Benjamin Otte
d14e2a489a iconhelper: Fold function into callers
The function takes so many arguments and is so short that it's not worth
keeping.
2015-12-04 17:44:51 +01:00
Benjamin Otte
72d4b65b1d iconhelper: Apply icon-effect directly
Instead of creating an icon source, making sure no state is set and
therefore the icon-effect will be applied and then rendering that icon
source, just call the icon-effect apply function.

Also, the new way isn't deprecated.
2015-12-04 17:44:51 +01:00
Benjamin Otte
cefba86fb3 iconhelper: Return surface from icon-effect function
All the callers where converting to a surface anyway.
2015-12-04 17:44:51 +01:00
Benjamin Otte
295f208e1c iconhelper: Refactor missing icon handling
In particular, stop using deprecated code for loading the missing image
icon.
2015-12-04 17:44:51 +01:00
Benjamin Otte
3c54a49633 iconhelper: Fold function into only caller 2015-12-04 17:44:51 +01:00
Benjamin Otte
bc1b53a34c css: Query icon theme from style, not from settings
No need to look at the settings when the CSS has a property for the icon
theme.
2015-12-02 03:18:26 +01:00
Benjamin Otte
0c027937e8 iconhelper: Stop tracking state
The iconfactory code doesn't use it anymore, so we don't need to track
it either.
2015-12-02 00:29:31 +01:00
Benjamin Otte
6a4b91d0ed iconhelper: Remove _gtk_icon_helper_ensure_pixbuf()
The code isn't used anymore. Everything uses
gtk_icon_helper_load_surface() now.
2015-12-02 00:29:30 +01:00
Benjamin Otte
4a42aa5229 imagedefinition: Remove icon-size
The size of icons is a property that is relevant to who is rendering the
icon, not to the icon itself.

Example: Starting a DND operation from an entry icon should cause the
icon to resize (from the entr icon's size to the DND icon size).
2015-12-02 00:29:30 +01:00
Benjamin Otte
e99eba4415 dnd: Rewrite iconhelper code
It now uses GtkImageDefinition instead.
2015-12-02 00:29:30 +01:00
Benjamin Otte
482d71d680 iconhelper: Add a scale argument to gtk_icon_helper_load_surface()
It will be used in the next patch.
2015-12-02 00:29:30 +01:00
Benjamin Otte
afad393b15 iconhelper: Refactor ensure_surface()
Make gtk_icon_helper_ensure_surface() a private function that just
ensures the surface was loaded.

Add gtk_icon_helper_load_surface() that is called by the above function
and the dnd code to actually load the surface.
2015-12-02 00:29:30 +01:00
Benjamin Otte
2ce67f0098 iconhelper: Store surface in ensure_surface()
Do not assign it in the functions that actually load the surface. Make
those just return the surface.
2015-12-02 00:29:30 +01:00
Benjamin Otte
b2584eb8ed iconhelper: Don't store surface size
Instead, compute it on demand.

This avoids having to cache it in lots of places and simplifies code.
2015-12-02 00:29:29 +01:00
Benjamin Otte
751a1a9926 iconhelper: Move invalidation check
Just do the invalidation check once, there's no need to do it in every
branch of the switch.

Also remove useless checks: These functions will not be called if we
already have a rendered surface.
2015-12-02 00:29:29 +01:00
Benjamin Otte
c601a9653a iconhelper: Move invalidation check
Just do the invalidation check once, there's no need to do it in every
branch of the switch.

Also remove useless checks: These functions will not be called if we
already have a rendered surface.
2015-12-02 00:29:29 +01:00
Benjamin Otte
afd0e28437 iconhelper: Improve size determination for surfaces
Instead of just working for image surface, this should now work for all
bounded surfaces.

Test included.
2015-12-02 00:29:29 +01:00
Benjamin Otte
071d2a1d69 iconhelper: Move size computation
We do a switch on the image type, so compute the size for a certain
image type right there.
2015-12-02 00:29:29 +01:00
Benjamin Otte
1c96b703a6 dragsource: Store an itemdefinition, not an iconhelper
The icon is never rendered, so there's no need for the extra iconhelper
code.
2015-12-02 00:29:29 +01:00
Benjamin Otte
e666106a43 imagedefinition: Split out from icon helper
The image definition is supposed to hold the description about the image
to be displayed. The icon helper actually does caching and tracks
changes.
2015-12-02 00:29:29 +01:00
Benjamin Otte
29cdb2001c iconhelper: Don't include gtk.h 2015-11-25 16:32:39 +01:00
Benjamin Otte
4843925660 iconhelper: Remove unused function 2015-11-25 16:32:39 +01:00
Benjamin Otte
2a8e6619a7 iconhelper: Remove unused context argument
Various functions don't use the style context.
2015-11-25 16:32:39 +01:00
Benjamin Otte
5cffbed165 iconhelper: Don't pass GENERIC_FALLBACK flag
It's not used when looking up with a GIcon.
2015-10-28 19:44:26 +01:00
Benjamin Otte
b6bf982289 iconhelper: Track icon-name fallback usage in the GIcon
Passing GTK_ICON_LOOKUP_GENERIC_FALLBACK to the icon lookup doesn't work
for GIcons, so we have to make sure we use the right GThemedIcon.

Fixes image-icon-name-use-fallback reftest.
2015-10-08 14:44:38 +02:00
Matthias Clasen
ddf7501acd More of the same
A similar case in GtkIconHelper. Here we were confusing ourselves,
and compared a icon_size against -1, although the variable is
never set to -1.
2015-03-22 15:14:42 -04:00
Benjamin Otte
49881eebbb Revert "iconhelper: Don't check states"
This reverts commit 63f59dde3a.

It turns out, the state was not just necessary for style computation,
but also for tracking RTL and LTR. And so it broke the reftests.
2015-03-12 04:31:45 +01:00
Benjamin Otte
7ad203732f iconhelper: Use the screen's icon theme
... and not the default one.
2015-03-12 01:15:38 +01:00
Benjamin Otte
93f8966bd9 iconhelper: Replace function
The old one just calls the other one.
2015-03-12 01:15:38 +01:00
Benjamin Otte
181e58e402 iconhelper: Move function from style context into only user 2015-03-12 01:15:38 +01:00
Benjamin Otte
63f59dde3a iconhelper: Don't check states
This is the wrong thing to do in today's world.
2015-03-12 01:15:38 +01:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Alexander Larsson
928822f1a5 GtkIconHelper: Short circuit _gtk_icon_helper_get_size in some cases
_gtk_icon_helper_get_size() is often used during size request and may
not necessary mean that the icon will be displayed immediately. In
many common cases we know the size without having to ensure a surface.
In many cases this means we can avoid loading an icon until needed, and
in the case of stateless IconHelpers such as GtkCellRendererPixbuf this
is very important as otherwise it will constantly be reloading icons
if the displayed set is larger than the in-memory icon cache.

https://bugzilla.gnome.org/show_bug.cgi?id=734651
2014-08-12 15:47:42 +02:00
Cosimo Cecchi
09a36b1e9f iconhelper: reset original pixbuf scale on clear
Avoids a previously set value for a different image to accidentally
stick around.

https://bugzilla.gnome.org/show_bug.cgi?id=733416
2014-07-29 10:13:21 +02:00
Matthias Clasen
6d83b173df GtkIconHelper: use FORCE_SCALE when force_scale_pixbuf is set
When force_scale_pixbuf is set, the icon helper will scale the
icon to the requested size (either the pixel size, or the resolved
icon size), so we can just as well instruct the icon theme code
to do the scaling for us.
2014-06-22 11:52:11 -04:00