public static Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme (); // foreach (string search_path in IconTheme.Default.SearchPath) // icon_theme.AppendSearchPath (search_path); // FIXME: Temporary workaround for a bug in IconTheme.SearchPath in Gtk# on 64-bit systems // https://github.com/mono/gtk-sharp/commit/9c54fd5ae77f63d11fdc6873a3cb90691990e37f icon_theme.AppendSearchPath ("/usr/share/icons"); icon_theme.AppendSearchPath ("/usr/local/share/icons"); icon_theme.AppendSearchPath ("/opt/local/share/icons"); icon_theme.AppendSearchPath (Path.Combine (SparkleUI.AssetsPath, "icons")); try { return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback); } catch { try { return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback); } catch { return null; } } }
public static Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme(); icon_theme.AppendSearchPath(Path.Combine(UI.AssetsPath, "icons")); try { return icon_theme.LoadIcon(name, size, IconLookupFlags.GenericFallback); } catch { try { return icon_theme.LoadIcon("gtk-image-missing", size, IconLookupFlags.GenericFallback); } catch { return null; } } }
// Looks up an icon from the system's theme public static Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme (); icon_theme.AppendSearchPath (SparklePaths.SparkleIconPath); icon_theme.AppendSearchPath (SparklePaths.SparkleLocalIconPath); try { return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback); } catch { try { return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback); } catch { return null; } } }
Gdk.Pixbuf GetPixbuf(Gtk.IconTheme theme, string name) { try { return(theme.LoadIcon(name, 16, 0)); } catch { return(RenderIcon(name, Gtk.IconSize.Menu, null)); } }
public static Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme (); icon_theme.AppendSearchPath (Path.Combine (UserInterface.AssetsPath, "icons")); foreach (string search_path in IconTheme.Default.SearchPath) icon_theme.AppendSearchPath (search_path); try { return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback); } catch { try { return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback); } catch { return null; } } }
// Looks up an icon from the system's theme public static Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme (); icon_theme.AppendSearchPath (Path.Combine (SparkleUI.AssetsPath, "icons")); icon_theme.AppendSearchPath ( Path.Combine (Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons")); try { return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback); } catch { try { return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback); } catch { return null; } } }
public Pixbuf GetIcon(string mimeType, Gtk.IconSize size) { if (mimeType == null) { throw new ArgumentNullException("mimeType"); } if (mimeType.Length == 0) { throw new ArgumentException("Argument is emtpy", "mimeType"); } Pixbuf pb; string iconKey = mimeType + (int)size; if (mimeIconCache.TryGetValue(iconKey, out pb)) { return(pb); } if (useCustomMimeIcons) { // render icons which are available in the custom theme Icon icon; if (customMimeMapping.TryGetIconForMimeType(mimeType, out icon)) { pb = icon.Render(widget, size); } else { pb = defaultIcon.Render(widget, size); } } else { // render system mime icons dynamically Gtk.IconTheme iconTheme = Gtk.IconTheme.Default; string iconName = null; foreach (string name in ((GLib.ThemedIcon)GLib.Content.TypeGetIcon(mimeType)).Names) { if (iconTheme.HasIcon(name)) { iconName = name; break; } } if (!string.IsNullOrEmpty(iconName)) { pb = iconTheme.LoadIcon(iconName, IconUtils.GetIconSizeVal(size), 0); } else { Icon fbIcon; if (fallbackIcons.TryGetValue(mimeType, out fbIcon)) { iconName = fbIcon.Name; pb = fbIcon.Render(widget, size); } else { pb = defaultIcon.Render(widget, size); iconName = defaultIcon.Name; } } } if (pb != null) { mimeIconCache.Add(iconKey, pb); } return(pb); }
Pixbuf IconFromTheme (string name, int size, IconTheme theme) { Pixbuf pixbuf = null; string name_noext = name; // We may have to remove the extension. if (name.Contains (".")) name_noext = name.Remove (name.LastIndexOf (".")); try { if (theme.HasIcon (name)) pixbuf = theme.LoadIcon (name, size, 0); else if (theme.HasIcon (name_noext)) pixbuf = theme.LoadIcon (name_noext, size, 0); else if (name == "gnome-mime-text-plain" && theme.HasIcon ("gnome-mime-text")) pixbuf = theme.LoadIcon ("gnome-mime-text", size, 0); } catch (Exception e) { Log<DrawingService>.Warn ("Error loading themed icon '" + name + "': " + e.Message); Log<DrawingService>.Debug (e.StackTrace); pixbuf = null; } return pixbuf; }
// Looks up an icon from the system's theme public Gdk.Pixbuf GetIcon(string name, int size) { IconTheme icon_theme = new IconTheme (); icon_theme.AppendSearchPath (System.IO.Path.Combine ("/usr/share/sparkleshare", "icons")); return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback); }