[Gtk-sharp-list] Again: Associated Icon File

Eskil Bylund eskil.bylund at gmail.com
Fri Dec 8 22:13:57 EST 2006


Hi Luciano,

You can use the methods from Gnome.Vfs. For example:

// A new pixbuf might be created for every call, so remember to keep a
reference to the returned pixbuf.
public static Gdk.Pixbuf GetIcon(string filename, int size)
{
	string mimeType = Gnome.Vfs.Mime.TypeFromName(filename);
	
	Gnome.IconLookupResultFlags result;
	string iconName = Gnome.Icon.Lookup(IconTheme.Default, null, null,
		null, null, mimeType, Gnome.IconLookupFlags.None, out result);
	
	if (IconTheme.Default.HasIcon(iconName))
	{
		return IconTheme.Default.LoadIcon(iconName, size,
			IconLookupFlags.UseBuiltin);
	}
	return null;
}

Eskil


More information about the Gtk-sharp-list mailing list