[Monodevelop-patches-list] r2574 - in trunk/MonoDevelop/Core/src: MonoDevelop.Base MonoDevelop.Base/Gui/Workbench/Layouts MonoDevelop.Gui.Utils MonoDevelop.Gui.Utils/FileIcons
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Wed Jun 1 12:47:51 EDT 2005
Author: jluke
Date: 2005-06-01 12:47:51 -0400 (Wed, 01 Jun 2005)
New Revision: 2574
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs
Log:
use Gtk.IconTheme to load the icons
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-01 15:21:47 UTC (rev 2573)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-01 16:47:51 UTC (rev 2574)
@@ -3,7 +3,7 @@
* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs:
* Gui/Workbench/Layouts/SdiWorkspaceWindow.cs:
* Gui/Pads/FileScout/FileListItem.cs: adjust to
- FileIconLoader.GetPixbufForFile change
+ FileIconLoader changes
2005-06-01 Jacob Ilsø Christensen <jacobilsoe at gmail.com>
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs 2005-06-01 15:21:47 UTC (rev 2573)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs 2005-06-01 16:47:51 UTC (rev 2574)
@@ -462,7 +462,7 @@
{
Gtk.Image mimeimage = null;
if (content.IsUntitled) {
- mimeimage = new Gtk.Image (FileIconLoader.GetPixbufForType ("gnome-fs-regular").ScaleSimple (16, 16, Gdk.InterpType.Bilinear));
+ mimeimage = new Gtk.Image (FileIconLoader.GetPixbufForType ("gnome-fs-regular", 16));
} else {
mimeimage = new Gtk.Image (FileIconLoader.GetPixbufForFile (content.ContentName, 16));
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs 2005-06-01 15:21:47 UTC (rev 2573)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs 2005-06-01 16:47:51 UTC (rev 2574)
@@ -316,7 +316,7 @@
tabLabel.Icon.Pixbuf = FileIconLoader.GetPixbufForFile (content.ContentName, 16);
}
} catch {
- tabLabel.Icon.Pixbuf = FileIconLoader.GetPixbufForType ("gnome-fs-regular").ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
+ tabLabel.Icon.Pixbuf = FileIconLoader.GetPixbufForType ("gnome-fs-regular", 16);
}
if (TitleChanged != null) {
TitleChanged(this, e);
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/ChangeLog 2005-06-01 15:21:47 UTC (rev 2573)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/ChangeLog 2005-06-01 16:47:51 UTC (rev 2574)
@@ -2,6 +2,9 @@
* FileIcons/FileIconLoader.cs (GetPixbufForFile):
just use size instead of height, width
+
+ * FileIcons/FileIconLoader.cs: use Gtk.IconTheme to load
+ icons, simplify and size appropriately
2005-04-17 John Luke <john.luke at gmail.com>
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs 2005-06-01 15:21:47 UTC (rev 2573)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Utils/FileIcons/FileIconLoader.cs 2005-06-01 16:47:51 UTC (rev 2574)
@@ -1,22 +1,19 @@
using System;
using System.Collections;
-using Gnome;
+using Gtk;
namespace MonoDevelop.Gui.Utils
{
-
- public class FileIconLoader
+ public sealed class FileIconLoader
{
-
- static Gnome.IconTheme iconTheme;
+ static Gdk.Pixbuf defaultIcon;
static Gnome.ThumbnailFactory thumbnailFactory;
static Hashtable iconHash;
static FileIconLoader ()
{
- iconTheme = new Gnome.IconTheme ();
- thumbnailFactory = new Gnome.ThumbnailFactory (ThumbnailSize.Normal);
+ thumbnailFactory = new Gnome.ThumbnailFactory (Gnome.ThumbnailSize.Normal);
iconHash = new Hashtable ();
}
@@ -24,6 +21,15 @@
{
}
+ public static Gdk.Pixbuf DefaultIcon {
+ get {
+ if (defaultIcon == null)
+ defaultIcon = new Gdk.Pixbuf ("../data/resources/icons/gnome-fs-regular.png");
+ return defaultIcon;
+ }
+ }
+
+ // FIXME: is there a GTK replacement for Gnome.Icon.LookupSync?
public static Gdk.Pixbuf GetPixbufForFile (string filename, int size)
{
Gnome.IconLookupResultFlags result;
@@ -32,35 +38,26 @@
if (filename == "Documentation")
icon = "gnome-fs-regular";
else
- icon = Gnome.Icon.LookupSync (iconTheme, thumbnailFactory, filename, "", Gnome.IconLookupFlags.None, out result);
+ icon = Gnome.Icon.LookupSync (IconTheme.Default, thumbnailFactory, filename, "", Gnome.IconLookupFlags.None, out result);
} catch {
icon = "gnome-fs-regular";
}
- Gdk.Pixbuf pix = GetPixbufForType (icon);
- return pix.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
+ return GetPixbufForType (icon, size);
}
- public static Gdk.Pixbuf GetPixbufForType (string type)
+ public static Gdk.Pixbuf GetPixbufForType (string type, int size)
{
- Gdk.Pixbuf bf = (Gdk.Pixbuf) iconHash [type];
+ // FIXME: is caching these really worth it?
+ // we have to cache them in both type and size
+ Gdk.Pixbuf bf = (Gdk.Pixbuf) iconHash [type+size];
if (bf == null) {
- const string default_icon_location = "../data/resources/icons/gnome-fs-regular.png";
- string p_filename = "";
- try {
- int i;
- p_filename = iconTheme.LookupIcon (type, 24, new Gnome.IconData (), out i);
- if (p_filename.Equals ("")) {
- p_filename = default_icon_location;
- }
- } catch {
- p_filename = default_icon_location;
+ bf = IconTheme.Default.LoadIcon (type, size, (IconLookupFlags) 0);
+ if (bf == null) {
+ bf = DefaultIcon;
+ if (bf.Height > size)
+ bf = bf.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
}
- try {
- bf = new Gdk.Pixbuf (p_filename);
- } catch {
- bf = new Gdk.Pixbuf (default_icon_location);
- }
- iconHash [type] = bf;
+ iconHash [type+size] = bf;
}
return bf;
}
More information about the Monodevelop-patches-list
mailing list