summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog77
-rw-r--r--THANKS5
-rwxr-xr-xcheck-THANKS.pl17
-rw-r--r--components/help/hyperbola-filefmt.c141
-rw-r--r--icons/ardmore/.cvsignore3
-rw-r--r--icons/arlo/.cvsignore3
-rw-r--r--icons/arlo/backgrounds/.cvsignore3
-rw-r--r--icons/arlo/sidebar_tab_pieces/.cvsignore3
-rw-r--r--icons/villanova/.cvsignore3
-rw-r--r--libnautilus-extensions/nautilus-bookmark.c16
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.c283
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.h2
-rw-r--r--libnautilus-extensions/nautilus-trash-monitor.c4
-rw-r--r--libnautilus-private/nautilus-bookmark.c16
-rw-r--r--libnautilus-private/nautilus-icon-factory.c283
-rw-r--r--libnautilus-private/nautilus-icon-factory.h2
-rw-r--r--libnautilus-private/nautilus-trash-monitor.c4
-rw-r--r--src/nautilus-bookmark-list.c6
-rw-r--r--src/nautilus-bookmark-parsing.c13
19 files changed, 581 insertions, 303 deletions
diff --git a/ChangeLog b/ChangeLog
index f2e2a1267..253a42092 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,78 @@
+2001-05-01 Darin Adler <darin@eazel.com>
+
+ reviewed by: John Sullivan <sullivan@eazel.com>
+
+ Some enhancements to icon lookup.
+
+ * libnautilus-extensions/nautilus-icon-factory.h:
+ * libnautilus-extensions/nautilus-icon-factory.c:
+ (get_mime_type_icon_without_suffix): Function used to strip suffixes
+ out so we can have file suffixes in the gnome-vfs icon database, but
+ can ignore them and look at all suffixes for the named icon.
+ (make_icon_name_from_mime_type): Construct an icon name for types
+ that don't specify a particular icon. This allows theme designers
+ to make icons for any MIME type.
+ (get_icon_name_for_regular_file): Use the new "without suffix" call.
+ This requires changing this function to return a strdup'd name.
+ (get_icon_name_for_directory), (get_icon_name_for_file): Change to
+ return a strdup'd name.
+ (make_full_icon_path): Do the file exists check in here (was
+ already doing it in some cases) and also call
+ gnome_vfs_icon_path_from_filename.
+ (get_themed_icon_file_path): Get rid of redundant g_file_exists
+ checks and gnome_vfs_icon_path_from_filename call, since both are
+ now handled inside make_full_icon_path.
+ (nautilus_scalable_icon_get_text_pieces),
+ (nautilus_scalable_icon_new_from_text_pieces),
+ (nautilus_scalable_icon_unref), (nautilus_scalable_icon_hash),
+ (nautilus_scalable_icon_equal): Add MIME type to the scalable
+ icons.
+ (nautilus_icon_factory_get_icon_for_file): Pass in the MIME type.
+ (nautilus_icon_factory_get_emblem_icon_by_name): Pass NULL for
+ MIME type.
+ (load_pixbuf_svg): Change to pass in boolean for emblem hack since
+ we don't always have an icon name.
+ (load_icon_from_path): New function, share common code.
+ (load_named_icon): New function, share common code.
+ (load_specific_icon): Try icon based on MIME type first, then fall
+ back on the name specified.
+ (nautilus_icon_factory_get_pixbuf_from_name): Pass NULL for MIME
+ type.
+ (load_icon_with_embedded_text): Pass in the MIME type.
+
+ * src/nautilus-bookmark-list.c: (append_bookmark_node):
+ * src/nautilus-bookmark-parsing.c:
+ (nautilus_bookmark_new_from_node):
+ * libnautilus-extensions/nautilus-bookmark.c:
+ (nautilus_bookmark_icon_is_different),
+ (nautilus_bookmark_set_icon_to_default):
+ Update to deal with MIME types in scalable icons.
+
+ * components/help/hyperbola-filefmt.c:
+ (fmt_scrollkeeper_parse_toc_section),
+ (fmt_scrollkeeper_parse_doc_toc),
+ (fmt_scrollkeeper_parse_document),
+ (fmt_scrollkeeper_parse_section), (fmt_scrollkeeper_parse_xml),
+ (fmt_scrollkeeper_trim_empty_branches),
+ (fmt_scrollkeeper_tree_empty), (fmt_scrollkeeper_populate_tree),
+ (remove_leading_and_trailing_white_spaces), (fmt_toplevel_add_doc),
+ (get_path_from_node), (has_content), (fmt_toplevel_parse_xml_tree):
+ Made more compatible with libxml by not using the content field
+ directly and using xmlChildrenNode and xmlRootNode.
+
+ * libnautilus-extensions/nautilus-trash-monitor.c:
+ (nautilus_trash_monitor_get): Fixed NautilusDirectory leak.
+
+ * THANKS: Added some more translator credits.
+ * check-THANKS.pl: Fixed some email addresses and such.
+
+ * icons/ardmore/.cvsignore:
+ * icons/arlo/.cvsignore,
+ * icons/arlo/backgrounds/.cvsignore:
+ * icons/arlo/sidebar_tab_pieces/.cvsignore:
+ * icons/villanova/.cvsignore:
+ Removed these again.
+
2001-05-01 Andy Hertzfeld <andy@eazel.com>
* components/news/nautilus-news.c: (mark_new_items),
@@ -444,7 +519,7 @@
Made bookmarks window a GnomeDialog, giving it the single
button "Done".
-2001-04-27 Andy Hertzfeld andy@eazel.com>
+2001-04-27 Andy Hertzfeld <andy@eazel.com>
added preferences for the maximum numder of items per site and
the update interval. It's not quite finished, as the news
diff --git a/THANKS b/THANKS
index 1f811939d..cde5c67c9 100644
--- a/THANKS
+++ b/THANKS
@@ -55,12 +55,12 @@ As well as the following people who contributed translations:
Akira TAGOH <tagoh@gnome.gr.jp>
Alastair McKinstry <mckinstry@computer.org>
-Almer S. Tigelaar <almer1@dds.nl>
+Almer S. Tigelaar <almer@gnome.org>
Andreas Hyden <a.hyden@cyberpoint.se>
Andrew V. Samoilov <sav@bcs.zp.ua>
Benedikt Roth <Benedikt.Roth@gmx.net>
Carlos Perelló Marín <carlos@hispalinux.es>
-Christian Meyer <linux@chrisime.de>
+Christian Meyer <chrisime@gnome.org>
Christian Rose <menthos@menthos.com>
Christophe Merlet <redfox@eikonex.org>
Christopher R. Gabriel <cgabriel@softwarelibero.org>
@@ -78,6 +78,7 @@ Kjenneth Christiansen <kenneth@gnu.org>
Manuel de Vega Barreiro <barreiro@arrakis.es>
Martin Norbäck <d95mback@dtek.chalmers.se>
Matthias Warkus <mawarkus@gnome.org>
+Ole Laursen <olau@hardworking.dk>
Pablo Gonzalo del Campo <pablodc@bigfoot.com>
Pablo Saratxaga <pablo@mandrakesoft.com>
Pauli Virtanen <pauli.virtanen@saunalahti.fi>
diff --git a/check-THANKS.pl b/check-THANKS.pl
index d54874631..3e01b3480 100755
--- a/check-THANKS.pl
+++ b/check-THANKS.pl
@@ -4,7 +4,7 @@
#
# Nautilus
#
-# Copyright (C) 2000 Eazel, Inc.
+# Copyright (C) 2000, 2001 Eazel, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -20,7 +20,7 @@
# along with this library; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# Author: Maciej Stachowiak
+# Author: Maciej Stachowiak <mjs@eazel.com>
#
# check-THANKS.pl: Checks for users mentioned in one of the ChangeLogs
@@ -53,6 +53,7 @@ my %name_map =
my %email_map =
(
+ 'almer1@dds.nl' => 'almer@gnome.org',
'arik@gnome.org' => 'arik@eazel.com',
'at@ue-spacy.com' => 'tagoh@gnome.gr.jp',
'baulig@suse.de' => 'martin@home-of-linux.org',
@@ -64,6 +65,7 @@ my %email_map =
'kabalak@gtranslator.org' => 'kabalak@kabalak.net',
'kmaraas@gnu.org' => 'kmaraas@gnome.org',
'kmaraas@online.no' => 'kmaraas@gnome.org',
+ 'linux@chrisime.de' => 'chrisime@gnome.org',
'linuxfan@ionet..net' => 'josh@whitecape.org',
'linuxfan@ionet.net' => 'josh@whitecape.org',
'mathieu@gnome.org' => 'mathieu@eazel.com',
@@ -79,12 +81,13 @@ my %email_map =
# Some ChangeLog lines that carry no credit (incorrect changes that
-# had to be reverted, etc)
+# had to be reverted, changes done for someone else, etc.)
my %no_credit =
(
'2000-09-08 Daniel Egger <egger@suse.de>' => 1,
- '2000-09-06 Daniel Egger <egger@suse.de>' => 1
+ '2000-09-06 Daniel Egger <egger@suse.de>' => 1,
+ '2001-04-25 Changwoo Ryu <cwryu@debian.org>' => 1,
);
@@ -272,19 +275,19 @@ if (@double_credited)
{
print "${person}\n";
}
-
+
$printed = 1;
}
if (@only_in_about)
{
print "\nThe following people are in the about screen but not AUTHORS:\n\n";
-
+
foreach my $person (@only_in_about)
{
print "${person}\n";
}
-
+
$printed = 1;
}
}
diff --git a/components/help/hyperbola-filefmt.c b/components/help/hyperbola-filefmt.c
index bc034aaf9..6a0f92ee3 100644
--- a/components/help/hyperbola-filefmt.c
+++ b/components/help/hyperbola-filefmt.c
@@ -20,24 +20,22 @@
*/
#include <config.h>
-
-#include <gnome.h>
-
#include "hyperbola-filefmt.h"
-#include <eel/eel-glib-extensions.h>
-
-#include <zlib.h>
+#include <ctype.h>
#include <dirent.h>
-#include <regex.h>
+#include <eel/eel-glib-extensions.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-util.h>
#include <limits.h>
-#include <ctype.h>
-#include <unistd.h>
-
+#include <parser.h>
+#include <regex.h>
#include <string.h>
-
#include <tree.h>
-#include <parser.h>
+#include <unistd.h>
+#include <xmlmemory.h>
+#include <zlib.h>
typedef struct {
const char *name;
@@ -965,6 +963,7 @@ fmt_scrollkeeper_parse_toc_section (HyperbolaDocTree * tree, char **ancestors,
{
xmlNodePtr next_child;
+ char *content;
char **section;
char *sect_uri;
int i, pos;
@@ -972,12 +971,13 @@ fmt_scrollkeeper_parse_toc_section (HyperbolaDocTree * tree, char **ancestors,
char separator[2] = { '\0' };
- next_child = node->childs;
+ next_child = node->xmlChildrenNode;
/* Set up the positioning information for the HyperbolaDocTree */
section = fmt_scrollkeeper_expand_ancestor_list (ancestors, &i);
- section[i] =
- g_strdup_printf ("%03d. %s", this_pos, next_child->content);
+ content = xmlNodeGetContent (next_child);
+ section[i] = g_strdup_printf ("%03d. %s", this_pos, content);
+ xmlFree (content);
section[i + 1] = NULL;
/*
@@ -1019,8 +1019,6 @@ fmt_scrollkeeper_parse_toc_section (HyperbolaDocTree * tree, char **ancestors,
g_free (sect_uri);
g_free (section[i]);
g_free (section);
-
- return;
}
/*
@@ -1079,7 +1077,7 @@ fmt_scrollkeeper_parse_doc_toc (HyperbolaDocTree * tree, char **ancestors,
}
/* Process the top-level tocsect nodes in the file */
- for (pos = 1, next_child = toc_doc->root->childs; next_child != NULL;
+ for (pos = 1, next_child = toc_doc->xmlRootNode->xmlChildrenNode; next_child != NULL;
next_child = next_child->next) {
if (!g_strncasecmp (next_child->name, "tocsect", 7)) {
fmt_scrollkeeper_parse_toc_section (tree, ancestors,
@@ -1091,8 +1089,6 @@ fmt_scrollkeeper_parse_doc_toc (HyperbolaDocTree * tree, char **ancestors,
}
xmlFreeDoc (toc_doc);
-
- return;
}
@@ -1133,21 +1129,17 @@ fmt_scrollkeeper_parse_document (HyperbolaDocTree * tree, char **ancestors,
toc_location = g_new0 (char, 1024);
- next_child = node->childs;
+ next_child = node->xmlChildrenNode;
/* Obtain info about the document from the XML node describing it */
for (; next_child != NULL; next_child = next_child->next) {
if (!g_strcasecmp (next_child->name, "doctitle")) {
- doc_data[0] = next_child->childs->content;
- }
-
- else if (!g_strcasecmp (next_child->name, "docsource")) {
- doc_data[1] = next_child->childs->content;
- }
-
- else if (!g_strcasecmp (next_child->name, "docformat")) {
- doc_data[2] = next_child->childs->content;
+ doc_data[0] = xmlNodeGetContent (next_child->xmlChildrenNode);
+ } else if (!g_strcasecmp (next_child->name, "docsource")) {
+ doc_data[1] = xmlNodeGetContent (next_child->xmlChildrenNode);
+ } else if (!g_strcasecmp (next_child->name, "docformat")) {
+ doc_data[2] = xmlNodeGetContent (next_child->xmlChildrenNode);
}
}
@@ -1171,6 +1163,9 @@ fmt_scrollkeeper_parse_document (HyperbolaDocTree * tree, char **ancestors,
/* If not a type we deal with then don't do anything else */
g_free (section);
g_free (toc_location);
+ xmlFree (doc_data[0]);
+ xmlFree (doc_data[1]);
+ xmlFree (doc_data[2]);
return;
}
@@ -1201,8 +1196,9 @@ fmt_scrollkeeper_parse_document (HyperbolaDocTree * tree, char **ancestors,
g_free (toc_location);
g_free (doc_uri);
g_free (section);
-
- return;
+ xmlFree (doc_data[0]);
+ xmlFree (doc_data[1]);
+ xmlFree (doc_data[2]);
}
@@ -1230,11 +1226,11 @@ fmt_scrollkeeper_parse_section (HyperbolaDocTree * tree, char **ancestors,
char **section;
int i;
- next_child = node->childs;
+ next_child = node->xmlChildrenNode;
/* Make space for this level and add the title of this node to the path */
section = fmt_scrollkeeper_expand_ancestor_list (ancestors, &i);
- section[i] = next_child->childs->content;
+ section[i] = xmlNodeGetContent (next_child->xmlChildrenNode);
section[i + 1] = NULL;
/* There is no URI so use this function instead */
@@ -1251,10 +1247,8 @@ fmt_scrollkeeper_parse_section (HyperbolaDocTree * tree, char **ancestors,
}
}
- /* Don't own the individual pointers so only free the double pointer */
+ xmlFree (section[i]);
g_free (section);
-
- return;
}
@@ -1276,19 +1270,17 @@ fmt_scrollkeeper_parse_xml (HyperbolaDocTree * tree, char **defpath,
xmlNodePtr node;
/* Ensure the document is valid and a real ScrollKeeper document */
- if (!doc->root || !doc->root->name ||
- g_strcasecmp (doc->root->name, "ScrollKeeperContentsList")) {
+ if (!doc->xmlRootNode || !doc->xmlRootNode->name ||
+ g_strcasecmp (doc->xmlRootNode->name, "ScrollKeeperContentsList")) {
g_warning ("Invalid ScrollKeeper XML Contents List!");
return;
}
/* Start parsing the list and add to the tree */
- for (node = doc->root->childs; node != NULL; node = node->next) {
+ for (node = doc->xmlRootNode->xmlChildrenNode; node != NULL; node = node->next) {
if (!g_strcasecmp (node->name, "sect"))
fmt_scrollkeeper_parse_section (tree, defpath, node);
}
-
- return;
}
/* trim empty (the ones that don't have docs in them ) branches from
@@ -1310,12 +1302,12 @@ fmt_scrollkeeper_trim_empty_branches (xmlNodePtr cl_node)
next = node->next;
if (!strcmp (node->name, "sect") &&
- node->childs->next !=
+ node->xmlChildrenNode->next !=
NULL) fmt_scrollkeeper_trim_empty_branches (node->
- childs->next);
+ xmlChildrenNode->next);
if (!strcmp (node->name, "sect") &&
- node->childs->next == NULL) {
+ node->xmlChildrenNode->next == NULL) {
xmlUnlinkNode (node);
xmlFreeNode (node);
}
@@ -1336,8 +1328,8 @@ fmt_scrollkeeper_tree_empty (xmlNodePtr cl_node)
next = node->next;
if (!strcmp (node->name, "sect") &&
- node->childs->next != NULL) {
- ret_val = fmt_scrollkeeper_tree_empty (node->childs->next);
+ node->xmlChildrenNode->next != NULL) {
+ ret_val = fmt_scrollkeeper_tree_empty (node->xmlChildrenNode->next);
if (!ret_val)
return ret_val;
}
@@ -1424,7 +1416,7 @@ fmt_scrollkeeper_populate_tree (HyperbolaDocTree * tree)
node = node->next) {
doc = fmt_scrollkeeper_get_xml_tree_of_locale (node->data);
if (doc != NULL) {
- if (doc->root != NULL && !fmt_scrollkeeper_tree_empty(doc->root->childs)) {
+ if (doc->xmlRootNode != NULL && !fmt_scrollkeeper_tree_empty(doc->xmlRootNode->xmlChildrenNode)) {
break;
} else {
xmlFreeDoc (doc);
@@ -1434,15 +1426,14 @@ fmt_scrollkeeper_populate_tree (HyperbolaDocTree * tree)
}
if (doc) {
- fmt_scrollkeeper_trim_empty_branches (doc->root->childs);
+ fmt_scrollkeeper_trim_empty_branches (doc->xmlRootNode->xmlChildrenNode);
fmt_scrollkeeper_parse_xml (tree, tree_path, doc);
xmlFreeDoc (doc);
}
-
- return;
}
-static char* remove_leading_and_trailing_white_spaces (char * str)
+static char *
+remove_leading_and_trailing_white_spaces (char * str)
{
int i, len;
@@ -1463,7 +1454,8 @@ static char* remove_leading_and_trailing_white_spaces (char * str)
return str;
}
-static void fmt_toplevel_add_doc (HyperbolaDocTree * tree, char * omf_name)
+static void
+fmt_toplevel_add_doc (HyperbolaDocTree * tree, char * omf_name)
{
xmlDocPtr doc;
xmlNodePtr node;
@@ -1481,29 +1473,28 @@ static void fmt_toplevel_add_doc (HyperbolaDocTree * tree, char * omf_name)
if (doc == NULL)
return;
- if (doc->root == NULL || doc->root->childs == NULL ||
- doc->root->childs->childs == NULL) {
+ if (doc->xmlRootNode == NULL || doc->xmlRootNode->xmlChildrenNode == NULL ||
+ doc->xmlRootNode->xmlChildrenNode->xmlChildrenNode == NULL) {
xmlFreeDoc(doc);
return;
}
- for(node = doc->root->childs->childs; node != NULL;
+ for(node = doc->xmlRootNode->xmlChildrenNode->xmlChildrenNode; node != NULL;
node = node->next) {
if (!strcmp(node->name, "identifier")) {
doc_path = xmlGetProp(node, "url");
uri = g_strconcat("gnome-help:", doc_path, NULL);
}
- if (!strcmp(node->name, "title") &&
- node->childs != NULL &&
- node->childs->content != NULL) {
-
+ if (!strcmp(node->name, "title")) {
char *ptr;
- ptr = g_strdup(node->childs->content);
- str = remove_leading_and_trailing_white_spaces(ptr);
- title = g_strconcat(prefix, str, NULL);
- g_free(ptr);
+ ptr = xmlNodeGetContent (node->xmlChildrenNode);
+ if (ptr != NULL) {
+ str = remove_leading_and_trailing_white_spaces (ptr);
+ title = g_strconcat (prefix, str, NULL);
+ xmlFree (ptr);
+ }
}
}
@@ -1606,15 +1597,24 @@ get_path_from_node (const char *omf_dir, xmlNode *docpath_node)
{
char *str, *omf_path, *omf_name;
- str = g_strdup (docpath_node->childs->content);
+ str = xmlNodeGetContent (docpath_node->xmlChildrenNode);
omf_name = remove_leading_and_trailing_white_spaces (str);
omf_path = g_strdup_printf ("%s/%s", omf_dir, omf_name);
- g_free (str);
+ xmlFree (str);
return omf_path;
}
+static gboolean
+has_content (xmlNodePtr node)
+{
+ xmlChar *content;
+
+ content = xmlNodeGetContent (node);
+ xmlFree (content);
+ return content != NULL;
+}
/* Note: Locales should include "C" as the last element. Basically for use
* with locales lists returned by gnome_i18n_get_language_list. */
@@ -1629,7 +1629,7 @@ fmt_toplevel_parse_xml_tree (HyperbolaDocTree * tree,
int bytes_read;
gboolean node_added;
- if (doc == NULL || doc->root == NULL)
+ if (doc == NULL || doc->xmlRootNode == NULL)
return FALSE;
if (locales == NULL)
@@ -1653,7 +1653,7 @@ fmt_toplevel_parse_xml_tree (HyperbolaDocTree * tree,
node_added = FALSE;
- for(doc_node = doc->root->childs; doc_node != NULL;
+ for(doc_node = doc->xmlRootNode->xmlChildrenNode; doc_node != NULL;
doc_node = doc_node->next) {
/* nothing found yet */
@@ -1661,12 +1661,11 @@ fmt_toplevel_parse_xml_tree (HyperbolaDocTree * tree,
/* check out the doc for the current locale */
- for(docpath_node = doc_node->childs;
+ for(docpath_node = doc_node->xmlChildrenNode;
docpath_node != NULL;
docpath_node = docpath_node->next) {
/* check validity of the node first */
- if (docpath_node->childs != NULL
- && docpath_node->childs->content != NULL
+ if (has_content (docpath_node->xmlChildrenNode)
&& is_new_locale_better (locales,
best_path_node,
docpath_node)) {
diff --git a/icons/ardmore/.cvsignore b/icons/ardmore/.cvsignore
deleted file mode 100644
index 1a195c560..000000000
--- a/icons/ardmore/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-.thumbnails \ No newline at end of file
diff --git a/icons/arlo/.cvsignore b/icons/arlo/.cvsignore
deleted file mode 100644
index 1a195c560..000000000
--- a/icons/arlo/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-.thumbnails \ No newline at end of file
diff --git a/icons/arlo/backgrounds/.cvsignore b/icons/arlo/backgrounds/.cvsignore
deleted file mode 100644
index 1a195c560..000000000
--- a/icons/arlo/backgrounds/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-.thumbnails \ No newline at end of file
diff --git a/icons/arlo/sidebar_tab_pieces/.cvsignore b/icons/arlo/sidebar_tab_pieces/.cvsignore
deleted file mode 100644
index 1a195c560..000000000
--- a/icons/arlo/sidebar_tab_pieces/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-.thumbnails \ No newline at end of file
diff --git a/icons/villanova/.cvsignore b/icons/villanova/.cvsignore
deleted file mode 100644
index 1a195c560..000000000
--- a/icons/villanova/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-.thumbnails \ No newline at end of file
diff --git a/libnautilus-extensions/nautilus-bookmark.c b/libnautilus-extensions/nautilus-bookmark.c
index badc7005d..3c16da5fe 100644
--- a/libnautilus-extensions/nautilus-bookmark.c
+++ b/libnautilus-extensions/nautilus-bookmark.c
@@ -307,32 +307,36 @@ static gboolean
nautilus_bookmark_icon_is_different (NautilusBookmark *bookmark,
NautilusScalableIcon *new_icon)
{
- char *new_uri, *new_name;
- char *old_uri, *old_name;
+ char *new_uri, *new_mime_type, *new_name;
+ char *old_uri, *old_mime_type, *old_name;
gboolean result;
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (new_icon != NULL);
- /* Bookmarks only care about the uri and name. */
+ /* Bookmarks don't store the modifier or embedded text. */
nautilus_scalable_icon_get_text_pieces
- (new_icon, &new_uri, &new_name, NULL, NULL);
+ (new_icon, &new_uri, &new_mime_type, &new_name, NULL, NULL);
if (bookmark->details->icon == NULL) {
result = !eel_str_is_empty (new_uri)
+ || !eel_str_is_empty (new_mime_type)
|| !eel_str_is_empty (new_name);
} else {
nautilus_scalable_icon_get_text_pieces
- (bookmark->details->icon, &old_uri, &old_name, NULL, NULL);
+ (bookmark->details->icon, &old_uri, &old_mime_type, &old_name, NULL, NULL);
result = eel_strcmp (old_uri, new_uri) != 0
+ || eel_strcmp (old_mime_type, new_mime_type) != 0
|| eel_strcmp (old_name, new_name) != 0;
g_free (old_uri);
+ g_free (old_mime_type);
g_free (old_name);
}
g_free (new_uri);
+ g_free (new_mime_type);
g_free (new_name);
return result;
@@ -438,7 +442,7 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
icon_name = GENERIC_BOOKMARK_ICON_NAME;
}
bookmark->details->icon = nautilus_scalable_icon_new_from_text_pieces
- (NULL, icon_name, NULL, NULL);
+ (NULL, NULL, icon_name, NULL, NULL);
}
/**
diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c
index 94982a25e..83728fb71 100644
--- a/libnautilus-extensions/nautilus-icon-factory.c
+++ b/libnautilus-extensions/nautilus-icon-factory.c
@@ -70,7 +70,6 @@ static const char *icon_file_name_suffixes[] =
{
".svg",
".SVG",
- "",
".png",
".PNG",
".gif",
@@ -198,6 +197,7 @@ struct NautilusScalableIcon {
guint ref_count;
char *uri;
+ char *mime_type;
char *name;
char *modifier;
char *embedded_text;
@@ -738,23 +738,51 @@ set_theme (const char *theme_name)
signals[ICONS_CHANGED]);
}
+static char *
+get_mime_type_icon_without_suffix (const char *mime_type)
+{
+ const char *with_suffix, *suffix;
+ guint i;
+
+ with_suffix = gnome_vfs_mime_get_icon (mime_type);
+ if (with_suffix == NULL) {
+ return NULL;
+ }
+
+ for (i = 0; i < EEL_N_ELEMENTS (icon_file_name_suffixes); i++) {
+ suffix = icon_file_name_suffixes[i];
+ if (eel_str_has_suffix (with_suffix, suffix)) {
+ return eel_str_strip_trailing_str (with_suffix, suffix);
+ }
+ }
+
+ return g_strdup (with_suffix);
+}
+
+static char *
+make_icon_name_from_mime_type (const char *mime_type)
+{
+ char *mime_type_without_slashes, *icon_name;
+
+ if (mime_type == NULL) {
+ return NULL;
+ }
+
+ mime_type_without_slashes = eel_str_replace_substring
+ (mime_type, "/", "-");
+ icon_name = g_strconcat ("gnome-", mime_type_without_slashes, NULL);
+ g_free (mime_type_without_slashes);
+ return icon_name;
+}
/* Use the MIME type to get the icon name. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_regular_file (NautilusFile *file)
+static char *
+get_icon_name_for_regular_file (NautilusFile *file)
{
const char *icon_name;
char *mime_type, *uri;
mime_type = nautilus_file_get_mime_type (file);
- if (mime_type != NULL) {
- icon_name = gnome_vfs_mime_get_icon (mime_type);
- if (icon_name != NULL) {
- g_free (mime_type);
- return icon_name;
- }
- }
-
uri = nautilus_file_get_uri (file);
/* Special-case icons based on the uri scheme. Eventually we
@@ -778,12 +806,12 @@ nautilus_icon_factory_get_icon_name_for_regular_file (NautilusFile *file)
g_free (uri);
g_free (mime_type);
- return icon_name;
+ return g_strdup (icon_name);
}
/* Use the MIME type to get the icon name. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
+static char *
+get_icon_name_for_directory (NautilusFile *file)
{
const char *icon_name;
char *mime_type;
@@ -798,43 +826,43 @@ nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
g_free (mime_type);
- return icon_name;
+ return g_strdup (icon_name);
}
/* Get the icon name for a file. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_file (NautilusFile *file)
-{
+static char *
+get_icon_name_for_file (NautilusFile *file)
+{
char *uri;
uri = nautilus_file_get_uri (file);
if (strcmp (uri, EEL_TRASH_URI) == 0) {
g_free (uri);
- return nautilus_trash_monitor_is_empty ()
- ? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY;
+ return g_strdup (nautilus_trash_monitor_is_empty ()
+ ? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY);
}
g_free (uri);
/* Get an icon name based on the file's type. */
switch (nautilus_file_get_file_type (file)) {
case GNOME_VFS_FILE_TYPE_DIRECTORY:
- return nautilus_icon_factory_get_icon_name_for_directory (file);
+ return get_icon_name_for_directory (file);
case GNOME_VFS_FILE_TYPE_FIFO:
- return ICON_NAME_FIFO;
+ return g_strdup (ICON_NAME_FIFO);
case GNOME_VFS_FILE_TYPE_SOCKET:
- return ICON_NAME_SOCKET;
+ return g_strdup (ICON_NAME_SOCKET);
case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
- return ICON_NAME_CHARACTER_DEVICE;
+ return g_strdup (ICON_NAME_CHARACTER_DEVICE);
case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
- return ICON_NAME_BLOCK_DEVICE;
+ return g_strdup (ICON_NAME_BLOCK_DEVICE);
case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
/* Non-broken symbolic links return the target's type. */
- return ICON_NAME_BROKEN_SYMBOLIC_LINK;
+ return g_strdup (ICON_NAME_BROKEN_SYMBOLIC_LINK);
case GNOME_VFS_FILE_TYPE_REGULAR:
case GNOME_VFS_FILE_TYPE_UNKNOWN:
default:
- return nautilus_icon_factory_get_icon_name_for_regular_file (file);
+ return get_icon_name_for_regular_file (file);
}
}
@@ -846,22 +874,31 @@ make_full_icon_path (const char *path,
char *partial_path, *full_path;
char *user_directory, *themes_directory;
+ partial_path = g_strconcat (path, suffix, NULL);
+
if (path[0] == '/') {
- return g_strconcat (path, suffix, NULL);
+ return partial_path;
}
/* Build a path for this icon, depending on the theme_is_in_user_directory boolean. */
- partial_path = g_strconcat (path, suffix, NULL);
if (theme_is_in_user_directory) {
user_directory = nautilus_get_user_directory ();
themes_directory = nautilus_make_path (user_directory, "themes");
full_path = nautilus_make_path (themes_directory, partial_path);
g_free (user_directory);
g_free (themes_directory);
+ if (!g_file_exists (full_path)) {
+ g_free (full_path);
+ full_path = NULL;
+ }
} else {
full_path = nautilus_pixmap_file (partial_path);
}
+ if (full_path == NULL) {
+ full_path = gnome_vfs_icon_path_from_filename (partial_path);
+ }
+
g_free (partial_path);
return full_path;
}
@@ -930,7 +967,7 @@ get_themed_icon_file_path (const char *theme_name,
/* Try each suffix. */
for (i = 0; i < EEL_N_ELEMENTS (icon_file_name_suffixes); i++) {
- if (include_size && strcasecmp(icon_file_name_suffixes[i], ".svg")) {
+ if (include_size && strcasecmp (icon_file_name_suffixes[i], ".svg") != 0) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s-%u",
themed_icon_name,
@@ -948,7 +985,7 @@ get_themed_icon_file_path (const char *theme_name,
g_free (aa_path);
/* Return the path if the file exists. */
- if (path != NULL && g_file_exists (path)) {
+ if (path != NULL) {
break;
}
@@ -962,9 +999,10 @@ get_themed_icon_file_path (const char *theme_name,
g_free (partial_path);
/* Return the path if the file exists. */
- if (path != NULL && g_file_exists (path)) {
+ if (path != NULL) {
break;
}
+
g_free (path);
path = NULL;
}
@@ -987,14 +1025,13 @@ get_themed_icon_file_path (const char *theme_name,
property = NULL;
if (optimized_for_aa) {
- property = xmlGetProp (node, "embedded_text_rectangle_aa");
+ property = xmlGetProp (node, "embedded_text_rectangle_aa");
}
if (property == NULL) {
- property = xmlGetProp (node, "embedded_text_rectangle");
+ property = xmlGetProp (node, "embedded_text_rectangle");
}
if (property != NULL) {
-
if (sscanf (property,
" %d , %d , %d , %d %*s",
&parsed_rect.x0,
@@ -1041,14 +1078,10 @@ get_themed_icon_file_path (const char *theme_name,
g_free (path);
path = NULL;
- }
+ }
}
g_free (themed_icon_name);
- if (path == NULL) {
- path = gnome_vfs_icon_path_from_filename (icon_name);
- }
-
return path;
}
@@ -1180,6 +1213,7 @@ mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_dat
void
nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
char **uri_return,
+ char **mime_type_return,
char **name_return,
char **modifier_return,
char **embedded_text_return)
@@ -1189,6 +1223,9 @@ nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
if (uri_return != NULL) {
*uri_return = g_strdup (icon->uri);
}
+ if (mime_type_return != NULL) {
+ *mime_type_return = g_strdup (icon->mime_type);
+ }
if (name_return != NULL) {
*name_return = g_strdup (icon->name);
}
@@ -1198,11 +1235,12 @@ nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
if (embedded_text_return != NULL) {
*embedded_text_return = g_strdup (icon->embedded_text);
}
-}
+}
/* Get or create a scalable icon from text pieces. */
NautilusScalableIcon *
nautilus_scalable_icon_new_from_text_pieces (const char *uri,
+ const char *mime_type,
const char *name,
const char *modifier,
const char *embedded_text)
@@ -1216,6 +1254,9 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
if (uri != NULL && uri[0] == '\0') {
uri = NULL;
}
+ if (mime_type != NULL && mime_type[0] == '\0') {
+ mime_type = NULL;
+ }
if (name != NULL && name[0] == '\0') {
name = NULL;
}
@@ -1231,6 +1272,7 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
/* Check to see if it's already in the table. */
cache_key.uri = (char *) uri;
+ cache_key.mime_type = (char *) mime_type;
cache_key.name = (char *) name;
cache_key.modifier = (char *) modifier;
cache_key.embedded_text = (char *) embedded_text;
@@ -1240,6 +1282,7 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
/* Not in the table, so create it and put it in. */
icon = g_new0 (NautilusScalableIcon, 1);
icon->uri = g_strdup (uri);
+ icon->mime_type = g_strdup (mime_type);
icon->name = g_strdup (name);
icon->modifier = g_strdup (modifier);
icon->embedded_text = g_strdup (embedded_text);
@@ -1275,6 +1318,7 @@ nautilus_scalable_icon_unref (NautilusScalableIcon *icon)
g_hash_table_remove (hash_table, icon);
g_free (icon->uri);
+ g_free (icon->mime_type);
g_free (icon->name);
g_free (icon->modifier);
g_free (icon->embedded_text);
@@ -1295,6 +1339,11 @@ nautilus_scalable_icon_hash (gconstpointer p)
}
hash <<= 4;
+ if (icon->mime_type != NULL) {
+ hash ^= g_str_hash (icon->mime_type);
+ }
+
+ hash <<= 4;
if (icon->name != NULL) {
hash ^= g_str_hash (icon->name);
}
@@ -1322,6 +1371,7 @@ nautilus_scalable_icon_equal (gconstpointer a,
icon_b = b;
return eel_strcmp (icon_a->uri, icon_b->uri) == 0
+ && eel_strcmp (icon_a->mime_type, icon_b->mime_type) == 0
&& eel_strcmp (icon_a->name, icon_b->name) == 0
&& eel_strcmp (icon_a->modifier, icon_b->modifier) == 0
&& eel_strcmp (icon_a->embedded_text, icon_b->embedded_text) == 0;
@@ -1398,6 +1448,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
file_uri = nautilus_file_get_uri (file);
is_local = nautilus_file_is_local (file);
+ mime_type = nautilus_file_get_mime_type (file);
/* if the file is an image, either use the image itself as the icon if it's small enough,
or use a thumbnail if one exists. If it's too large, don't try to thumbnail it at all.
@@ -1436,7 +1487,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
/* also, dont make thumbnails for images in the thumbnails directory */
if (uri == NULL) {
- mime_type = nautilus_file_get_mime_type (file);
file_size = nautilus_file_get_size (file);
/* FIXME: This has to be done later, when we know
@@ -1446,7 +1496,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
&& is_supported_mime_type (mime_type)
&& should_display_image_file_as_itself (file, TRUE)) {
if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD && is_local) {
- uri = nautilus_file_get_uri (file);
+ uri = nautilus_file_get_uri (file);
} else if (strstr (file_uri, "/.thumbnails/") == NULL
&& file_size < cached_thumbnail_limit) {
uri = nautilus_get_thumbnail_uri (file, TRUE);
@@ -1455,7 +1505,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
}
}
- g_free (mime_type);
}
/* Handle nautilus link xml files, which may specify their own image */
@@ -1465,22 +1514,25 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
if (file_path != NULL) {
image_uri = nautilus_link_local_get_image_uri (file_path);
if (image_uri != NULL) {
- /* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file:// URIs? */
- if (eel_istr_has_prefix (image_uri, "file://")) {
- if (uri == NULL) {
- uri = image_uri;
- } else {
- g_free (image_uri);
- }
- } else {
- icon_name = image_uri;
- }
+ /* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file: URIs? */
+ if (eel_istr_has_prefix (image_uri, "file://")) {
+ if (uri == NULL) {
+ uri = image_uri;
+ } else {
+ g_free (image_uri);
+ }
+ } else {
+ icon_name = image_uri;
+ }
}
g_free (file_path);
}
}
- if (uri == NULL && nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+ /* Handle .desktop files. */
+ if (uri == NULL
+ && nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+ /* FIXME bugzilla.eazel.com 2563: This does sync. I/O and only works for local paths. */
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
if (file_path != NULL) {
entry = gnome_desktop_entry_load (file_path);
@@ -1495,23 +1547,25 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
/* handle SVG files */
- if (uri == NULL && icon_name == NULL && nautilus_file_is_mime_type (file, "image/svg")) {
+ if (uri == NULL && icon_name == NULL
+ && nautilus_file_is_mime_type (file, "image/svg")) {
uri = g_strdup (file_uri);
}
/* Get the generic icon set for this file. */
g_free (file_uri);
if (icon_name == NULL) {
- icon_name = g_strdup (nautilus_icon_factory_get_icon_name_for_file (file));
+ icon_name = get_icon_name_for_file (file);
}
top_left_text = nautilus_file_get_top_left_text (file);
/* Create the icon or find it in the cache if it's already there. */
scalable_icon = nautilus_scalable_icon_new_from_text_pieces
- (uri, icon_name, modifier, top_left_text);
+ (uri, mime_type, icon_name, modifier, top_left_text);
g_free (uri);
+ g_free (mime_type);
g_free (icon_name);
g_free (top_left_text);
@@ -1567,7 +1621,7 @@ nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name)
name_with_prefix = g_strconcat (EMBLEM_NAME_PREFIX, emblem_name, NULL);
scalable_icon = nautilus_scalable_icon_new_from_text_pieces
- (NULL, name_with_prefix, NULL, NULL);
+ (NULL, NULL, name_with_prefix, NULL, NULL);
g_free (name_with_prefix);
return scalable_icon;
@@ -1696,7 +1750,7 @@ get_next_icon_size_to_try (guint target_size, guint *current_size)
/* This loads an SVG image, scaling it to the appropriate size. */
static GdkPixbuf *
-load_pixbuf_svg (const char *path, const char *name, guint size_in_pixels)
+load_pixbuf_svg (const char *path, guint size_in_pixels, gboolean is_emblem)
{
FILE *f;
GdkPixbuf *pixbuf;
@@ -1708,10 +1762,10 @@ load_pixbuf_svg (const char *path, const char *name, guint size_in_pixels)
}
/* FIXME: the nominal size of .svg emblems is too large, so we scale it
- * down here if the file is an emblem. This code should be removed
- * eventually when we scale all the emblems properly.
+ * down here if the file is an emblem. This code should be removed
+ * when we scale all the emblems properly.
*/
- if (eel_str_has_prefix (name, EMBLEM_NAME_PREFIX)) {
+ if (is_emblem) {
actual_size_in_pixels = size_in_pixels * EMBLEM_SCALE_FACTOR;
} else {
actual_size_in_pixels = size_in_pixels;
@@ -1780,6 +1834,51 @@ get_cache_time (const char *file_uri, time_t *cache_time)
return result;
}
+static GdkPixbuf *
+load_icon_from_path (const char *path,
+ guint size_in_pixels,
+ gboolean custom,
+ gboolean is_emblem) /* for emblem scaling hack only */
+{
+ /* Get the icon. */
+ if (path == NULL) {
+ return NULL;
+ }
+ if (path_represents_svg_image (path)) {
+ return load_pixbuf_svg (path, size_in_pixels, is_emblem);
+ }
+ /* Custom non-svg icons exist at one size.
+ * Non-custom icons have their size encoded in their path.
+ */
+ if (custom && size_in_pixels != NAUTILUS_ICON_SIZE_STANDARD) {
+ return NULL;
+ }
+ return gdk_pixbuf_new_from_file (path);
+}
+
+static GdkPixbuf *
+load_named_icon (const char *name,
+ const char *modifier,
+ guint size_in_pixels,
+ gboolean optimized_for_aa,
+ IconDetails *details)
+{
+ char *path;
+ GdkPixbuf *pixbuf;
+
+ path = get_icon_file_path (name, modifier,
+ size_in_pixels, optimized_for_aa,
+ details);
+ pixbuf = load_icon_from_path (path, size_in_pixels, FALSE,
+ eel_str_has_prefix (name, EMBLEM_NAME_PREFIX));
+ g_free (path);
+
+ if (pixbuf == NULL) {
+ memset (&details, 0, sizeof (details));
+ }
+ return pixbuf;
+}
+
/* This load function returns NULL if the icon is not available at
* this size.
*/
@@ -1791,6 +1890,7 @@ load_specific_icon (NautilusScalableIcon *scalable_icon,
{
IconDetails details;
GdkPixbuf *pixbuf;
+ char *icon_name;
char *path;
CacheIcon *icon;
@@ -1801,39 +1901,37 @@ load_specific_icon (NautilusScalableIcon *scalable_icon,
if (custom) {
/* We don't support custom icons that are not local here. */
path = gnome_vfs_get_local_path_from_uri (scalable_icon->uri);
+ pixbuf = load_icon_from_path (path, size_in_pixels, TRUE, FALSE);
+ g_free (path);
} else {
- path = get_icon_file_path (scalable_icon->name,
- scalable_icon->modifier,
- size_in_pixels,
- optimized_for_aa,
- &details);
- }
-
- /* Get the icon. */
- if (path != NULL) {
- if (path_represents_svg_image (path)) {
- pixbuf = load_pixbuf_svg (path, scalable_icon->name, size_in_pixels);
- } else {
- /* Custom non-svg icons exist at one size.
- * Non-custom icons have their size encoded in their path.
+ pixbuf = load_named_icon (scalable_icon->name,
+ scalable_icon->modifier,
+ size_in_pixels, optimized_for_aa,
+ &details);
+ if (pixbuf == NULL) {
+ /* Use the type in the MIME database, or turn the MIME
+ * type into an icon name.
*/
- if (!(custom && size_in_pixels != NAUTILUS_ICON_SIZE_STANDARD)) {
- pixbuf = gdk_pixbuf_new_from_file (path);
+ icon_name = get_mime_type_icon_without_suffix (scalable_icon->mime_type);
+ if (icon_name == NULL) {
+ icon_name = make_icon_name_from_mime_type (scalable_icon->mime_type);
}
+ if (icon_name != NULL && eel_strcmp (icon_name, scalable_icon->name) != 0) {
+ pixbuf = load_named_icon (icon_name, scalable_icon->modifier,
+ size_in_pixels, optimized_for_aa,
+ &details);
+ }
+ g_free (icon_name);
}
-
- g_free (path);
}
- /* If we got nothing, we can free the icon. */
if (pixbuf == NULL) {
return NULL;
}
/* Since we got something, we can create a cache icon. */
icon = cache_icon_new (pixbuf, custom, FALSE, &details);
- get_cache_time (scalable_icon->uri,
- &icon->cache_time);
+ get_cache_time (scalable_icon->uri, &icon->cache_time);
gdk_pixbuf_unref (pixbuf);
return icon;
@@ -2099,7 +2197,7 @@ mark_recently_used (CircularList *node)
check_recently_used_list ();
}
-/* Utility routine that checks if a cached thubmnail-type icon has
+/* Utility routine that checks if a cached thumbnail-type icon has
* changed since it was cached. Returns TRUE after removing the icon
* from the cache if the icon has changed.
*/
@@ -2404,17 +2502,17 @@ nautilus_icon_factory_get_pixmap_and_mask_for_file (NautilusFile *file,
gdk_pixbuf_unref (pixbuf);
}
-/* Convenience routine for getting a pixbuf from an icon name
- */
-GdkPixbuf * nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
- const char *modifier,
- guint size_in_pixels,
- gboolean optimized_for_aa)
+/* Convenience routine for getting a pixbuf from an icon name. */
+GdkPixbuf *
+nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
+ const char *modifier,
+ guint size_in_pixels,
+ gboolean optimized_for_aa)
{
GdkPixbuf *pixbuf;
NautilusScalableIcon *icon;
- icon = nautilus_scalable_icon_new_from_text_pieces (NULL, icon_name, modifier, NULL);
+ icon = nautilus_scalable_icon_new_from_text_pieces (NULL, NULL, icon_name, modifier, NULL);
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon (icon,
size_in_pixels, size_in_pixels,
size_in_pixels, size_in_pixels,
@@ -2539,6 +2637,7 @@ load_icon_with_embedded_text (NautilusScalableIcon *scalable_icon,
/* Get the icon without text. */
scalable_icon_without_text = nautilus_scalable_icon_new_from_text_pieces
(scalable_icon->uri,
+ scalable_icon->mime_type,
scalable_icon->name,
scalable_icon->modifier,
NULL);
diff --git a/libnautilus-extensions/nautilus-icon-factory.h b/libnautilus-extensions/nautilus-icon-factory.h
index 2bd3e5c7b..8c10173d6 100644
--- a/libnautilus-extensions/nautilus-icon-factory.h
+++ b/libnautilus-extensions/nautilus-icon-factory.h
@@ -162,6 +162,7 @@ void nautilus_scalable_icon_unref (Nautil
*/
void nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *scalable_icon,
char **uri_return,
+ char **mime_type_return,
char **name_return,
char **modifier_return,
char **embedded_text_return);
@@ -169,6 +170,7 @@ void nautilus_scalable_icon_get_text_pieces (Nautil
* nautilus_scalable_icon_get_text_pieces.
*/
NautilusScalableIcon *nautilus_scalable_icon_new_from_text_pieces (const char *uri,
+ const char *mime_type,
const char *name,
const char *modifier,
const char *embedded_text);
diff --git a/libnautilus-extensions/nautilus-trash-monitor.c b/libnautilus-extensions/nautilus-trash-monitor.c
index d3f9cc74d..a392c3d56 100644
--- a/libnautilus-extensions/nautilus-trash-monitor.c
+++ b/libnautilus-extensions/nautilus-trash-monitor.c
@@ -3,7 +3,7 @@
/*
nautilus-trash-monitor.c: Nautilus trash state watcher.
- Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2000, 2001 Eazel, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -197,6 +197,8 @@ nautilus_trash_monitor_get (void)
/* make sure we get signalled when trash directories get added */
nautilus_trash_directory_finish_initializing
(NAUTILUS_TRASH_DIRECTORY (trash_directory));
+
+ nautilus_directory_unref (trash_directory);
}
return nautilus_trash_monitor;
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index badc7005d..3c16da5fe 100644
--- a/libnautilus-private/nautilus-bookmark.c
+++ b/libnautilus-private/nautilus-bookmark.c
@@ -307,32 +307,36 @@ static gboolean
nautilus_bookmark_icon_is_different (NautilusBookmark *bookmark,
NautilusScalableIcon *new_icon)
{
- char *new_uri, *new_name;
- char *old_uri, *old_name;
+ char *new_uri, *new_mime_type, *new_name;
+ char *old_uri, *old_mime_type, *old_name;
gboolean result;
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (new_icon != NULL);
- /* Bookmarks only care about the uri and name. */
+ /* Bookmarks don't store the modifier or embedded text. */
nautilus_scalable_icon_get_text_pieces
- (new_icon, &new_uri, &new_name, NULL, NULL);
+ (new_icon, &new_uri, &new_mime_type, &new_name, NULL, NULL);
if (bookmark->details->icon == NULL) {
result = !eel_str_is_empty (new_uri)
+ || !eel_str_is_empty (new_mime_type)
|| !eel_str_is_empty (new_name);
} else {
nautilus_scalable_icon_get_text_pieces
- (bookmark->details->icon, &old_uri, &old_name, NULL, NULL);
+ (bookmark->details->icon, &old_uri, &old_mime_type, &old_name, NULL, NULL);
result = eel_strcmp (old_uri, new_uri) != 0
+ || eel_strcmp (old_mime_type, new_mime_type) != 0
|| eel_strcmp (old_name, new_name) != 0;
g_free (old_uri);
+ g_free (old_mime_type);
g_free (old_name);
}
g_free (new_uri);
+ g_free (new_mime_type);
g_free (new_name);
return result;
@@ -438,7 +442,7 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
icon_name = GENERIC_BOOKMARK_ICON_NAME;
}
bookmark->details->icon = nautilus_scalable_icon_new_from_text_pieces
- (NULL, icon_name, NULL, NULL);
+ (NULL, NULL, icon_name, NULL, NULL);
}
/**
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index 94982a25e..83728fb71 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -70,7 +70,6 @@ static const char *icon_file_name_suffixes[] =
{
".svg",
".SVG",
- "",
".png",
".PNG",
".gif",
@@ -198,6 +197,7 @@ struct NautilusScalableIcon {
guint ref_count;
char *uri;
+ char *mime_type;
char *name;
char *modifier;
char *embedded_text;
@@ -738,23 +738,51 @@ set_theme (const char *theme_name)
signals[ICONS_CHANGED]);
}
+static char *
+get_mime_type_icon_without_suffix (const char *mime_type)
+{
+ const char *with_suffix, *suffix;
+ guint i;
+
+ with_suffix = gnome_vfs_mime_get_icon (mime_type);
+ if (with_suffix == NULL) {
+ return NULL;
+ }
+
+ for (i = 0; i < EEL_N_ELEMENTS (icon_file_name_suffixes); i++) {
+ suffix = icon_file_name_suffixes[i];
+ if (eel_str_has_suffix (with_suffix, suffix)) {
+ return eel_str_strip_trailing_str (with_suffix, suffix);
+ }
+ }
+
+ return g_strdup (with_suffix);
+}
+
+static char *
+make_icon_name_from_mime_type (const char *mime_type)
+{
+ char *mime_type_without_slashes, *icon_name;
+
+ if (mime_type == NULL) {
+ return NULL;
+ }
+
+ mime_type_without_slashes = eel_str_replace_substring
+ (mime_type, "/", "-");
+ icon_name = g_strconcat ("gnome-", mime_type_without_slashes, NULL);
+ g_free (mime_type_without_slashes);
+ return icon_name;
+}
/* Use the MIME type to get the icon name. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_regular_file (NautilusFile *file)
+static char *
+get_icon_name_for_regular_file (NautilusFile *file)
{
const char *icon_name;
char *mime_type, *uri;
mime_type = nautilus_file_get_mime_type (file);
- if (mime_type != NULL) {
- icon_name = gnome_vfs_mime_get_icon (mime_type);
- if (icon_name != NULL) {
- g_free (mime_type);
- return icon_name;
- }
- }
-
uri = nautilus_file_get_uri (file);
/* Special-case icons based on the uri scheme. Eventually we
@@ -778,12 +806,12 @@ nautilus_icon_factory_get_icon_name_for_regular_file (NautilusFile *file)
g_free (uri);
g_free (mime_type);
- return icon_name;
+ return g_strdup (icon_name);
}
/* Use the MIME type to get the icon name. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
+static char *
+get_icon_name_for_directory (NautilusFile *file)
{
const char *icon_name;
char *mime_type;
@@ -798,43 +826,43 @@ nautilus_icon_factory_get_icon_name_for_directory (NautilusFile *file)
g_free (mime_type);
- return icon_name;
+ return g_strdup (icon_name);
}
/* Get the icon name for a file. */
-static const char *
-nautilus_icon_factory_get_icon_name_for_file (NautilusFile *file)
-{
+static char *
+get_icon_name_for_file (NautilusFile *file)
+{
char *uri;
uri = nautilus_file_get_uri (file);
if (strcmp (uri, EEL_TRASH_URI) == 0) {
g_free (uri);
- return nautilus_trash_monitor_is_empty ()
- ? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY;
+ return g_strdup (nautilus_trash_monitor_is_empty ()
+ ? ICON_NAME_TRASH_EMPTY : ICON_NAME_TRASH_NOT_EMPTY);
}
g_free (uri);
/* Get an icon name based on the file's type. */
switch (nautilus_file_get_file_type (file)) {
case GNOME_VFS_FILE_TYPE_DIRECTORY:
- return nautilus_icon_factory_get_icon_name_for_directory (file);
+ return get_icon_name_for_directory (file);
case GNOME_VFS_FILE_TYPE_FIFO:
- return ICON_NAME_FIFO;
+ return g_strdup (ICON_NAME_FIFO);
case GNOME_VFS_FILE_TYPE_SOCKET:
- return ICON_NAME_SOCKET;
+ return g_strdup (ICON_NAME_SOCKET);
case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
- return ICON_NAME_CHARACTER_DEVICE;
+ return g_strdup (ICON_NAME_CHARACTER_DEVICE);
case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
- return ICON_NAME_BLOCK_DEVICE;
+ return g_strdup (ICON_NAME_BLOCK_DEVICE);
case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
/* Non-broken symbolic links return the target's type. */
- return ICON_NAME_BROKEN_SYMBOLIC_LINK;
+ return g_strdup (ICON_NAME_BROKEN_SYMBOLIC_LINK);
case GNOME_VFS_FILE_TYPE_REGULAR:
case GNOME_VFS_FILE_TYPE_UNKNOWN:
default:
- return nautilus_icon_factory_get_icon_name_for_regular_file (file);
+ return get_icon_name_for_regular_file (file);
}
}
@@ -846,22 +874,31 @@ make_full_icon_path (const char *path,
char *partial_path, *full_path;
char *user_directory, *themes_directory;
+ partial_path = g_strconcat (path, suffix, NULL);
+
if (path[0] == '/') {
- return g_strconcat (path, suffix, NULL);
+ return partial_path;
}
/* Build a path for this icon, depending on the theme_is_in_user_directory boolean. */
- partial_path = g_strconcat (path, suffix, NULL);
if (theme_is_in_user_directory) {
user_directory = nautilus_get_user_directory ();
themes_directory = nautilus_make_path (user_directory, "themes");
full_path = nautilus_make_path (themes_directory, partial_path);
g_free (user_directory);
g_free (themes_directory);
+ if (!g_file_exists (full_path)) {
+ g_free (full_path);
+ full_path = NULL;
+ }
} else {
full_path = nautilus_pixmap_file (partial_path);
}
+ if (full_path == NULL) {
+ full_path = gnome_vfs_icon_path_from_filename (partial_path);
+ }
+
g_free (partial_path);
return full_path;
}
@@ -930,7 +967,7 @@ get_themed_icon_file_path (const char *theme_name,
/* Try each suffix. */
for (i = 0; i < EEL_N_ELEMENTS (icon_file_name_suffixes); i++) {
- if (include_size && strcasecmp(icon_file_name_suffixes[i], ".svg")) {
+ if (include_size && strcasecmp (icon_file_name_suffixes[i], ".svg") != 0) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s-%u",
themed_icon_name,
@@ -948,7 +985,7 @@ get_themed_icon_file_path (const char *theme_name,
g_free (aa_path);
/* Return the path if the file exists. */
- if (path != NULL && g_file_exists (path)) {
+ if (path != NULL) {
break;
}
@@ -962,9 +999,10 @@ get_themed_icon_file_path (const char *theme_name,
g_free (partial_path);
/* Return the path if the file exists. */
- if (path != NULL && g_file_exists (path)) {
+ if (path != NULL) {
break;
}
+
g_free (path);
path = NULL;
}
@@ -987,14 +1025,13 @@ get_themed_icon_file_path (const char *theme_name,
property = NULL;
if (optimized_for_aa) {
- property = xmlGetProp (node, "embedded_text_rectangle_aa");
+ property = xmlGetProp (node, "embedded_text_rectangle_aa");
}
if (property == NULL) {
- property = xmlGetProp (node, "embedded_text_rectangle");
+ property = xmlGetProp (node, "embedded_text_rectangle");
}
if (property != NULL) {
-
if (sscanf (property,
" %d , %d , %d , %d %*s",
&parsed_rect.x0,
@@ -1041,14 +1078,10 @@ get_themed_icon_file_path (const char *theme_name,
g_free (path);
path = NULL;
- }
+ }
}
g_free (themed_icon_name);
- if (path == NULL) {
- path = gnome_vfs_icon_path_from_filename (icon_name);
- }
-
return path;
}
@@ -1180,6 +1213,7 @@ mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_dat
void
nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
char **uri_return,
+ char **mime_type_return,
char **name_return,
char **modifier_return,
char **embedded_text_return)
@@ -1189,6 +1223,9 @@ nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
if (uri_return != NULL) {
*uri_return = g_strdup (icon->uri);
}
+ if (mime_type_return != NULL) {
+ *mime_type_return = g_strdup (icon->mime_type);
+ }
if (name_return != NULL) {
*name_return = g_strdup (icon->name);
}
@@ -1198,11 +1235,12 @@ nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *icon,
if (embedded_text_return != NULL) {
*embedded_text_return = g_strdup (icon->embedded_text);
}
-}
+}
/* Get or create a scalable icon from text pieces. */
NautilusScalableIcon *
nautilus_scalable_icon_new_from_text_pieces (const char *uri,
+ const char *mime_type,
const char *name,
const char *modifier,
const char *embedded_text)
@@ -1216,6 +1254,9 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
if (uri != NULL && uri[0] == '\0') {
uri = NULL;
}
+ if (mime_type != NULL && mime_type[0] == '\0') {
+ mime_type = NULL;
+ }
if (name != NULL && name[0] == '\0') {
name = NULL;
}
@@ -1231,6 +1272,7 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
/* Check to see if it's already in the table. */
cache_key.uri = (char *) uri;
+ cache_key.mime_type = (char *) mime_type;
cache_key.name = (char *) name;
cache_key.modifier = (char *) modifier;
cache_key.embedded_text = (char *) embedded_text;
@@ -1240,6 +1282,7 @@ nautilus_scalable_icon_new_from_text_pieces (const char *uri,
/* Not in the table, so create it and put it in. */
icon = g_new0 (NautilusScalableIcon, 1);
icon->uri = g_strdup (uri);
+ icon->mime_type = g_strdup (mime_type);
icon->name = g_strdup (name);
icon->modifier = g_strdup (modifier);
icon->embedded_text = g_strdup (embedded_text);
@@ -1275,6 +1318,7 @@ nautilus_scalable_icon_unref (NautilusScalableIcon *icon)
g_hash_table_remove (hash_table, icon);
g_free (icon->uri);
+ g_free (icon->mime_type);
g_free (icon->name);
g_free (icon->modifier);
g_free (icon->embedded_text);
@@ -1295,6 +1339,11 @@ nautilus_scalable_icon_hash (gconstpointer p)
}
hash <<= 4;
+ if (icon->mime_type != NULL) {
+ hash ^= g_str_hash (icon->mime_type);
+ }
+
+ hash <<= 4;
if (icon->name != NULL) {
hash ^= g_str_hash (icon->name);
}
@@ -1322,6 +1371,7 @@ nautilus_scalable_icon_equal (gconstpointer a,
icon_b = b;
return eel_strcmp (icon_a->uri, icon_b->uri) == 0
+ && eel_strcmp (icon_a->mime_type, icon_b->mime_type) == 0
&& eel_strcmp (icon_a->name, icon_b->name) == 0
&& eel_strcmp (icon_a->modifier, icon_b->modifier) == 0
&& eel_strcmp (icon_a->embedded_text, icon_b->embedded_text) == 0;
@@ -1398,6 +1448,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
file_uri = nautilus_file_get_uri (file);
is_local = nautilus_file_is_local (file);
+ mime_type = nautilus_file_get_mime_type (file);
/* if the file is an image, either use the image itself as the icon if it's small enough,
or use a thumbnail if one exists. If it's too large, don't try to thumbnail it at all.
@@ -1436,7 +1487,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
/* also, dont make thumbnails for images in the thumbnails directory */
if (uri == NULL) {
- mime_type = nautilus_file_get_mime_type (file);
file_size = nautilus_file_get_size (file);
/* FIXME: This has to be done later, when we know
@@ -1446,7 +1496,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
&& is_supported_mime_type (mime_type)
&& should_display_image_file_as_itself (file, TRUE)) {
if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD && is_local) {
- uri = nautilus_file_get_uri (file);
+ uri = nautilus_file_get_uri (file);
} else if (strstr (file_uri, "/.thumbnails/") == NULL
&& file_size < cached_thumbnail_limit) {
uri = nautilus_get_thumbnail_uri (file, TRUE);
@@ -1455,7 +1505,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
}
}
- g_free (mime_type);
}
/* Handle nautilus link xml files, which may specify their own image */
@@ -1465,22 +1514,25 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
if (file_path != NULL) {
image_uri = nautilus_link_local_get_image_uri (file_path);
if (image_uri != NULL) {
- /* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file:// URIs? */
- if (eel_istr_has_prefix (image_uri, "file://")) {
- if (uri == NULL) {
- uri = image_uri;
- } else {
- g_free (image_uri);
- }
- } else {
- icon_name = image_uri;
- }
+ /* FIXME bugzilla.eazel.com 2564: Lame hack. We only support file: URIs? */
+ if (eel_istr_has_prefix (image_uri, "file://")) {
+ if (uri == NULL) {
+ uri = image_uri;
+ } else {
+ g_free (image_uri);
+ }
+ } else {
+ icon_name = image_uri;
+ }
}
g_free (file_path);
}
}
- if (uri == NULL && nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+ /* Handle .desktop files. */
+ if (uri == NULL
+ && nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+ /* FIXME bugzilla.eazel.com 2563: This does sync. I/O and only works for local paths. */
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
if (file_path != NULL) {
entry = gnome_desktop_entry_load (file_path);
@@ -1495,23 +1547,25 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
}
/* handle SVG files */
- if (uri == NULL && icon_name == NULL && nautilus_file_is_mime_type (file, "image/svg")) {
+ if (uri == NULL && icon_name == NULL
+ && nautilus_file_is_mime_type (file, "image/svg")) {
uri = g_strdup (file_uri);
}
/* Get the generic icon set for this file. */
g_free (file_uri);
if (icon_name == NULL) {
- icon_name = g_strdup (nautilus_icon_factory_get_icon_name_for_file (file));
+ icon_name = get_icon_name_for_file (file);
}
top_left_text = nautilus_file_get_top_left_text (file);
/* Create the icon or find it in the cache if it's already there. */
scalable_icon = nautilus_scalable_icon_new_from_text_pieces
- (uri, icon_name, modifier, top_left_text);
+ (uri, mime_type, icon_name, modifier, top_left_text);
g_free (uri);
+ g_free (mime_type);
g_free (icon_name);
g_free (top_left_text);
@@ -1567,7 +1621,7 @@ nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name)
name_with_prefix = g_strconcat (EMBLEM_NAME_PREFIX, emblem_name, NULL);
scalable_icon = nautilus_scalable_icon_new_from_text_pieces
- (NULL, name_with_prefix, NULL, NULL);
+ (NULL, NULL, name_with_prefix, NULL, NULL);
g_free (name_with_prefix);
return scalable_icon;
@@ -1696,7 +1750,7 @@ get_next_icon_size_to_try (guint target_size, guint *current_size)
/* This loads an SVG image, scaling it to the appropriate size. */
static GdkPixbuf *
-load_pixbuf_svg (const char *path, const char *name, guint size_in_pixels)
+load_pixbuf_svg (const char *path, guint size_in_pixels, gboolean is_emblem)
{
FILE *f;
GdkPixbuf *pixbuf;
@@ -1708,10 +1762,10 @@ load_pixbuf_svg (const char *path, const char *name, guint size_in_pixels)
}
/* FIXME: the nominal size of .svg emblems is too large, so we scale it
- * down here if the file is an emblem. This code should be removed
- * eventually when we scale all the emblems properly.
+ * down here if the file is an emblem. This code should be removed
+ * when we scale all the emblems properly.
*/
- if (eel_str_has_prefix (name, EMBLEM_NAME_PREFIX)) {
+ if (is_emblem) {
actual_size_in_pixels = size_in_pixels * EMBLEM_SCALE_FACTOR;
} else {
actual_size_in_pixels = size_in_pixels;
@@ -1780,6 +1834,51 @@ get_cache_time (const char *file_uri, time_t *cache_time)
return result;
}
+static GdkPixbuf *
+load_icon_from_path (const char *path,
+ guint size_in_pixels,
+ gboolean custom,
+ gboolean is_emblem) /* for emblem scaling hack only */
+{
+ /* Get the icon. */
+ if (path == NULL) {
+ return NULL;
+ }
+ if (path_represents_svg_image (path)) {
+ return load_pixbuf_svg (path, size_in_pixels, is_emblem);
+ }
+ /* Custom non-svg icons exist at one size.
+ * Non-custom icons have their size encoded in their path.
+ */
+ if (custom && size_in_pixels != NAUTILUS_ICON_SIZE_STANDARD) {
+ return NULL;
+ }
+ return gdk_pixbuf_new_from_file (path);
+}
+
+static GdkPixbuf *
+load_named_icon (const char *name,
+ const char *modifier,
+ guint size_in_pixels,
+ gboolean optimized_for_aa,
+ IconDetails *details)
+{
+ char *path;
+ GdkPixbuf *pixbuf;
+
+ path = get_icon_file_path (name, modifier,
+ size_in_pixels, optimized_for_aa,
+ details);
+ pixbuf = load_icon_from_path (path, size_in_pixels, FALSE,
+ eel_str_has_prefix (name, EMBLEM_NAME_PREFIX));
+ g_free (path);
+
+ if (pixbuf == NULL) {
+ memset (&details, 0, sizeof (details));
+ }
+ return pixbuf;
+}
+
/* This load function returns NULL if the icon is not available at
* this size.
*/
@@ -1791,6 +1890,7 @@ load_specific_icon (NautilusScalableIcon *scalable_icon,
{
IconDetails details;
GdkPixbuf *pixbuf;
+ char *icon_name;
char *path;
CacheIcon *icon;
@@ -1801,39 +1901,37 @@ load_specific_icon (NautilusScalableIcon *scalable_icon,
if (custom) {
/* We don't support custom icons that are not local here. */
path = gnome_vfs_get_local_path_from_uri (scalable_icon->uri);
+ pixbuf = load_icon_from_path (path, size_in_pixels, TRUE, FALSE);
+ g_free (path);
} else {
- path = get_icon_file_path (scalable_icon->name,
- scalable_icon->modifier,
- size_in_pixels,
- optimized_for_aa,
- &details);
- }
-
- /* Get the icon. */
- if (path != NULL) {
- if (path_represents_svg_image (path)) {
- pixbuf = load_pixbuf_svg (path, scalable_icon->name, size_in_pixels);
- } else {
- /* Custom non-svg icons exist at one size.
- * Non-custom icons have their size encoded in their path.
+ pixbuf = load_named_icon (scalable_icon->name,
+ scalable_icon->modifier,
+ size_in_pixels, optimized_for_aa,
+ &details);
+ if (pixbuf == NULL) {
+ /* Use the type in the MIME database, or turn the MIME
+ * type into an icon name.
*/
- if (!(custom && size_in_pixels != NAUTILUS_ICON_SIZE_STANDARD)) {
- pixbuf = gdk_pixbuf_new_from_file (path);
+ icon_name = get_mime_type_icon_without_suffix (scalable_icon->mime_type);
+ if (icon_name == NULL) {
+ icon_name = make_icon_name_from_mime_type (scalable_icon->mime_type);
}
+ if (icon_name != NULL && eel_strcmp (icon_name, scalable_icon->name) != 0) {
+ pixbuf = load_named_icon (icon_name, scalable_icon->modifier,
+ size_in_pixels, optimized_for_aa,
+ &details);
+ }
+ g_free (icon_name);
}
-
- g_free (path);
}
- /* If we got nothing, we can free the icon. */
if (pixbuf == NULL) {
return NULL;
}
/* Since we got something, we can create a cache icon. */
icon = cache_icon_new (pixbuf, custom, FALSE, &details);
- get_cache_time (scalable_icon->uri,
- &icon->cache_time);
+ get_cache_time (scalable_icon->uri, &icon->cache_time);
gdk_pixbuf_unref (pixbuf);
return icon;
@@ -2099,7 +2197,7 @@ mark_recently_used (CircularList *node)
check_recently_used_list ();
}
-/* Utility routine that checks if a cached thubmnail-type icon has
+/* Utility routine that checks if a cached thumbnail-type icon has
* changed since it was cached. Returns TRUE after removing the icon
* from the cache if the icon has changed.
*/
@@ -2404,17 +2502,17 @@ nautilus_icon_factory_get_pixmap_and_mask_for_file (NautilusFile *file,
gdk_pixbuf_unref (pixbuf);
}
-/* Convenience routine for getting a pixbuf from an icon name
- */
-GdkPixbuf * nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
- const char *modifier,
- guint size_in_pixels,
- gboolean optimized_for_aa)
+/* Convenience routine for getting a pixbuf from an icon name. */
+GdkPixbuf *
+nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
+ const char *modifier,
+ guint size_in_pixels,
+ gboolean optimized_for_aa)
{
GdkPixbuf *pixbuf;
NautilusScalableIcon *icon;
- icon = nautilus_scalable_icon_new_from_text_pieces (NULL, icon_name, modifier, NULL);
+ icon = nautilus_scalable_icon_new_from_text_pieces (NULL, NULL, icon_name, modifier, NULL);
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon (icon,
size_in_pixels, size_in_pixels,
size_in_pixels, size_in_pixels,
@@ -2539,6 +2637,7 @@ load_icon_with_embedded_text (NautilusScalableIcon *scalable_icon,
/* Get the icon without text. */
scalable_icon_without_text = nautilus_scalable_icon_new_from_text_pieces
(scalable_icon->uri,
+ scalable_icon->mime_type,
scalable_icon->name,
scalable_icon->modifier,
NULL);
diff --git a/libnautilus-private/nautilus-icon-factory.h b/libnautilus-private/nautilus-icon-factory.h
index 2bd3e5c7b..8c10173d6 100644
--- a/libnautilus-private/nautilus-icon-factory.h
+++ b/libnautilus-private/nautilus-icon-factory.h
@@ -162,6 +162,7 @@ void nautilus_scalable_icon_unref (Nautil
*/
void nautilus_scalable_icon_get_text_pieces (NautilusScalableIcon *scalable_icon,
char **uri_return,
+ char **mime_type_return,
char **name_return,
char **modifier_return,
char **embedded_text_return);
@@ -169,6 +170,7 @@ void nautilus_scalable_icon_get_text_pieces (Nautil
* nautilus_scalable_icon_get_text_pieces.
*/
NautilusScalableIcon *nautilus_scalable_icon_new_from_text_pieces (const char *uri,
+ const char *mime_type,
const char *name,
const char *modifier,
const char *embedded_text);
diff --git a/libnautilus-private/nautilus-trash-monitor.c b/libnautilus-private/nautilus-trash-monitor.c
index d3f9cc74d..a392c3d56 100644
--- a/libnautilus-private/nautilus-trash-monitor.c
+++ b/libnautilus-private/nautilus-trash-monitor.c
@@ -3,7 +3,7 @@
/*
nautilus-trash-monitor.c: Nautilus trash state watcher.
- Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2000, 2001 Eazel, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -197,6 +197,8 @@ nautilus_trash_monitor_get (void)
/* make sure we get signalled when trash directories get added */
nautilus_trash_directory_finish_initializing
(NAUTILUS_TRASH_DIRECTORY (trash_directory));
+
+ nautilus_directory_unref (trash_directory);
}
return nautilus_trash_monitor;
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index d8f5c764f..bea1b04e5 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -135,7 +135,7 @@ append_bookmark_node (gpointer data, gpointer user_data)
NautilusBookmark *bookmark;
NautilusScalableIcon *icon;
char *bookmark_uri, *bookmark_name;
- char *icon_uri, *icon_name;
+ char *icon_uri, *icon_mime_type, *icon_name;
g_assert (NAUTILUS_IS_BOOKMARK (data));
@@ -155,8 +155,10 @@ append_bookmark_node (gpointer data, gpointer user_data)
icon = nautilus_bookmark_get_icon (bookmark);
if (icon != NULL) {
/* Don't bother storing modifier or embedded text for bookmarks. */
- nautilus_scalable_icon_get_text_pieces (icon, &icon_uri, &icon_name, NULL, NULL);
+ nautilus_scalable_icon_get_text_pieces (icon, &icon_uri, &icon_mime_type, &icon_name,
+ NULL, NULL);
xmlSetProp (bookmark_node, "icon_uri", icon_uri);
+ xmlSetProp (bookmark_node, "icon_mime_type", icon_mime_type);
xmlSetProp (bookmark_node, "icon_name", icon_name);
nautilus_scalable_icon_unref (icon);
g_free (icon_uri);
diff --git a/src/nautilus-bookmark-parsing.c b/src/nautilus-bookmark-parsing.c
index 5813623b1..7895016c0 100644
--- a/src/nautilus-bookmark-parsing.c
+++ b/src/nautilus-bookmark-parsing.c
@@ -26,20 +26,18 @@
*/
#include <config.h>
-#include <stdlib.h>
#include "nautilus-bookmark-parsing.h"
+#include <eel/eel-xml-extensions.h>
#include <gnome-xml/xmlmemory.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
-#include <eel/eel-xml-extensions.h>
+#include <stdlib.h>
NautilusBookmark *
nautilus_bookmark_new_from_node (xmlNodePtr node)
{
- xmlChar *name;
- xmlChar *uri;
- xmlChar *icon_uri;
- xmlChar *icon_name;
+ xmlChar *name, *uri;
+ xmlChar *icon_uri, *icon_mime_type, *icon_name;
NautilusScalableIcon *icon;
NautilusBookmark *new_bookmark;
@@ -47,13 +45,14 @@ nautilus_bookmark_new_from_node (xmlNodePtr node)
name = eel_xml_get_property_translated (node, "name");
uri = xmlGetProp (node, "uri");
icon_uri = xmlGetProp (node, "icon_uri");
+ icon_mime_type = xmlGetProp (node, "icon_mime_type");
icon_name = xmlGetProp (node, "icon_name");
if (icon_uri == NULL && icon_name == NULL) {
icon = NULL;
} else {
icon = nautilus_scalable_icon_new_from_text_pieces
- (icon_uri, icon_name, NULL, NULL);
+ (icon_uri, icon_mime_type, icon_name, NULL, NULL);
}
new_bookmark = nautilus_bookmark_new_with_icon (uri, name, icon);
if (icon != NULL) {