Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/cut-n-paste/recent-files/egg-recent-item.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2005-01-08 23:33:58 (GMT)
committer Marco Pesenti Gritti <marco@src.gnome.org>2005-01-08 23:33:58 (GMT)
commit2845fb905cccd6655c294247722648d3bce97a27 (patch)
treeaf15e794a64dea8dcde1daeab80ca61b07d2158d /cut-n-paste/recent-files/egg-recent-item.c
parent0607a5da99d7206625d8537fb28096d755721de3 (diff)
Update
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
Diffstat (limited to 'cut-n-paste/recent-files/egg-recent-item.c')
-rw-r--r--cut-n-paste/recent-files/egg-recent-item.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/cut-n-paste/recent-files/egg-recent-item.c b/cut-n-paste/recent-files/egg-recent-item.c
index 9be7970..c533205 100644
--- a/cut-n-paste/recent-files/egg-recent-item.c
+++ b/cut-n-paste/recent-files/egg-recent-item.c
@@ -1,5 +1,5 @@
/* -*- 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
@@ -39,6 +39,7 @@ egg_recent_item_new (void)
item->private_data = FALSE;
item->uri = NULL;
item->mime_type = NULL;
+ item->mime_type_is_explicit = FALSE;
item->refcount = 1;
@@ -97,11 +98,6 @@ egg_recent_item_new_from_uri (const gchar *uri)
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;
}
@@ -182,6 +178,21 @@ egg_recent_item_new_valist (const gchar *uri, va_list args)
}
*/
+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)
{
@@ -208,6 +219,8 @@ egg_recent_item_set_uri (EggRecentItem *item, const gchar *uri)
g_free (utf8_uri);
}
+ egg_recent_item_update_mime_type (item);
+
return TRUE;
}
@@ -334,7 +347,16 @@ egg_recent_item_get_short_name (const EggRecentItem *item)
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 *