Commit Graph

511 Commits

Author SHA1 Message Date
Matthias Clasen
e190b4536a Drop another use of icon_file 2019-10-18 08:53:23 -05:00
Matthias Clasen
c3de5e3624 Avoid a use of icon_file
This is a step towards getting rid of GtkIconInfo->icon_file.
2019-10-18 08:53:23 -05:00
Matthias Clasen
dd69bcabf7 icon theme: Start to untangle GtkIconInfo
GtkIconInfo contains too much redundant data,
and it is hard to know which fields are to be
used when.

This commit starts to move towards dropping the
icon_file field - we prefer to work with the
filename directly, since it lets us avoid mime
sniffing and strdups.
2019-10-18 08:53:23 -05:00
Matthias Clasen
6373ced608 Drop gtk_icon_theme_get_example_icon_name
This function is not useful. Every icon theme
on my system either does not have that field,
or has it as 'folder'. So, just use 'folder'
when you need an example icon.
2019-10-18 08:53:23 -05:00
Matthias Clasen
2ea95a7674 Drop gtk_icon_theme_list_contexts
Contexts in icon themes are not useful for anything.
2019-10-18 08:53:23 -05:00
Matthias Clasen
233d096261 icon theme: Avoid a string copy
This is in an error path, so mostly cosmetic.
2019-10-18 08:53:23 -05:00
Matthias Clasen
8a603ff5bd Revert "icon theme: Avoid a string copy"
This reverts commit 0895f0211e.

This negatively affected icons that are included as
resources, since peek_path returns NULL for them.
2019-10-17 07:16:30 -05:00
Matthias Clasen
0895f0211e icon theme: Avoid a string copy
GIO has gained a way to peek at a GFile
path; lets use that.
2019-10-15 19:44:26 -04:00
Matthias Clasen
be13a23722 icon theme: Avoid mime sniffing
Themed icons are always pngs or svgs.
Take advantage of that to avoid costly
mime sniffing.
2019-10-15 19:44:26 -04:00
Benjamin Otte
6769db160d icontheme: Don't try to scale pixbufs to 0px
Always insist on at least 1px, even if the thumbnail we're turning into
an icon was 256 * 3 and should be scaled to 32 * 3/8.
2019-10-07 04:49:50 +02:00
Timm Bäder
0603b4431a icontheme: Stop using a private struct
The GtkIconTheme/GtkIconInfo structs aren't public anymore, so use the
structs directly instead of a priv pointer.
2019-09-09 17:36:27 +02:00
Timm Bäder
5f48f60a93 Icontheme: Clean up gtk_icon_info_load_async 2019-09-09 17:36:27 +02:00
Timm Bäder
32cec6c1cb icontheme: Adapt a code sample to the GdkPaintable transition 2019-09-09 17:36:27 +02:00
Timm Bäder
6a8921ec6b icontheme: Remove symbolic pixbuf cache
We recolor icons on via color matrix nodes these days, so this cache is
basically unused.
2019-09-09 17:36:27 +02:00
Timm Bäder
53132d0235 icontheme: Add LRU cache back
Add a cache of icon infos that we keep around a little longer, to avoid
loading icons from disk that only exist for a short amount of time (e.g.
during one frame of a cell renderer snapshot).

We make sure recently used items are kept alive by just adding them to
the cache on lookup.
2019-09-09 17:36:27 +02:00
Timm Bäder
32bed34935 icontheme: Remove GtkIconInfo->pixbuf
Create textures as soon as possible.
2019-09-09 17:36:26 +02:00
Timm Bäder
1873b38a94 icontheme: Remove icon_info_load_pixbuf
What it does overlaps with the only caller a lot now.
2019-09-09 17:36:26 +02:00
Timm Bäder
38b4a2a8e2 icontheme: Optimize suffix_from_name
We call this function a lot, so avoid repeated strlen() calls on @name
and the different suffixes.
2019-09-09 17:36:26 +02:00
Timm Bäder
b65d9ca955 icontheme: Avoid creating useless IconThemeDirs
We were allocating IconThemeDir instances and then only later assign a
value to has_icons. In the !has_icons case, we were directly throwing
the IconThemeDir away again.

