[gnome-software/mwleeds/hardcoded-pwa-list: 6/18] epiphany: Don't try to use icons bigger than 512x512




commit 96bf0a3c1af61193eb1016b29ab086e213b82b3d
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Wed Mar 9 15:56:35 2022 -0800

    epiphany: Don't try to use icons bigger than 512x512
    
    Some web apps only provide an icon that's 1024x1024, but the dynamic
    launcher portal requires a max size of 512x512, so scale them down if
    needed.

 plugins/epiphany/gs-plugin-epiphany.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 839bad7e3..725357a76 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -748,6 +748,7 @@ get_serialized_icon (GsApp *app,
        g_autoptr(GBytes) bytes = NULL;
        g_autoptr(GIcon) bytes_icon = NULL;
        g_autoptr(GVariant) icon_v = NULL;
+       guint icon_width;
 
        /* Note: GsRemoteIcon will work on this GFileIcon code path.
         * The icons plugin should have called
@@ -766,10 +767,15 @@ get_serialized_icon (GsApp *app,
                return NULL;
        }
 
+       /* Scale down to the portal's size limit if needed */
+       icon_width = gs_icon_get_width (icon);
+       if (icon_width > 512)
+               icon_width = 512;
+
        /* Serialize the icon as a #GBytesIcon since that's
         * what the dynamic launcher portal requires.
         */
-       stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), 0, NULL, NULL, NULL);
+       stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), icon_width, NULL, NULL, NULL);
 
        /* Icons are usually smaller than 1 MiB. Set a 10 MiB
         * limit so we can't use a huge amount of memory or hit


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]