[Monodevelop-patches-list] r696 - in trunk/MonoDevelop/src: Libraries/MonoDevelop.Gui.Utils Libraries/MonoDevelop.Gui.Utils/FileIcons Main/Base/Gui/Pads
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Tue Jan 27 22:08:39 EST 2004
Author: tberman
Date: 2004-01-27 22:08:39 -0500 (Tue, 27 Jan 2004)
New Revision: 696
Added:
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/FileIcons/
trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs
Modified:
trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
Log:
adding FileIconLoader, provides an easy way to pass a width/height and a filename and get back a scaled pixbuf. uses a hashtable internally to avoid multiple lookups
Added: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs 2004-01-28 01:57:45 UTC (rev 695)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs 2004-01-28 03:08:39 UTC (rev 696)
@@ -0,0 +1,44 @@
+using System;
+using System.Collections;
+
+using Gnome;
+
+namespace MonoDevelop.Gui.Utils
+{
+
+ public class FileIconLoader
+ {
+
+ static Gnome.IconTheme iconTheme;
+ static Gnome.ThumbnailFactory thumbnailFactory;
+ static Hashtable iconHash;
+
+ static FileIconLoader ()
+ {
+ iconTheme = new Gnome.IconTheme ();
+ thumbnailFactory = new Gnome.ThumbnailFactory (ThumbnailSize.Normal);
+ iconHash = new Hashtable ();
+ }
+
+ private FileIconLoader ()
+ {
+ }
+
+ public static Gdk.Pixbuf GetPixbufForFile (string filename, int width, int height)
+ {
+ Gnome.IconLookupResultFlags result;
+ string icon = Gnome.Icon.LookupSync (iconTheme, thumbnailFactory, filename, "", Gnome.IconLookupFlags.None, out result);
+ Gdk.Pixbuf big_pixbuf = (Gdk.Pixbuf) iconHash [icon];
+ if (big_pixbuf == null) {
+ int i;
+ string p_filename = iconTheme.LookupIcon (icon, 24, new Gnome.IconData (), out i);
+ big_pixbuf = new Gdk.Pixbuf (p_filename);
+ iconHash [icon] = big_pixbuf;
+ }
+ return big_pixbuf.ScaleSimple (height, width, Gdk.InterpType.Bilinear);
+ }
+
+
+ }
+
+}
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-01-28 01:57:45 UTC (rev 695)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-01-28 03:08:39 UTC (rev 696)
@@ -22,6 +22,7 @@
using ICSharpCode.SharpDevelop.Services;
using MonoDevelop.Gui.Widgets;
+using MonoDevelop.Gui.Utils;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
@@ -322,14 +323,7 @@
this.lastModified = lastModified;
//FIXME: This is because //home/blah is not the same as /home/blah according to Icon.LookupSync, if we get weird behaviours, lets look at this again, see if we still need it.
FullName = fullname.Substring (1);
- //FIXME: This code needs to be abstracted out to a MonoDevelop.Gui class and made to be performant and not sucky, ill do it later --Todd
- Gnome.IconLookupResultFlags result;
- string icon = Gnome.Icon.LookupSync (theme, tFactory, FullName, "", Gnome.IconLookupFlags.None, out result);
- int i;
- string p_filename = theme.LookupIcon (icon, 24, new Gnome.IconData (), out i);
- Gdk.Pixbuf big_pixbuf = new Gdk.Pixbuf (p_filename);
- this.icon = big_pixbuf.ScaleSimple (24, 24, Gdk.InterpType.Bilinear);
-
+ icon = FileIconLoader.GetPixbufForFile (FullName, 24, 24);
}
}
More information about the Monodevelop-patches-list
mailing list