summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2004-10-12 10:35:40 +0000
committerBastien Nocera <hadess@src.gnome.org>2004-10-12 10:35:40 +0000
commit5e1ae37e86698a67eae656ed8c038ad5055eb400 (patch)
tree7e178f4368dd8eabd9e568d447769e7a09b97898
parente38a2258168cb51b6863fb5bb3079d708ba5eeca (diff)
downloadtotem-5e1ae37e86698a67eae656ed8c038ad5055eb400.tar.gz
updated egg-recent from libegg
2004-10-12 Bastien Nocera <hadess@hadess.net> * src/egg-recent-model.c: (egg_recent_model_add_full): * src/egg-recent-util.c: (load_icon_file), (egg_recent_util_get_icon): updated egg-recent from libegg
-rw-r--r--ChangeLog6
-rw-r--r--src/egg-recent-model.c1
-rw-r--r--src/egg-recent-util.c50
3 files changed, 22 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index b62fc05d7..c7ae48adb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-12 Bastien Nocera <hadess@hadess.net>
+
+ * src/egg-recent-model.c: (egg_recent_model_add_full):
+ * src/egg-recent-util.c: (load_icon_file),
+ (egg_recent_util_get_icon): updated egg-recent from libegg
+
============ Version 0.99.18
2004-10-11 Bastien Nocera <hadess@hadess.net>
diff --git a/src/egg-recent-model.c b/src/egg-recent-model.c
index d4606ab6c..76a20d4d5 100644
--- a/src/egg-recent-model.c
+++ b/src/egg-recent-model.c
@@ -1291,6 +1291,7 @@ egg_recent_model_add_full (EggRecentModel * model, EggRecentItem *item)
ret = TRUE;
} else {
g_warning ("Failed to lock: %s", strerror (errno));
+ fclose (file);
return FALSE;
}
diff --git a/src/egg-recent-util.c b/src/egg-recent-util.c
index cb30e053f..6780cd1ee 100644
--- a/src/egg-recent-util.c
+++ b/src/egg-recent-util.c
@@ -55,50 +55,31 @@ egg_recent_util_escape_underlines (const gchar* text)
#ifndef USE_STABLE_LIBGNOMEUI
static GdkPixbuf *
-scale_icon (GdkPixbuf *pixbuf,
- double *scale)
-{
- guint width, height;
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
-
- width = floor (width * *scale + 0.5);
- height = floor (height * *scale + 0.5);
-
- return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
-}
-
-static GdkPixbuf *
load_icon_file (char *filename,
- guint base_size,
guint nominal_size)
{
GdkPixbuf *pixbuf, *scaled_pixbuf;
- guint width, height, size;
- double scale;
+ guint width, height;
- pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, nominal_size, nominal_size, NULL);
if (pixbuf == NULL) {
return NULL;
}
- if (base_size == 0) {
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- size = MAX (width, height);
- if (size > nominal_size) {
- base_size = size;
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ /* if the icon is larger than the nominal size, scale down */
+ if (MAX (width, height) > nominal_size) {
+ if (width > height) {
+ height = height * nominal_size / width;
+ width = nominal_size;
} else {
- /* Don't scale up small icons */
- base_size = nominal_size;
+ width = width * nominal_size / height;
+ height = nominal_size;
}
- }
-
- if (base_size != nominal_size) {
- scale = (double)nominal_size/base_size;
- scaled_pixbuf = scale_icon (pixbuf, &scale);
+ scaled_pixbuf = gdk_pixbuf_scale_simple
+ (pixbuf, width, height, GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
pixbuf = scaled_pixbuf;
}
@@ -113,7 +94,6 @@ egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri,
gchar *icon;
gchar *filename;
const GnomeIconData *icon_data;
- int base_size;
GdkPixbuf *pixbuf;
icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL,
@@ -125,14 +105,14 @@ egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri,
filename = gnome_icon_theme_lookup_icon (theme, icon,
size,
&icon_data,
- &base_size);
+ NULL);
g_free (icon);
if (filename == NULL) {
return NULL;
}
- pixbuf = load_icon_file (filename, base_size, size);
+ pixbuf = load_icon_file (filename, size);
g_free (filename);