The current location doesn't exist unless you've installed GNOME,
which is not so common on Ubuntu. Unfortunately I couldn't find any
other location containing a clean, high quality logo.
This adds another low quality icon source, and also prevents any icon
being returned if the highquality flag was set (note this prevents
virt-manager from displaying an icon, but there's nothing we can do
about that, and it's no worse than the current situation).
Updates commit 1d0683964f996b24b8fcf5bce7611a98443344f3.
Thanks: Xiaoyun Hu
---
src/inspect-icon.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/inspect-icon.c b/src/inspect-icon.c
index c298dd7..3893fba 100644
--- a/src/inspect-icon.c
+++ b/src/inspect-icon.c
@@ -141,7 +141,8 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t
*size_r,
break;
case OS_DISTRO_UBUNTU:
- r = icon_ubuntu (g, fs, &size);
+ if (!highquality)
+ r = icon_ubuntu (g, fs, &size);
break;
case OS_DISTRO_MAGEIA:
@@ -349,12 +350,29 @@ icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
return get_png (g, fs, DEBIAN_ICON, size_r, 2048);
}
-#define UBUNTU_ICON "/usr/share/icons/gnome/24x24/places/ubuntu-logo.png"
-
static char *
icon_ubuntu (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
{
- return get_png (g, fs, UBUNTU_ICON, size_r, 2048);
+ const char *icons[] = {
+ "/usr/share/icons/gnome/24x24/places/ubuntu-logo.png",
+
+ /* Very low quality and only present when ubuntu-desktop packages
+ * have been installed.
+ */
+ "/usr/share/help/C/ubuntu-help/figures/ubuntu-logo.png",
+ NULL
+ };
+ size_t i;
+ char *ret;
+
+ for (i = 0; icons[i] != NULL; ++i) {
+ ret = get_png (g, fs, icons[i], size_r, 2048);
+ if (ret == NULL)
+ return NULL;
+ if (ret != NOT_FOUND)
+ return ret;
+ }
+ return NOT_FOUND;
}
#define MAGEIA_ICON "/usr/share/icons/mageia.png"
--
2.7.4
Show replies by date
We have to download the old 32 bit explorer.exe in order to find the
icons as the 64 bit version doesn't contain any icons (where are they?).
Thus prefer the 32 bit (WoW64 subsystem) directory if found.
Fixes commit 7f16c346bbeba2f2fe3c31ccb85158178a284d84.
Thanks: Xiaoyun Hu
---
src/inspect-icon.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/inspect-icon.c b/src/inspect-icon.c
index 3893fba..0db8147 100644
--- a/src/inspect-icon.c
+++ b/src/inspect-icon.c
@@ -541,7 +541,28 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
int r;
char *ret;
- /* Download %systemroot%\explorer.exe */
+ /* Prefer %systemroot%\SysWOW64\explorer.exe, a PE32 binary that
+ * usually contains the icons on 64 bit guests.
+ */
+ filename = safe_asprintf (g, "%s/syswow64/explorer.exe",
+ fs->windows_systemroot);
+ filename_case = guestfs_case_sensitive_path (g, filename);
+ if (filename_case == NULL)
+ return NULL;
+
+ guestfs_push_error_handler (g, NULL, NULL);
+ r = guestfs_is_file (g, filename_case);
+ guestfs_pop_error_handler (g);
+ if (r == -1)
+ return NULL;
+ if (r)
+ goto download;
+ free (filename);
+ filename = NULL;
+ free (filename_case);
+ filename_case = NULL;
+
+ /* Otherwise download %systemroot%\explorer.exe */
filename = safe_asprintf (g, "%s/explorer.exe", fs->windows_systemroot);
filename_case = guestfs_case_sensitive_path (g, filename);
if (filename_case == NULL)
@@ -555,6 +576,7 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
if (r == 0)
return NOT_FOUND;
+ download:
filename_downloaded = guestfs_int_download_to_tmp (g, fs, filename_case,
"explorer.exe",
MAX_WINDOWS_EXPLORER_SIZE);
--
2.7.4