Don't crash when the requested icon doesn't exist in theme

This commit is contained in:
Benjamin Podszun 2010-07-29 14:03:10 +01:00 committed by Hylke Bons
parent c4ab98a6b7
commit 63ab8a084d

View file

@ -96,13 +96,30 @@ namespace SparkleShare {
// Looks up an icon from the system's theme
public static Gdk.Pixbuf GetIcon (string Name, int Size)
public static Gdk.Pixbuf GetIcon (string name, int size)
{
IconTheme IconTheme = new IconTheme ();
IconTheme.AppendSearchPath (SparklePaths.SparkleIconPath);
IconTheme.AppendSearchPath (SparklePaths.SparkleLocalIconPath);
return IconTheme.LoadIcon (Name, Size, IconLookupFlags.GenericFallback);
try {
return IconTheme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
} catch {
try {
return IconTheme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
} catch {
return null;
}
}
}