+2005-01-09 Marco Pesenti Gritti <marco@gnome.org>
+
+ * cut-n-paste/recent-files/egg-recent-item.c:
+ * cut-n-paste/recent-files/egg-recent-item.h:
+ * cut-n-paste/recent-files/egg-recent-model.c:
+ * cut-n-paste/recent-files/egg-recent-util.c:
+ * cut-n-paste/recent-files/egg-recent-view-gtk.c:
+ * cut-n-paste/recent-files/egg-recent-view.c:
+
+ Update
+
2005-01-08 Martin Kretzschmar <martink@gnome.org>
* pdf/splash/Splash.cc (clear, drawPixel, drawSpan, xorSpan, getPixel)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
+/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
item->private_data = FALSE;
item->uri = NULL;
item->mime_type = NULL;
+ item->mime_type_is_explicit = FALSE;
item->refcount = 1;
return NULL;
}
- item->mime_type = gnome_vfs_get_mime_type (item->uri);
-
- if (!item->mime_type)
- item->mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
-
return item;
}
}
*/
+static void
+egg_recent_item_update_mime_type (EggRecentItem *item)
+{
+ if (!item->mime_type_is_explicit) {
+ g_free (item->mime_type);
+ item->mime_type = NULL;
+
+ if (item->uri)
+ item->mime_type = gnome_vfs_get_mime_type (item->uri);
+
+ if (!item->mime_type)
+ item->mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
+ }
+}
+
gboolean
egg_recent_item_set_uri (EggRecentItem *item, const gchar *uri)
{
g_free (utf8_uri);
}
+ egg_recent_item_update_mime_type (item);
+
return TRUE;
}
void
egg_recent_item_set_mime_type (EggRecentItem *item, const gchar *mime)
{
- item->mime_type = g_strdup (mime);
+ g_free (item->mime_type);
+ item->mime_type = NULL;
+
+ if (mime && mime[0]) {
+ item->mime_type_is_explicit = TRUE;
+ item->mime_type = g_strdup (mime);
+ } else {
+ item->mime_type_is_explicit = FALSE;
+ egg_recent_item_update_mime_type (item);
+ }
}
gchar *
GList *groups;
int refcount;
+
+ guint mime_type_is_explicit : 1;
};
GType egg_recent_item_get_type (void) G_GNUC_CONST;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
+/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
egg_recent_model_monitor (EggRecentModel *model, gboolean should_monitor)
{
if (should_monitor && model->priv->monitor == NULL) {
+ char *uri;
+
+ uri = gnome_vfs_get_uri_from_local_path (model->priv->path);
gnome_vfs_monitor_add (&model->priv->monitor,
- model->priv->path,
- GNOME_VFS_MONITOR_FILE,
- egg_recent_model_monitor_cb,
- model);
+ uri,
+ GNOME_VFS_MONITOR_FILE,
+ egg_recent_model_monitor_cb,
+ model);
+
+ g_free (uri);
/* if the above fails, don't worry about it.
* local notifications will still happen
ret = TRUE;
} else {
g_warning ("Failed to lock: %s", strerror (errno));
+ fclose (file);
return FALSE;
}
}
#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;
}
gchar *icon;
gchar *filename;
const GnomeIconData *icon_data;
- int base_size;
GdkPixbuf *pixbuf;
icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL,
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);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
+/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
retval = gtk_separator_menu_item_new ();
- /**
+ /*
* this is a tag so we can distinguish our menu items
* from others that may be in the menu.
*/
g_free (mime_type);
g_free (text);
- /**
+ /*
* this is a tag so we can distinguish our menu items
* from others that may be in the menu.
*/
/**
* egg_recent_view_gtk_get_type:
- * @:
*
* This returns a GType representing a EggRecentViewGtk object.
*
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/**
+/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the