Bug 210745 - [GTK4] Adapt to GtkIconTheme API changes
Summary: [GTK4] Adapt to GtkIconTheme API changes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Claudio Saavedra
URL:
Keywords:
Depends on:
Blocks: GTK4
  Show dependency treegraph
 
Reported: 2020-04-20 07:25 PDT by Claudio Saavedra
Modified: 2020-04-21 05:31 PDT (History)
8 users (show)

See Also:


Attachments
Patch (3.64 KB, patch)
2020-04-20 07:30 PDT, Claudio Saavedra
no flags Details | Formatted Diff | Diff
Patch (4.05 KB, patch)
2020-04-21 02:49 PDT, Claudio Saavedra
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Claudio Saavedra 2020-04-20 07:25:22 PDT
[GTK4] Adapt to GtkIconTheme API changes
Comment 1 Claudio Saavedra 2020-04-20 07:30:59 PDT
Created attachment 396974 [details]
Patch
Comment 2 Darin Adler 2020-04-20 10:16:03 PDT
Comment on attachment 396974 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396974&action=review

Not a GTK expert, but expert enough to review this I think.

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:69
> +    GRefPtr<GtkIconPaintable> iconPaintable = adoptGRef(gtk_icon_theme_lookup_icon(gtk_icon_theme_get_for_display(gdk_display_get_default()), "image-missing", nullptr, 16, scale, gtk_widget_get_default_direction(), static_cast<GtkIconLookupFlags>(0));
> +    if (iconPaintable) {

I suggest using auto and putting local variable definition inside the if

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:71
> +        GFile* file = gtk_icon_paintable_get_file(iconPaintable.get());
> +        if (file) {

Ditto.

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:73
> +            auto buffer = loadResourceSharedBuffer(g_file_peek_path(file));
> +            icon->setData(WTFMove(buffer), true);

Given there’s no failure checking here, I would have done it as a one-liner.

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:80
>      GRefPtr<GtkIconInfo> iconInfo = adoptGRef(gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), "image-missing", iconSize, GTK_ICON_LOOKUP_NO_SVG));
>      if (iconInfo) {

Ditto.

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:82
>          auto buffer = loadResourceSharedBuffer(gtk_icon_info_get_filename(iconInfo.get()));
>          icon->setData(WTFMove(buffer), true);

Ditto.
Comment 3 Adrian Perez 2020-04-20 10:36:01 PDT
Comment on attachment 396974 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396974&action=review

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:70
> +        GFile* file = gtk_icon_paintable_get_file(iconPaintable.get());

We need a GRefPtr<GFile> here to avoid leaking the object. The _get_file()
accessor is “transfer full”. You could even do:

  if (auto file = adoptGRef(gtk_icon_paintable_get_file(iconPaintable.get()))) {
      // Load data from file.
  }

=)
Comment 4 Darin Adler 2020-04-20 10:51:00 PDT
Very happy to see the adoptGRef recommendations.
Comment 5 Carlos Garcia Campos 2020-04-21 01:24:38 PDT
Comment on attachment 396974 [details]
Patch

I would just remove this code for both GTK3 and GTK4 and always use the missingImage we already compile as a GResource.
Comment 6 Claudio Saavedra 2020-04-21 02:49:20 PDT
Created attachment 397065 [details]
Patch
Comment 7 Adrian Perez 2020-04-21 04:34:03 PDT
Comment on attachment 397065 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397065&action=review

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:53
> +    return loadImageFromGResource(name);

Oh, much nicer! Thanks Carlos for remembering that we had an image
for this in the resource bundle already =)
Comment 8 EWS 2020-04-21 05:31:26 PDT
Committed r260425: <https://trac.webkit.org/changeset/260425>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397065 [details].