From d5460aea4452eefb1c3f8baabf8db2eb8992a003 Mon Sep 17 00:00:00 2001 From: "dolske%mozilla.com" Date: Thu, 10 Jan 2008 06:04:51 +0000 Subject: [PATCH] Bug 410215 - GTK's .xpm decoding is weird, stop using XPM as the default window icon. r+sr=roc, a1.9=schrep --- widget/src/gtk2/nsWindow.cpp | 49 ++++++++++++++---------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index 1d4693520c9..38d20898b68 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -1338,21 +1338,26 @@ nsWindow::SetIcon(const nsAString& aIconSpec) nsCAutoString path; nsCStringArray iconList; - // Assume the given string is a local identifier for an icon file. + // Look for icons with the following suffixes appended to the base name. + // The last two entries (for the old XPM format) will be ignored unless + // no icons are found using the other suffixes. XPM icons are depricated. - ResolveIconName(aIconSpec, NS_LITERAL_STRING(".xpm"), - getter_AddRefs(iconFile)); - if (iconFile) { - iconFile->GetNativePath(path); - iconList.AppendCString(path); - } + const char extensions[6][7] = { ".png", "16.png", "32.png", "48.png", + ".xpm", "16.xpm" }; - // Get the 16px icon path as well - ResolveIconName(aIconSpec, NS_LITERAL_STRING("16.xpm"), - getter_AddRefs(iconFile)); - if (iconFile) { - iconFile->GetNativePath(path); - iconList.AppendCString(path); + for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(extensions); i++) { + // Don't bother looking for XPM versions if we found a PNG. + if (i == NS_ARRAY_LENGTH(extensions) - 2 && iconList.Count()) + break; + + nsAutoString extension; + extension.AppendASCII(extensions[i]); + + ResolveIconName(aIconSpec, extension, getter_AddRefs(iconFile)); + if (iconFile) { + iconFile->GetNativePath(path); + iconList.AppendCString(path); + } } // leave the default icon intact if no matching icons were found @@ -3881,23 +3886,7 @@ nsWindow::SetWindowIconList(const nsCStringArray &aIconList) void nsWindow::SetDefaultIcon(void) { - // Set up the default window icon - nsCOMPtr iconFile; - ResolveIconName(NS_LITERAL_STRING("default"), - NS_LITERAL_STRING(".xpm"), - getter_AddRefs(iconFile)); - if (!iconFile) { - NS_WARNING("default.xpm not found"); - return; - } - - nsCAutoString path; - iconFile->GetNativePath(path); - - nsCStringArray iconList; - iconList.AppendCString(path); - - SetWindowIconList(iconList); + SetIcon(NS_LITERAL_STRING("default")); } void