After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762825 - Broken image icon displayed when downloading .img files
Broken image icon displayed when downloading .img files
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Downloads
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-28 17:01 UTC by Michael Catanzaro
Modified: 2016-03-01 14:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot (73.46 KB, image/png)
2016-02-29 13:55 UTC, Michael Catanzaro
  Details
download-widget: Fix icon for .img files (1.97 KB, patch)
2016-02-29 20:29 UTC, Iulian Radu
none Details | Review
download-widget: Fix icon for .img files (2.00 KB, patch)
2016-02-29 20:35 UTC, Iulian Radu
reviewed Details | Review
Different approach (1.66 KB, patch)
2016-03-01 07:27 UTC, Carlos Garcia Campos
committed Details | Review

Description Michael Catanzaro 2016-02-28 17:01:49 UTC
Download any .img file, a broken image icon displays in the popover. :/  Not sure what to do about this, the APIs seem designed to make it difficult to detect this....
Comment 1 Carlos Garcia Campos 2016-02-29 06:40:51 UTC
What's exactly the problem? why .img files? what does broken mean? the missing image icon? we are supposed to fallback to package icon when we don't know the mime type
Comment 2 Michael Catanzaro 2016-02-29 13:55:13 UTC
(In reply to Carlos Garcia Campos from comment #1)
> we are supposed to fallback to package icon when we
> don't know the mime type

The problem is we do know the MIME type. We pass it to g_content_type_get_symbolic_icon, then if g_content_type_get_symbolic_icon returns NULL we fall back to using package-x-generic-symbolic. But the return value of g_content_type_get_symbolic_icon never is not nullable, so this is wrong. If GLib can't find a reasonable icon, it returns a broken image icon (screenshot attached).
Comment 3 Michael Catanzaro 2016-02-29 13:55:43 UTC
Created attachment 322657 [details]
screenshot
Comment 4 Iulian Radu 2016-02-29 20:29:07 UTC
Created attachment 322704 [details] [review]
download-widget: Fix icon for .img files

If the file is an .img file, a broken image icon is displayed instead
of the package-x-generic-symbolic. This happens because GLib can't find
a proper icon for the given content type.

Check the icon name and fall back to using package-x-generic-symbolic
if the icon name matches the "broken image" icon's name.
Comment 5 Iulian Radu 2016-02-29 20:35:41 UTC
Created attachment 322705 [details] [review]
download-widget: Fix icon for .img files

Oops
Comment 6 Michael Catanzaro 2016-02-29 23:33:18 UTC
Review of attachment 322705 [details] [review]:

Thanks

::: lib/widgets/ephy-download-widget.c
@@ +56,3 @@
 static GParamSpec *obj_properties[LAST_PROP];
 
+#define GENERIC_APPLICATION_ICON_NAME "application-x-generic"

Since you only use this once, I would just hardcode it at the point of use, like we already do for "package-x-generic-symbolic." Don't tell your programming teacher.

@@ +144,3 @@
+    /* If GLib can't find an icon for the given content type, it returns a
+     * broken image icon. If that's the case, fall back to using
+     * package-x-generic-symbolic. */

I prefer a style with the closing * of the */ in the same column as the rest of the *s:

/*
 *
 *
 */

@@ +147,3 @@
+    generic_icon_name = g_content_type_get_generic_icon_name (content_type);
+    if (g_strcmp0 (generic_icon_name, GENERIC_APPLICATION_ICON_NAME) == 0)
+      icon = g_icon_new_for_string ("package-x-generic-symbolic", NULL);

We can simplify this to get rid of the redundant "package-x-generic-symbolic" lines:

if (content_type) {
  // Declare it here for reduced scope
  char *generic_icon_name = g_content_type_get_generic_icon_name (content_type);

  if (g_strcmp0 (generic_icon_name, "application-x-generic") != 0)
    icon = g_content_type_get_symbolic_icon (content_type);

  g_free (generic_icon_name);
}

if (!icon)
  icon = g_icon_new_for_string ("package-x-generic-symbolic", NULL);
Comment 7 Carlos Garcia Campos 2016-03-01 06:38:52 UTC
(In reply to Michael Catanzaro from comment #3)
> Created attachment 322657 [details]
> screenshot

That's the image missing icon, the fallback GtkImage uses when it can't find the icon in the theme
Comment 8 Carlos Garcia Campos 2016-03-01 06:55:31 UTC
Review of attachment 322705 [details] [review]:

I don't think this is the right fix, it looks like a generic workaround for a very specific problem. Let me explain what I think is going on here. The content type of .img is detected as application/x-raw-disk-image. g_content_type_get_symbolic_icon() creates a GThemedIcon with application-x-raw-disk-image-symbolic, and the generic icon application-x-generic-symbolic (because this is application-). When GtkImage tries to render the GIcon it doesn't find any of the icons in the theme, nor the fallbacks either (the non symbolic ones) and ends up falling back to missing-image. So, I think there isn't any bug here, we just need an icon for either application-x-raw-disk-image or application-x-generic in the theme. But since we always fallback to package-x-generic-symbolic for downloads I think it makes sense to try to prevent the missing icon from being shown and use always the package one. In that case we need a workaround for any missing icon, not just the ones starting with application-.
Comment 9 Carlos Garcia Campos 2016-03-01 07:27:01 UTC
Created attachment 322720 [details] [review]
Different approach

I think this is simpler and should fix any other cases.
Comment 10 Michael Catanzaro 2016-03-01 14:44:45 UTC
Review of attachment 322720 [details] [review]:

Yeah, I was confused by the application- prefix on the icon too; I should probably not review patches when I'm tired....

::: lib/widgets/ephy-download-widget.c
@@ +147,3 @@
+       * missing in the theme.
+       */
+      g_themed_icon_append_name (G_THEMED_ICON (icon), "package-x-generic-symbolic");

OK, I didn't realize you could do this. Nice.