Delay allocating the IconThemeDirs until we know that it has icons.
This avoids allocating and then de-allocating around 1400 IconThemeDir
instances when opening the widget-factory.
2019-09-09 17:36:26 +02:00
Timm Bäder
0b472c23d7 icontheme: Inline scan_resources into only caller
The previous code was hiding the fact that the scan_resources function
almost always did nothing and just used g_resources_enumerate_children()
and then returned FALSE, leaving the caller with cleaning up the already
allocated IconThemeDir. By inlining this, we make sure that calling code
does not even need to allocate the IconThemeDir.
2019-09-09 17:36:26 +02:00
Timm Bäder
bb89ee184f icontheme: Remove proxy pixbufs
These were only used for the LRU cache.
2019-09-09 17:36:26 +02:00
Timm Bäder
eb087c9943 icontheme: Remove lru cache
We will replace it with something else later
2019-09-09 17:36:26 +02:00
Timm Bäder
eeec6f8fb9 icontheme: Annotate return value as nullable 2019-09-09 17:36:26 +02:00
Timm Bäder
71339225eb icontheme: Remove gtk_icon_info_load_texture
It's the same as load_icon now.
2019-09-09 17:36:26 +02:00
Timm Bäder
590e70d4d1 icontheme: Return a paintable from gtk_icon_info_load_icon 2019-09-09 17:36:26 +02:00
Timm Bäder
fd16ac4d5e icontheme: Return paintables from more API 2019-09-09 17:36:26 +02:00
Timm Bäder
f3099afcc5 icontheme: Return textures from load_icon{,_for_scale} 2019-09-09 17:36:26 +02:00
Timm Bäder
e0fe2882ad icontheme: Don't try to scale pixbufs to same size 2019-09-09 17:36:26 +02:00
Timm Bäder
2ffbb37783 icontheme: Annotate return value of load_icon as nullable
It returns NULL in the error case.
2019-09-09 17:36:26 +02:00
Timm Bäder
6821fe0c13 icontheme: Add error argument to _load_texture
Loading an icon might fail.
2019-09-09 17:36:26 +02:00
Timm Bäder
a0947232fa icontheme: optimize icon_uri_is_symbolic as well 2019-09-09 17:36:26 +02:00
Timm Bäder
d98e05b91a icontheme: Save the min_suffix for the min_dir
We already have to compute that value in the loop before, so just save
it.
2019-09-09 17:36:26 +02:00
Timm Bäder
fa85f4fc2e icontheme: Remove use_builtin parameter from theme_lookup_icon
Unused.
2019-09-09 17:36:26 +02:00
Timm Bäder
44352b375e icontheme: Remove paramter from get_icon_suffix
Turns out nobody care about that one.
2019-09-09 17:36:26 +02:00
Timm Bäder
ebe88ea322 icontheme: Optimize icon_name_is_symbolic
We call this function *a lot* it's doing lots of unnecessary work inside
g_str_has_suffix. Get the icon name length only once instead and
open-code the suffix check.
2019-09-09 17:36:26 +02:00
Timm Bäder
6d77723fe0 gtkicontheme: Avoid a get_icon_flags call
We're only using the value of the first call at all if
symbolic_suffix & ICON_SUFFIX_PNG is FALSE.
2019-09-09 17:36:26 +02:00
Timm Bäder
c5ed51a188 icontheme: Remove outdated comment
It's not called css_fg anymore and it can't possibly be NULL since we
make sure before passing it here.
2019-09-09 17:36:25 +02:00
Дилян Палаузов
6ded38de2b Minor typos in the Documentation (a/an) 2019-08-25 12:52:46 +00:00
Jonas Ådahl
048957cd49 gtk/icon-theme: Handle lack of SVG loader gracefully
When loading a SVG icon from a gresource file only containing SVG icons,
but without having a SVG loader available in gdk-pixbuf, we would crash
when trying to eventually load the resource. Fix this by gracefully
handling this by simply failing to load the icon, while the first time
it happens, log a warning.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2084
2019-08-08 09:05:30 +02:00
Christian Hergert
f507a79056 marshallers: ensure g_cclosure_marshal_VOID__VOIDv is used
If we set c_marshaller manually, then g_signal_newv() will not setup a
va_marshaller for us. However, if we provide c_marshaller as NULL, it will
setup both the c_marshaller (to g_cclosure_marshal_VOID__VOID) and
va_marshaller (to g_cclosure_marshal_VOID__VOIDv) for us.
2019-05-29 13:22:31 -07:00
Matthias Clasen
96eefd49fa icon theme: Make final
Nobody should subclass GtkIconTheme or GtkIconInfo.
2019-05-26 15:33:10 -04:00
Matthias Clasen
4df2a4c82c icon theme: Remove fallbacks
We want to include all needed icons as resources,
so disable the fallbacks and see what comes up.
2019-02-12 17:34:43 -05:00
Emmanuele Bassi
25fd230327 gtk: Drop the "plus"
Source names should use "[gtk]" without the plus.
2019-02-05 11:26:20 +01:00
Luca Bacci
a52989842e Win32: Fix typo on compilation speedup macro define
There is a typo, the correct macro to define is WIN32_LEAN_AND_MEAN.
After this change <shellapi.h> must be included in order to use
ExtractIconExW().
2018-12-22 01:18:17 +01:00
Philip Chimento
284d909347 icontheme: Recolor <polygon> elements in SVGs too
Otherwise, it's possible to have a symbolic icon where some of the
shapes keep the #bebebe chroma key color.
2018-12-08 01:40:32 +00:00
Federico Mena Quintero
e5f9bf2e9b (#1471): base64-encode included SVGs to avoid mis-escaped characters
We wrap SVG data from icons within another SVG with extra styling
information.  The wrapped SVG may contain characters that cannot be
part of a data: URL (https://fetch.spec.whatwg.org/#data-urls).

Librsvg 2.45 got more strict in its parsing of data: URLs; whereas
previously it ignored '#' characters in them, now it considers them to
be the start of a fragment identifier, which is not allowed in data:
URLs anyway.

To avoid unallowed characters, we now create a data: URL with a
base-64 encoded SVG.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1471
2018-11-27 13:57:21 -06:00
Timm Bäder
797739198f icontheme: Stop exporting gtk_icon_info_new_for_file 2018-11-08 05:48:14 +01:00
Timm Bäder
0c017ff109 icontheme: Stop exporting gtk_icon_theme_color_symbolic_pixbuf 2018-11-08 05:48:14 +01:00
Timm Bäder
aad3686726 icontheme: Drop remaining emblem code 2018-11-08 05:48:14 +01:00
Timm Bäder
fe7a2635d0 icontheme: Don't reference nonexistent parameter in docs 2018-11-08 05:48:14 +01:00
Timm Bäder
2834b38d2c icontheme: Use a bit field in AsyncSymbolicData
176 -> 144 bytes
2018-11-08 05:48:14 +01:00
Timm Bäder
29563a33ba icontheme: Stop strdup'ing css colors when loading
... symbolic icons.
2018-11-08 05:48:10 +01:00
Jehan
04367acf9b gtk: also recolor circle and ellipse in symbolic SVG icons. 2018-06-23 00:35:17 +02:00
Jan Alexander Steffens (heftig)
1e06838c1c
icontheme: Keep dir_mtimes in order
Don't reverse the order each time we insert a theme. Reverse it only
once, after all themes have been loaded.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1115
2018-05-23 20:06:01 +02:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Benjamin Otte
af18796312 icontheme: Remove surface support
It's not used anymore.
2018-03-16 06:04:45 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Emmanuele Bassi
334acbfc39 Replace gdk_threads_add_idle* with g_idle_add()
The main GDK thread lock is not portable and deprecated.

The only reason why gdk_threads_add_idle() and
gdk_threads_add_idle_full() exist is to allow invoking a callback with
the GDK lock held, in case 3rd party libraries still use the deprecated
gdk_threads_enter()/gdk_threads_leave() API.

Since we're removing the GDK lock, and we're releasing a new major API,
such code cannot exist any more; this means we can use the GLib API for
installing idle callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:06:58 +01:00
Emmanuele Bassi
a379ddefc3 Remove leading underscore from private symbols
There's no need to do that any more, as only explicitly annotated
symbols are exported.
2018-02-01 16:05:58 +01:00
Emmanuele Bassi
e090c1f1a9 Rename gtkiconcache.h
The gtkiconcache.h header is private, so rename it to follow the naming
scheme for private headers.
2018-02-01 15:34:57 +01:00
Matthias Clasen
461d05f643 icon theme: Make logging per-display
As far as possible, for now. This needs some more
work to cover all locations.
2018-01-14 17:05:04 -05:00
Matthias Clasen
c088d69f93 icon theme: Remove unused code
The deprecated api to add builtin icons was removed
a year ago, so we don't need the code anymore that deals
with looking up builtin icons.
2017-11-29 22:25:57 -05:00
Matthias Clasen
0d23606653 Drop gtk_icon_size_lookup
Add a new, private gtk_image_get_image_size to replace it, and
update the remaining callers in a suitable way.
2017-11-15 14:22:17 -05:00
Matthias Clasen
2301d8d90b enums: Change GtkIconSize values
The new values are the ones we intend to keep. The old ones had
duplicated meanings and nobody knew which one to take.
2017-11-15 14:22:17 -05:00
Matthias Clasen
724863c275 icontheme: Add a trailing / when enumerating resources
This avoids extra string copies in GResource.
2017-11-13 12:13:42 -05:00
Matthias Clasen
ec1ea0db04 icontheme: Append a / to the resource path
g_resources_enumerate_children expects the path to end
in a '/' (even though thats not stated in the docs), and
will copy it if that isn't the case. Avoid the copy
by putting  a '/' there to begin with.
2017-11-13 07:33:35 -05:00
Matthias Clasen
1da7dc890c Make the recoloring code more robust
Pass both width+height and scale, so we can handle the case
where width+height are zero and we are using the file, scaled.
2017-11-07 21:27:38 -05:00
Matthias Clasen
284fd36e5d Fix symbolic.svg rendering
With the shader approach to symbolic recoloring, we must
not recolor the svgs anymore as we're loading them. Instead,
load them the same way that gtk-encode-symbolic-svg does.

This fixes the rendering of large symbolic icons e.g. the
'no search results found' page in the file chooser.
2017-11-07 18:56:32 -05:00
Benjamin Otte
8d849458ac docs: You can't modify textures
So there's no need to tell people they must not do that.
2017-11-05 00:07:17 +01:00
Benjamin Otte
ca3c23662c GskTexture => GdkTexture
We want this thing to replace GdkPixbuf, so it has to live in GDK.
2017-11-04 00:07:13 +01:00
Benjamin Otte
3967072c66 docs: Fix up some places that still said screen instead of display 2017-10-31 08:25:37 +01:00
Benjamin Otte
ecd5b399a4 icontheme: Use GdkDisplay instead of GdkScreen 2017-10-31 03:05:55 +01:00
Benjamin Otte
9151e0b9f5 stylecontext: Port to use display instead of screen 2017-10-31 03:05:54 +01:00
Timm Bäder
134ba2ebf7 icontheme: Silence some compiler warnings 2017-10-23 14:23:52 +02:00
Matthias Clasen
02db8ccd89 icon theme: Add a texture cache
Return cached textures for icons. This lets us avoid duplicate
texture uploads for icons whose surfaces we already cache.
2017-10-23 08:07:35 +02:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Robert Ancell
7b8ea9af55 icon-theme: Show filename attempted when icon fails to load 2017-06-09 09:24:02 +12:00
Piotr Drąg
a2da4ddceb Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772371
2016-12-19 15:08:10 -05:00
Timm Bäder
d188912338 icontheme: Remove deprecated API 2016-10-22 19:08:29 +02:00
Emmanuele Bassi
a9bcd05a14 icontheme: Simplify lookup_size()
No need to use an internal function, and no need to store the icon size
id, since we're using the id as the offset.
2016-10-19 14:04:00 +01:00
Ignacio Casal Quinteiro
a12b691b76 gtkicontheme: check if the context quark string is not null
On windows you might not have a theme installed by default which
means that when trying to create the context quark it will fail.
If then we try to replace a NULL key in the hash table it will crash.

https://bugzilla.gnome.org/show_bug.cgi?id=769859
2016-10-17 13:04:31 +02:00
Emmanuele Bassi
39e848c0eb icontheme: Drop unnecessary allocation
Use a static array for the known icon sizes, now that we don't allow
registering custom icon sizes any more. This allows us to cut a one-off
allocation that makes Valgrind sad.
2016-10-17 11:44:11 +01:00
Emmanuele Bassi
44885bcfed Remove redundant declarations 2016-10-17 11:10:14 +01:00
Timm Bäder
ed184b3935 Remove GtkIconFactory
Move the icon size lookup API into gtkicontheme.c
2016-10-16 18:17:21 +02:00
Benjamin Otte
0df388051d API: Remove GtkStyle
All the remaining gtkrc.c stuff like GtkRcStyle goes with it.
2016-10-16 18:17:21 +02:00
Benjamin Otte
9a5de96187 API: Remove GtkNumerableIcon 2016-10-16 18:17:21 +02:00
Victor Toso
9701b58c4e icon-theme: Fix leaks on error
13 bytes in 1 blocks are definitely lost in loss record 766 of 16,875
   at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
   by 0xA9D0247: vasprintf (in /usr/lib64/libc-2.24.so)
   by 0xA2453FC: g_vasprintf (gprintf.c:316)
   by 0xA2152F7: g_strdup_vprintf (gstrfuncs.c:514)
   by 0xA21539C: g_strdup_printf (gstrfuncs.c:540)
   by 0x678F25C: gdk_rgba_to_string (gdkrgba.c:360)
   by 0x5FAE00D: rgba_to_string_noalpha (gtkicontheme.c:4322)
   by 0x5FAE6F2: gtk_icon_info_load_symbolic_svg (gtkicontheme.c:4492)
   by 0x5FAED4F: gtk_icon_info_load_symbolic_internal (gtkicontheme.c:4622)
   by 0x5FAEEE8: gtk_icon_info_load_symbolic (gtkicontheme.c:4711)
   by 0x5F00246: gtk_css_image_recolor_load (gtkcssimagerecolor.c:118)
   by 0x5F003E4: gtk_css_image_recolor_compute (gtkcssimagerecolor.c:170)

14 bytes in 1 blocks are definitely lost in loss record 801 of 16,875
   at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
   by 0xA9D0247: vasprintf (in /usr/lib64/libc-2.24.so)
   by 0xA2453FC: g_vasprintf (gprintf.c:316)
   by 0xA2152F7: g_strdup_vprintf (gstrfuncs.c:514)
   by 0xA21539C: g_strdup_printf (gstrfuncs.c:540)
   by 0x678F25C: gdk_rgba_to_string (gdkrgba.c:360)
   by 0x5FAE00D: rgba_to_string_noalpha (gtkicontheme.c:4322)
   by 0x5FAE68E: gtk_icon_info_load_symbolic_svg (gtkicontheme.c:4482)
   by 0x5FAED4F: gtk_icon_info_load_symbolic_internal (gtkicontheme.c:4622)
   by 0x5FAEEE8: gtk_icon_info_load_symbolic (gtkicontheme.c:4711)
   by 0x5F00246: gtk_css_image_recolor_load (gtkcssimagerecolor.c:118)
   by 0x5F003E4: gtk_css_image_recolor_compute (gtkcssimagerecolor.c:170)

15 bytes in 1 blocks are definitely lost in loss record 838 of 16,875
   at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
   by 0xA9D0247: vasprintf (in /usr/lib64/libc-2.24.so)
   by 0xA2453FC: g_vasprintf (gprintf.c:316)
   by 0xA2152F7: g_strdup_vprintf (gstrfuncs.c:514)
   by 0xA21539C: g_strdup_printf (gstrfuncs.c:540)
   by 0x678F25C: gdk_rgba_to_string (gdkrgba.c:360)
   by 0x5FAE00D: rgba_to_string_noalpha (gtkicontheme.c:4322)
   by 0x5FAE6C3: gtk_icon_info_load_symbolic_svg (gtkicontheme.c:4487)
   by 0x5FAED4F: gtk_icon_info_load_symbolic_internal (gtkicontheme.c:4622)
   by 0x5FAEEE8: gtk_icon_info_load_symbolic (gtkicontheme.c:4711)
   by 0x5F00246: gtk_css_image_recolor_load (gtkcssimagerecolor.c:118)
   by 0x5F003E4: gtk_css_image_recolor_compute (gtkcssimagerecolor.c:170)

16,384 bytes in 1 blocks are definitely lost in loss record 16,847 of 16,875
   at 0x4C2DADE: malloc (vg_replace_malloc.c:298)
   by 0x4C2FC91: realloc (vg_replace_malloc.c:785)
   by 0xA1F89FA: g_realloc (gmem.c:159)
   by 0xA1BAD2E: g_array_maybe_expand (garray.c:779)
   by 0xA1BA566: g_array_set_size (garray.c:555)
   by 0xA1BBCB8: g_byte_array_set_size (garray.c:1752)
   by 0x8D1CC48: g_file_load_contents (gfile.c:6766)
   by 0x5FAE767: gtk_icon_info_load_symbolic_svg (gtkicontheme.c:4501)
   by 0x5FAED4F: gtk_icon_info_load_symbolic_internal (gtkicontheme.c:4622)
   by 0x5FAEEE8: gtk_icon_info_load_symbolic (gtkicontheme.c:4711)
   by 0x5F00246: gtk_css_image_recolor_load (gtkcssimagerecolor.c:118)
   by 0x5F003E4: gtk_css_image_recolor_compute (gtkcssimagerecolor.c:170)

https://bugzilla.gnome.org/show_bug.cgi?id=772215
2016-09-30 14:20:01 -04:00
Rico Tzschichholz
a3f1596069 Add some missing (nullable) annotations
https://bugzilla.gnome.org/show_bug.cgi?id=771826
2016-09-22 14:02:07 +02:00
Matthias Clasen
de7c15636d icon theme: Add a warning
Warn about the situation when we've found a resource or file path,
but gdk-pixbuf fails to give us a pixbuf. This generally means that
either pixbuf loaders are not found or the shared-mime database
is missing.
2016-05-19 09:03:20 -04:00
Matthias Clasen
d1acb786a7 icon theme: Make the builtin hicolor index match reality
We were missing all of the status directories, and a few sizes.
This was causing us to not find image-missing on systems without
hicolor icon theme (this basically only happens on Windows).

https://bugzilla.gnome.org/show_bug.cgi?id=764378
2016-03-31 07:12:50 -04:00
Matthias Clasen
2ee7fb1818 Don't use g_print for debug output
The g_print documentation explicitly says not to do this, since
g_print is meant to be redirected by applications. Instead use
g_message for logging that can be triggered via GTK_DEBUG.
2016-02-28 21:40:23 -05:00
Matthias Clasen
bbd94b5a9f gtk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Matthias Clasen
e54549502e icontheme: Avoid a crash
gtk_icon_info_new_for_file with a size of 0 would fail for
symbolic pngs because we ended up scaling with 0. Avoid this.
2016-01-30 00:29:04 -05:00
Matthias Clasen
001598a821 icon theme: Improve loading of unthemed files
When creating icon info objects for unthemed files, we don't
really have a nominal size, so we pass 0 to mean 'load at
original size'. However, this is not what was happening.
To make this possible, add variants of some pixbuf loading
functions that take a scale factor instead of a desired size,
and use those when we don't have a nominal size.
2016-01-29 17:27:35 -05:00
Matthias Clasen
1b0ef71696 icon theme: Export recoloring function
This will be used in subsequent commits.

https://bugzilla.gnome.org/show_bug.cgi?id=760536
2016-01-14 13:51:09 -05:00
Matthias Clasen
7d717c8113 icon theme: Add a way to create GtkIconInfos from files
This is sometimes needed, and calling into actual icon theme
code just for it is confusing - the resulting icon does not
depend on the icon theme at all.

https://bugzilla.gnome.org/show_bug.cgi?id=760536
2016-01-14 13:50:58 -05:00
Alberto Ruiz
496f0892fc introspection: This patch fixes nullable return values fixes for the following symbols in gtk
gtk_accel_group_query
  gtk_accel_group_from_accel_closure
  gtk_accel_label_get_accel_widget
  gtk_accessible_get_widget
  gtk_actionable_get_action_name
  gtk_app_chooser_get_app_info
  gtk_app_chooser_button_get_heading
  gtk_app_chooser_dialog_get_heading
  gtk_application_get_window_by_id
  gtk_assistant_get_nth_page
  gtk_binding_set_find
  gtk_builder_get_object
  gtk_builder_lookup_callback_symbol
  gtk_builder_get_application
  gtk_button_get_image
  gtk_cell_area_get_focus_from_sibling
  gtk_cell_renderer_start_editing
  gtk_cell_view_get_model
  gtk_cell_view_get_displayed_row
  gtk_clipboard_get_owner
  gtk_container_get_focus_child
  gtk_container_get_focus_vadjustment
  gtk_container_get_focus_hadjustment
  gtk_dialog_get_widget_for_response
  gtk_drag_get_source_widget
  gtk_drag_dest_get_target_list
  gtk_drag_source_get_target_list
  gtk_entry_completion_get_model
  gtk_entry_completion_compute_prefix
  gtk_expander_get_label_widget
  gtk_file_chooser_get_filename
  gtk_file_chooser_get_current_folder
  gtk_file_chooser_get_uri
  gtk_file_chooser_get_current_folder_uri
  gtk_file_chooser_get_preview_widget
  gtk_file_chooser_get_preview_file
  gtk_file_chooser_get_preview_filename
  gtk_file_chooser_get_preview_uri
  gtk_file_chooser_get_extra_widget
  gtk_file_chooser_get_filter
  gtk_file_chooser_native_get_accept_label
  gtk_file_chooser_native_get_cancel_label
  gtk_file_filter_get_name
  gtk_font_chooser_get_font_family
  gtk_font_chooser_get_font_face
  gtk_font_chooser_get_font
  gtk_font_chooser_get_font_desc
  gtk_font_chooser_get_font_map
  gtk_frame_get_label
  gtk_gesture_get_device
  gtk_gesture_get_window
  gtk_gl_area_get_error
  gtk_header_bar_get_title
  gtk_header_bar_get_subtitle
  gtk_header_bar_get_custom_title
  gtk_icon_info_get_filename
  gtk_icon_view_get_path_at_pos
  gtk_icon_view_get_model
  gtk_image_get_pixbuf
  gtk_image_get_animation
  gtk_label_get_mnemonic_widget
  gtk_label_get_attributes
  gtk_check_version
  gtk_menu_button_get_popup
  gtk_menu_button_get_menu_model
  gtk_menu_button_get_align_widget
  gtk_menu_button_get_popover
  gtk_menu_item_get_submenu
  gtk_menu_item_get_accel_path
  gtk_native_dialog_get_title
  gtk_native_dialog_get_transient_for
  gtk_notebook_get_nth_page
  gtk_notebook_get_tab_label_text
  gtk_notebook_get_menu_label
  gtk_notebook_get_menu_label_text
  gtk_notebook_get_group_name
  gtk_notebook_get_action_widget
  gtk_offscreen_window_get_surface
  gtk_offscreen_window_get_pixbuf
  gtk_paned_get_child1
  gtk_paned_get_child2
  gtk_places_sidebar_get_location
  gtk_places_sidebar_get_nth_bookmark
  gtk_plug_get_socket_window
  gtk_popover_get_default_widget
  gtk_progress_bar_get_text
  gtk_recent_filter_get_name
  gtk_recent_manager_lookup_item
  gtk_settings_get_default
  gtk_socket_get_plug_window
  gtk_stack_sidebar_get_stack
  gtk_stack_switcher_get_stack
  gtk_style_context_get_section
  gtk_style_context_get_parent
  gtk_style_context_get_frame_clock
  gtk_test_find_widget
  gtk_text_buffer_get_mark
  gtk_text_tag_table_lookup
  gtk_text_view_get_tabs
  gtk_text_view_toggle_cursor_visible
  gtk_text_view_get_window
  gtk_toolbar_get_nth_item
  gtk_tool_button_get_label
  gtk_tool_button_get_icon_name
  gtk_tool_button_get_label_widget
  gtk_tool_button_get_icon_widget
  gtk_tool_palette_get_drop_item
  gtk_tool_palette_get_drop_group
  gtk_tree_model_filter_convert_child_path_to_path
  gtk_tree_model_filter_convert_path_to_child_path
  gtk_tree_model_sort_convert_child_path_to_path
  gtk_tree_model_sort_convert_path_to_child_path
  gtk_tree_view_get_column
  gtk_tree_view_get_bin_window
  gtk_tree_view_column_get_widget
  gtk_tree_view_column_get_tree_view
  gtk_widget_get_frame_clock
  gtk_window_group_get_current_device_grab
  GtkTextBufferSerializeFunc
2016-01-08 12:18:23 +00: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
7fa37e4bf8 css: Introduct -gtk-icon-palette
This borrows heavily from the CSS4 fonts draft's font-palette, currently
found at https://drafts.csswg.org/css-fonts-4/#font-palette-control

The palette is mainly meant to trigger invalidations when colors used for
symbolic icons change, to potentially allow extending supported colors
in symbolic icons and to recolor all colors of a symbolic icon, not just
the main one.

The syntax for the property goes like this:
Name:        -gtk-icon-palette
Value:       default | name <color> [ , name <color> ]*
Initial:     default
Applies to:  all elements with icons
Inherited:   yes
Animatable:  yes, each color animated separately

The property defines a list of named colors to be used when looking up
icons. If a name is not defined, the value of the current "color"
property is used. Which names are relevant depends on the icons in use.
Currently symbolic icons make use of the names "success", "warning" and
"error".

"default" is the current behavior of the GTK when coloring symbolic
icons and is equal to the string
  success @success_color, warning @warning_color, error @error_color

Animation is crudely implemented by animating colors that are in both
palettes that are animated and otherwise keeping the color from the
palette that defined it. Note that this can cause a sharp cut at the
beginning or end of the animation when the color goes away and will
therefore be replaced with the color property.

You can see an example of animations at
http://gfycat.com/CautiousPeacefulIaerismetalmark
2015-12-03 00:47:00 +01:00
Emmanuele Bassi
c1ecd1ef9d docs: Point at for_scale() variants
Using lookup_icon() and lookup_by_gicon() with a size multiplied by a
scaling factor is almost certainly going to get worse results than using
their for_scale() variants.
2015-11-04 11:50:37 +00:00
Benjamin Otte
8ec2362d81 icontheme: Clarify GENERIC_FALLBACK flag handling
- Add docs explaining that it doesn't work everywhere
- g_warn_if_fail() in the APIs where it doesn't work
2015-10-28 19:44:26 +01:00
Matthias Clasen
270e900f55 icon theme: Ensure to propagate an error
If the svg pixbuf loader is not available, we end up with criticals
from gtk_css_image_icon_theme_draw because gtk_icon_info_load_symbolic
returns NULL without setting an error.

Avoid this by propagating the load error.
2015-10-27 11:09:00 -04:00
Matthias Clasen
8ba55d80fc gtkicontheme: Check a return value
We were already looking at the error anyway, but rewriting things
this way lets coverity see the light.
2015-07-17 16:11:16 -04:00
Cosimo Cecchi
06df94ff7b icontheme: don't modify symbolic SVG dimensions when recoloring
When recoloring symbolic SVG, do not modify the original width and
height of the passed-in file; the function later will scale the image
through gdk_pixbuf_new_from_stream_at_scale(), but we should still
use the original size to create the proxy SVG, or the image will
possibly be doubly-resized or blurry.

https://bugzilla.gnome.org/show_bug.cgi?id=750605
2015-06-12 08:55:23 -07:00
Matthias Clasen
85b4eef004 icon theme: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:15 -04:00
Daniel Drake
aba2de3443 icontheme: allow directories with mtime 0
In order to provide a constant mtime between OS build and deploy time,
while also maintaining a hardlink content-addressed model independent of
timestamps, ostree sets all mtimes to 0.

The icon cache code currently ignores directories with mtime 0, assuming
they don't exist.

Track directory existence in a more precise way.

https://bugzilla.gnome.org/show_bug.cgi?id=745052
2015-02-23 15:09:15 -06:00
Cosimo Cecchi
eddaf01676 icontheme: use desired size instead of negative for DIR_UNTHEMED SVGs
When loading SVGs from ICON_THEME_DIR_UNTHEMED GtkIconInfos,
such as those created for a GLoadableIcon, the size of the pixbuf to
load is set as a product of icon_info->scale.
But a few lines above, icon_info->scale is set to -1 for
ICON_THEME_DIR_UNTHEMED GtkIconInfos, so we'll end up always passing a
negative size to the GdkPixbuf loader, which is interpreted as the
nominal size of the image file.
Instead load the SVG at the desired scaled size in that case.

This fixes blurry icon in the notification panel in gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=744991
2015-02-23 09:56:06 -08:00
Cosimo Cecchi
acd72ffabe icontheme: fill correct information when loading GResource-backed GIcons
When loading a GResource-backed GFileIcon into a GtkIconInfo we
currently fail to populate the is_resource private field.
Also, since is_svg is set by looking at the filename, and
g_file_get_path() returns NULL for a GResourceFile, is_svg was always
FALSE.

https://bugzilla.gnome.org/show_bug.cgi?id=744991
2015-02-23 09:56:06 -08:00
Matthias Clasen
48a41b0119 Reduce symbolic icon warnings to a debug message
These icons are out there in the wild, and the warning causes
distcheck to fail. So, reduce it to a debug message.
2015-01-31 14:32:17 -05:00
Kjell Ahlstedt
5d3aa54a8a docs: Explain 'icon theme context' better in gtkicontheme.c
Add links from gtk_icon_theme_list_contexts() to
gtk_icon_theme_list_icons(), and from there to the Icon Theme
Specification and the Icon Naming Specification.

https://bugzilla.gnome.org/show_bug.cgi?id=461249
2014-12-07 23:35:31 -05:00
Matthias Clasen
95e8ae6e75 GtkIconTheme: Improve an error message
Mention the name of the theme when an icon lookup fails.
https://bugzilla.gnome.org/show_bug.cgi?id=687963
2014-11-03 00:25:14 -05:00
Matthias Clasen
964c202c38 GtkIconTheme: Repair symbolic fallback with rtl/ltr
For symbolic icons, we prefer symbolics in inherited themes over
generic icons in the theme itself. So far this was implemented
by looking at icon_name[0] and looking that up in inherited themes
if it is symbolic. But with automatic rtl/ltr handling, the first
icon  name will always have an -rtl or -ltr suffix, and an icon
with that suffix is not going to exist in most cases. To fix this,
look for shorter icon names too, as long as they are still symbolic.

https://bugzilla.gnome.org/show_bug.cgi?id=737000
2014-09-21 14:49:22 -04:00
Matthias Clasen
1b858e4212 Trivial: clarify a comment
Using 'highcolor' here seems confusing, since there is a theme
by that name. Just say full-color.
2014-09-21 14:29:36 -04:00
Matthias Clasen
1629903943 GtkIconTheme: Make suffix_from_name NULL-safe
This can happen sometimes with GFileIcons that are
not representable as a local path. Better not to crash
in this case.
2014-09-05 13:15:14 -04:00
Alexander Larsson
afeb50009d Change way alpha is used when recoloring symbolics
If the foreground color has an alpha != 1 we used to just pass that into
the svg. This is useful to e.g. render an insensitive icon. However,
that is not an ideal model for symbolics. For instance, if the icon uses
overlapping areas when drawing, expecting these to be opaque then the
transparent color will result in a different alpha value for the overlapping
area. Also, non-foreground symbolic colors are still rendered opaque, and
the recoloring of pngs can't handle transparent colors.

So, instead we extract any alpha from the foreground, render using the
opaque colors and then apply the foreground alpha to the entire result.
This means we get an even transparency, even for other colors, and we
can apply alpha for the pngs too.

https://bugzilla.gnome.org/show_bug.cgi?id=734668
2014-08-12 15:51:36 +02:00
Alexander Larsson
1d68801ade icon-theme: Support recolorable .symbolic.png files
If an icon theme has a file called "foo-symbolic.symbolic.png" which
was converted from svg using gtk-encode-symbolic-svg we will read
it in an recolor, allowing symbolic icons without using librsvg.

https://bugzilla.gnome.org/show_bug.cgi?id=730450
2014-08-03 02:20:18 +02:00
Matthias Clasen
f3ef3165df GtkIconTheme: Make spinners scale in hi-dpi
The Adwaita icon theme ships spinners in a scalable directory
with MaxSize=32 and Scale=1. One way to make them scale up in
hi-dpi would be to add an @2 directory with MaxSize=32 and Scale=2,
but that directory would also be consulted in non hi-dpi situations
and give us an effective spinner max size of 64.

Instead, treat svg icons implicitly as hi-dpi, and scale them
up to MaxSize * 2 when in hi-dpi.
2014-07-17 00:59:34 -04:00
Руслан Ижбулатов
e3d725ed8c GktIconTheme: Be even more careful with paths
This is a followup for 5a252f13a8

https://bugzilla.gnome.org/show_bug.cgi?id=733189
2014-07-15 19:02:41 +00:00
Matthias Clasen
5a252f13a8 GktIconTheme: Be more careful with paths
Slapping file:// in front of a path does not guarantee a working
uri (e.g. if you are on windows and the path looks like F:\\...).
Therefore, go back to using g_file_new_for_path if we don't have
to deal with a resource.
2014-07-14 18:44:00 -04:00
Matthias Clasen
6abcda8391 Use a define for the default icon theme name
We're using this name in two places, so match what we are doing
for the default theme name, and use a macro.
2014-07-09 21:18:18 -04:00
Matthias Clasen
eee7057421 GtkIconTheme: Rename a macro
We use DEFAULT_THEME_NAME in gtksettings.c as well, and this
can be a confusing when grepping, so rename this to
FALLBACK_ICON_THEME.
2014-07-09 21:12:08 -04:00
Stefano Facchini
cd71a23ee2 icontheme: Use correct URI for icons in resource paths
Fix based on a patch by Stefano Faccini,
https://bugzilla.gnome.org/show_bug.cgi?id=732894
2014-07-09 11:01:40 -04:00
Matthias Clasen
5a548106b0 Deprecate gtk_icon_theme_add_builtin_icon
Builtin icons are deprecated in favor of loading icons
from resource paths.
2014-06-30 17:17:49 -04:00
Matthias Clasen
e9ac1bb476 Make gtk_icon_theme_add_resource_path public API
This makes it possible to look up icons in resources using
the icon theme api, and should be used as a replacement
for installing icons below $pkgdatadir/icons and adding
that location to the search path.
2014-06-30 17:13:04 -04:00
Matthias Clasen
f6da4efd47 GtkIconTheme: Allow unthemed icons from resource paths
This makes it pretty straightforward to add individual icons
that don't need to be present in multiple sizes.
2014-06-30 17:02:41 -04:00
Matthias Clasen
c2a22feb27 Drop an extra dir from builtin icons
Make icon lookup from resources work without the extra hicolor
component in the path. It is redundant, since we always treat
builtin icons as part of hicolor anyway.
2014-06-30 16:23:28 -04:00
Matthias Clasen
c28d938a24 GtkIconTheme: Only look at resources for hicolor
We want to treat icons coming from resources as builtins that
are looked at as part of Hicolor.
2014-06-30 16:03:03 -04:00
Matthias Clasen
f7fbeb40c7 GtkIconTheme: Drop an unused parameter
We're always passing FALSE for scale_only, so why bother.
2014-06-30 16:00:05 -04:00
Matthias Clasen
bec3aa54e4 Treat unthemed icons the same as force_size for scaling
This is closer to what we were doing in the past.
2014-06-30 15:57:16 -04:00
Matthias Clasen
3d0dac0aef GtkIconTheme: Copy all fields in icon_info_dup
This functionality is only exercised by gnome-shell, currently.
Therefore, forgetting to copy a field here means an instant
gnome-shell crash :-(. More tests needed.
2014-06-23 12:20:59 -04:00
Matthias Clasen
30982b6d4e GtkIconTheme: Be more careful when warning
It sucks when printing a warning causes gnome-shell to crash,
so be more careful about icon names being NULL here.
2014-06-23 12:13:22 -04:00
Matthias Clasen
12a40cf8a6 GtkIconTheme: keep misplaced symbolics working
Recent changes made it a breaking mistake to install symbolic icons
of the wrong size into a theme directory, or into the legacy unthemed
icon location.

Since this change affects many apps, do the extra work to keep these
icons working, but emit warnings, in the hope that this will lead to
cleaning up the mess over time.
2014-06-23 08:18:42 -04:00
Matthias Clasen
fe92c4478e Move some comments around 2014-06-22 22:04:00 -04:00
Matthias Clasen
a44f01c573 Some documentation rewording 2014-06-22 16:46:11 -04:00
Matthias Clasen
6cc32c24be GtkIconTheme: Drop an unused variable
We no longer need a separate field for symbolic icon size,
now that we are using the directory size.
2014-06-22 11:52:11 -04:00
Matthias Clasen
b96058c3b7 GtkIconTheme: Load symbolic icons at the same size
Reuse the scale information that we have from loading icons
normally, when loading a symbolic icon, so that we apply the
same size constraints.

This commit assumes that svgs have the nominal size of the
directory they are in, which will be true for all current
symbolic icons.
2014-06-22 11:52:11 -04:00
Matthias Clasen
acb276c644 GtkIconInfo: Small struct packing improvement
This makes the GtkIconInfo struct a bit smaller.
2014-06-22 11:52:11 -04:00
Matthias Clasen
f2b98f45db GtkIconInfo: Drop an unused field
The GtkIconInfo threshold field was never used, so lets not
carry it around.
2014-06-22 11:52:10 -04:00
Matthias Clasen
a10412f49e GtkIconTheme: Respect limits in theme dirs
Previously, we were taking thresholds and min/max sizes into
account when choosing the best theme dir, but when it came
to loading the icon, we always scaled icons from scalable
directories all the way, ignoring the min/max size limits.

This commit changes things around so that we now load icons
in Threshold directories at their nominal size, and scale
icons in Scalable directories only up to the specified limits.

To override this and keep the previous behaviour of scaling
all the way to the desired size, use the GTK_ICON_THEME_FORCE_SIZE
flag.
2014-06-22 11:52:10 -04:00
Matthias Clasen
240daf55a1 GtkIconTheme: Drop an unused function 2014-06-20 20:40:52 -04:00
Matthias Clasen
2472cf22db GtkIconTheme: Small cleanup
Make the default symbolic colors a little more readable in the code.
2014-06-20 20:40:52 -04:00
Matthias Clasen
669bc909d8 GtkIconTheme: Trivial cleanup
Drop the _-prefix from a static function.
We've agreed to no stop using those prefixes.
2014-06-20 20:40:51 -04:00
Matthias Clasen
5ddacf094e GtkIconTheme: Don't create empty IconThemeDir structs
Starting gtk3-demo currently creates ~1200 of these, most
of them for nonexisting directories. Lets try to avoid that.
2014-06-20 12:15:25 -04:00
Matthias Clasen
4f1ff179bb Revert "Document gtk_icon_theme_add_resource_path"
This reverts commit 988b6b483d.
2014-06-20 08:46:42 -04:00
Matthias Clasen
a31e8369f8 Revert "Deprecate gtk_icon_theme_add_builtin_icon"
This reverts commit 923eeda2d3.
2014-06-20 08:46:24 -04:00
Matthias Clasen
923eeda2d3 Deprecate gtk_icon_theme_add_builtin_icon 2014-06-20 01:17:47 -04:00
Matthias Clasen
988b6b483d Document gtk_icon_theme_add_resource_path 2014-06-20 01:17:47 -04:00
Matthias Clasen
49bcaf844c GtkIconTheme: Include legacy stock icons from resources
Add /org/gtk/libgtk/icons as a resource path, and ensure
that we always parse an index.theme file for hicolor which
makes the builtin icons available as part of the hicolor theme.
2014-06-20 01:17:46 -04:00
Matthias Clasen
968ea4186d GtkIconTheme: Allow loading icons from resources
We add a new API, gtk_icon_theme_add_resource_path, which
can be used to add resource path as a base location for
icon theme content, similar to gtk_icon_theme_append_search_path.
2014-06-20 01:17:46 -04:00
Matthias Clasen
13c354db8d GtkIconTheme: Drop the all_icons hash table
It is not used anywhere anymore.
2014-06-20 01:17:46 -04:00