Commit Graph

60604 Commits

Author SHA1 Message Date
Benjamin Otte
f7a5dd7b8b icontheme: Remove contexts
There is no way to query contexts or do anything useful with them.

So don't keep track of them and don't make them an argument in public
APIs with the docs saying "I don't know what to use here, maybe read
some spec somewhere".
2020-02-04 16:51:54 +01:00
Benjamin Otte
544cd1acfc icontheme: Clean up includes 2020-02-04 16:43:59 +01:00
Benjamin Otte
4b96ba592f icontheme: Remove gtk_icon_get_base_size() and gtk_icon_get_base_dir()
Those functions are unused and the documentation says "Returns some
random number that the icon theme creator chose" which does not seem at
all useful and an implementation detail.

So get rid of it.
2020-02-04 16:43:59 +01:00
Benjamin Otte
7e8d8218b9 Revert "Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()"
We're not in the business of adding Cairo APIs. That's Cairo's job.

Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.

This reverts commit afa6cc2369.
2020-02-04 16:43:59 +01:00
Benjamin Otte
3bba52ed67 icontheme: Remove crayon APIs
We expose no API to get at any colors for drawing symbolics, so we
shouldn't have APIs to draw with them.

Apart from that, those APIs look like a box of crayons, not like an
icontheme.
2020-02-04 16:43:59 +01:00
Benjamin Otte
48b9791989 icontheme: Remove gtk_icon_theme_rescan_if_needed()
If the icon theme needs to be rescanned, it should just do it.
If it doesn't, there's no need for this function.

Ergo: Don't have the function.
2020-02-04 16:43:59 +01:00
Benjamin Otte
4c3363b8c2 icontheme: Remove NO_SVG and FORCE_SVG flags
If the icon theme loads SVGs or not is an implementation detail and
should not be exposed in public API.
2020-02-04 16:41:36 +01:00
Benjamin Otte
10023b5d6d icontheme: Remove GTK_ICON_LOOKUP_USE_BUILTIN
It's unused.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bbbe39fb44 icontheme: Make text direction a lookup argument
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.
2020-02-04 16:41:36 +01:00
Benjamin Otte
b713b9f68d icontheme: Remove async APIs
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.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bfebc2b01a icontheme: Remove gtk_icon_theme_get_default()
The API encouraged wrong usage - most of the users were indeed wrong.

Use the correct version instead:
  gtk_icon_theme_get_for_display (gtk_widget_get_display ())
2020-02-04 16:41:36 +01:00
Matthias Clasen
b8ffe5b245 css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
2020-02-04 12:19:23 +01:00
Matthias Clasen
4685fe1716 Merge branch 'faster-theme-lookup' into 'master'
Faster icon theme lookup

See merge request GNOME/gtk!1381
2020-02-04 10:51:27 +00:00
Alexander Larsson
046de4ccbf icon-theme: Only have one copy of the icon flags enum
It turns out with the icon cache now using the virtual SYMBOLIC_PNG_SUFFIX
flag the two enums are now identical, so lets just use one of them, the
one GtkIconCache (so we move it to the header).
2020-02-04 09:35:20 +01:00
Alexander Larsson
308d434b57 GtkIconCache: Remove unused code
We're not really using the icon theme cache much anymore, as the
individual per-directory hashes are no longer used, so delete all the
unused code.
2020-02-03 12:49:32 +01:00
Alexander Larsson
e4170661b9 IconTheme: Make icon lookups faster
Traditionally the icon lookup for a theme has been:

lookup (icon_name, size):
  best_directory = NULL
  forearch theme
    foreach directory in theme
       if dir_size_matches (directory, size) && dir_has_icon (directory, icon-name)
         best_directory = chose_best_size_dir (best_directory, directory)

if best_directory
  return icon from best_directory

However, it turns out that there are a lot of subdirectories which have the same
size, as they differ only in the (essentially useless) "context" value. For example
the "16x16/apps" subdirectory is essentially the same as the "16x16/actions" one.

So, instead rathern than keeping all the directories as separate we store the
all the directories with the same size as a single entity (DirSize) and the
icon lookup in that DirSize looks up not only which suffix to use for that icon
but also which subdir it is in.

Additionally we keep a hashtable with all icon names that are
available in the entire theme (i.e. all DirSizes), which allows use
both to store each icon name only once, but also to do a quick
negative lookup and early exit in case we're looking up an icon that
doesn't exist. This is pretty common because we often look up sets of
icons like "image-png-symbolic", "image-png", "image", expecting some
to fail.

This brings down the time of the initial css validation from 20msec to 15msec for
me when running icon-factory.
2020-02-03 12:49:26 +01:00
Alexander Larsson
0a8d7603ea icon-cache: Add new function to list all the icons in a directory
This lists the icons in a particular director, with their flags in a
hashtable. We also convert from "icon.symbolic" + SUFFIX_PNG to
"icon" + SUFFIX_SYMBOLIC_PNG.
2020-02-03 12:49:26 +01:00
Rico Tzschichholz
4ab12ab755 Remove last GtkWidgetPath reference
See 49b47c9133
2020-02-03 10:51:50 +01:00
Matthias Clasen
e7f2833703 Merge branch 'wip/muktupavels/update-documentation' into 'master'
display-x11: don't mention gdk_monitor_is_primary in the docs

