Re: Icon scaling
- From: Soeren Sandmann <sandmann daimi au dk>
- To: Alexander Larsson <alexl redhat com>
- Cc: Nautilus <nautilus-list gnome org>
- Subject: Re: Icon scaling
- Date: 31 Mar 2004 12:45:31 +0200
Soeren Sandmann <sandmann daimi au dk> writes:
> If you are interested in the "first see if the regular non-forced icon
> works" feature, here it is.
This one may even work.
Søren
Index: nautilus-icon-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-factory.c,v
retrieving revision 1.303
diff -u -p -u -r1.303 nautilus-icon-factory.c
--- nautilus-icon-factory.c 31 Mar 2004 09:24:55 -0000 1.303
+++ nautilus-icon-factory.c 31 Mar 2004 10:30:17 -0000
@@ -453,13 +453,15 @@ cache_icon_new (GdkPixbuf *pixbuf,
return icon;
}
-static void
+static CacheIcon *
cache_icon_ref (CacheIcon *icon)
{
g_assert (icon != NULL);
g_assert (icon->ref_count >= 1);
icon->ref_count++;
+
+ return icon;
}
static void
@@ -1261,6 +1263,7 @@ get_icon_from_cache (const char *icon,
CacheIcon *cached_icon;
gpointer key_in_table, value;
struct stat statbuf;
+ gint width, height;
g_return_val_if_fail (icon != NULL, NULL);
@@ -1283,6 +1286,38 @@ get_icon_from_cache (const char *icon,
g_assert (value != NULL);
key = key_in_table;
cached_icon = value;
+ } else if (force_nominal) {
+ /* Not in table, but force_nominal was specified and an existing icon
+ * might be close enough
+ */
+ lookup_key.force_nominal = FALSE;
+
+ if (g_hash_table_lookup_extended (hash_table, &lookup_key,
+ &key_in_table, &value)) {
+ g_assert (key_in_table != NULL);
+ g_assert (value != NULL);
+
+ key = key_in_table;
+ cached_icon = value;
+
+ width = gdk_pixbuf_get_width (cached_icon->pixbuf);
+ height = gdk_pixbuf_get_height (cached_icon->pixbuf);
+
+ if (MAX (width, height) < nominal_size) {
+ /* Existing icon is good enough, so register it
+ * as force_nominal
+ */
+ lookup_key.force_nominal = TRUE;
+
+ g_assert (g_hash_table_lookup (hash_table, &lookup_key) == NULL);
+
+ g_hash_table_insert (hash_table, &lookup_key,
+ cache_icon_ref (cached_icon));
+ } else {
+ key = NULL;
+ cached_icon = NULL;
+ }
+ }
}
/* Make sure that thumbnails and image-as-itself icons gets
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]