See merge request GNOME/gtk!1380
2020-02-03 08:15:30 +00:00
Alberts Muktupāvels
66af531ff3 display-x11: don't mention gdk_monitor_is_primary in the docs
https://gitlab.gnome.org/GNOME/gtk/merge_requests/1371#note_699272
2020-02-02 19:18:22 +02:00
Matthias Clasen
621120d1d3 css: Fix an oversight in style change computation
Take the 'color == NULL means currentColor' trick into account
when computing the changes between two styles.
2020-02-02 16:41:14 +01:00
Matthias Clasen
f84fdfc0c1 Merge branch 'sigma' into 'master'
gdk: Handle small final sigma in gdk_keyval_convert_case

See merge request GNOME/gtk!1351
2020-02-02 12:04:09 +00:00
Matthias Clasen
27223f7956 Merge branch 'initial-style' into 'master'
Make it easy to recognize initial style values

See merge request GNOME/gtk!1375
2020-02-01 12:52:44 +00:00
Matthias Clasen
5faf977f66 border: Don't render initial borders
Add a fast exist for comon case that the border
values are unset.
2020-02-01 09:12:12 +01:00
Matthias Clasen
7fbb37a09f background: Don't render initial backgrounds
Add a fast exit for the common case that the background
values are unset.
2020-02-01 09:11:39 +01:00
Matthias Clasen
7027fc9ab6 Make it easy to recognize initial style values
Reuse the type field in GtkCssValues to make initial
style values easily recognizable.
2020-02-01 09:11:22 +01:00
Matthias Clasen
7479564972 modelbutton: Update a11y states
We took care to set the proper role on our accessible object,
but we forgot to update the state for check and radio button
roles.
2020-01-31 19:14:05 +01:00
Matthias Clasen
09612a1b3c filechooser: Remove debug spew 2020-01-31 16:55:01 +01:00
Matthias Clasen
6104c12392 Build fix for GtkCssValues 2020-01-31 11:40:06 +01:00
Jor Teron
0c5ba00d59 Update Karbi translation 2020-01-31 10:15:03 +00:00
Daniel Mustieles
9f55377b69 Updated Spanish translation 2020-01-31 09:09:43 +01:00
Matthias Clasen
f140b151e1 Merge branch 'meson-sassc-subproject' into 'master'
build: require sassc and drop generated .css files

See merge request GNOME/gtk!814
2020-01-31 07:26:48 +00:00
Matthias Clasen
c91c4b60e7 Merge branch 'kill-primary-monitor-2' into 'master'
Remove primary monitor api

See merge request GNOME/gtk!1371
2020-01-30 20:51:07 +00:00
Matthias Clasen
a46f9af1c0 Remove primary monitor api
We only have implementations of this on X11 and Win32,
so make it available as backend api there.

Update all callers to use either the backend api, or
just monitor 0.
2020-01-30 21:33:37 +01:00
Christoph Reiter
4071e1e734 build: require sassc and drop generated .css files
Instead of requiring sassc to be installed add meson subprojects
which build libsass and sassc (currently both forks of mine, tested
under linux/mingw/msvc) when needed.

This allows us to drop the generated .css files and build scripts from git.

See #1502
2020-01-30 20:45:38 +01:00
Alexander Larsson
99c89d61e1 Merge branch 'icon-theme-rework' into 'master'
Rework icon themes

See merge request GNOME/gtk!1368
2020-01-30 17:30:10 +00:00
Alexander Larsson
09ef67afbc icon-theme: Add icon theme name in profiler mark 2020-01-30 18:22:11 +01:00
Alexander Larsson
d478ae1ef5 icon-theme: Avoid reentrancy issues while loading icon theme
In gtk_icon_theme_get_for_display() we were calling
gtk_icon_theme_set_display() which eventually (via the css machinery)
called back into gtk_icon_theme_get_for_display() which created a
second icon theme. We avoid this by setting the user-data earlier so
that the css machinery gets back the currently initializing theme
instead.
2020-01-30 18:19:56 +01:00
Alexander Larsson
b67d582230 GtkIconHelper: Preload icons for mapped widgets with higher priority
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.
2020-01-30 15:41:24 +01:00
Alexander Larsson
498ab6ac6c IconHelper: Only preload icons once
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.
2020-01-30 15:17:59 +01:00
Alexander Larsson
c69327caa8 icon-theme: Show which icon loads are threaded in profile mark 2020-01-30 15:16:40 +01:00
Alexander Larsson
d1cd578d59 icon-theme: Add i/o priority to choose_icon_async()
This is set on the GTask and lower priority will be loaded before,
this can be used to prioritize some icons for preloading.
2020-01-30 15:15:08 +01:00
Alexander Larsson
5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson
27799ba4f5 Remove final references to "icon info" with just "icon" 2020-01-30 10:53:43 +01:00
Alexander Larsson
2ec51b7010 icon-theme: Update the docs 2020-01-30 10:53:43 +01:00
Alexander Larsson
f7cd2a782b Fix warnings in gdk gir build
We now have graphene arguments in a gdk function, so add that to the
dependencies.
2020-01-30 10:53:43 +01:00
Alexander Larsson
ff0642bba6 icon-theme: Remove trailing whitespaces
Since everything is changing anyway lets just clean up all the
trailing whitespace issues in the whole file.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b227a2f190 icon-theme: Use GtkSnapshot, not GdkSnapshot 2020-01-30 10:53:43 +01:00
Alexander Larsson
2b202129bb icon-theme: Fix indentation of matrix values 2020-01-30 10:53:43 +01:00
Alexander Larsson
d1c6d78ebb GtkImage: Preload icons during css validation
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.
2020-01-30 10:53:43 +01:00