summaryrefslogtreecommitdiff
blob: 2aabd57697983cb323e60324770edc253b5d642b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
2007-10-02  Frederic Crozat  <fcrozat@mandriva.com>

	Backport from gio-branch, fixes #480608, from 
	Alexander Larsson  <alexl@redhat.com>

* libnautilus-private/nautilus-icon-factory.c:
	Don't clear thumbnails and other absolute pathnames from icon
	cache when mime data or icon theme changes. This is to avoid
	flashing and async realoading of all thumbnails.

* libnautilus-private/nautilus-directory-async.c:
	(mime_db_changed_callback):
	Use the right call to invalidate attributes, so that
	they get re-read correctly.
--- libnautilus-private/nautilus-icon-factory.c	2007/10/02 13:28:27	13248
+++ libnautilus-private/nautilus-icon-factory.c	2007/10/02 13:28:59	13249
@@ -200,7 +200,7 @@
 							  const char               *modifier,
 							  guint                     nominal_size,
 							  gboolean		    force_nominal);
-static void nautilus_icon_factory_clear                  (void);
+static void nautilus_icon_factory_clear                  (gboolean                  clear_pathnames);
 
 GNOME_CLASS_BOILERPLATE (NautilusIconFactory,
 			 nautilus_icon_factory,
@@ -270,7 +270,7 @@
 {
 	NautilusIconFactory *factory;
 
-	nautilus_icon_factory_clear ();
+	nautilus_icon_factory_clear (FALSE);
 
 	factory = user_data;
 
@@ -726,9 +726,23 @@
         return TRUE;
 }
 
-/* Reset the cache to the default state. */
+static gboolean
+remove_non_pathnames (gpointer _key, gpointer value, gpointer user_data)
+{
+	CacheKey *key = _key;
+	
+	if (key->name && key->name[0] == '/') {
+		return FALSE;
+	}
+	    
+        return TRUE; /* Tell the caller to remove the hash table entry. */
+}
+
+/* Reset the cache to the default state.
+   Clear pathnames can be set to FALSE which means we only clear icon names, not
+   absolute pathnames. This is useful to avoid throwing away all loaded thumbnails. */
 static void
-nautilus_icon_factory_clear (void)
+nautilus_icon_factory_clear (gboolean clear_pathnames)
 {
 	NautilusIconFactory *factory;
 	CircularList *head;
@@ -736,24 +750,25 @@
 	factory = get_icon_factory ();
 
         g_hash_table_foreach_remove (factory->icon_cache,
-				     remove_all,
+				     clear_pathnames ? remove_all : remove_non_pathnames,
                                      NULL);
 	
 	/* Empty out the recently-used list. */
 	head = &factory->recently_used_dummy_head;
 
-	/* fallback_icon hangs around, but we don't know if it
-	 * was ever inserted in the list
-	 */
-	g_assert (factory->recently_used_count == 0 ||
-		  factory->recently_used_count == 1);
-
-	if (factory->recently_used_count == 1) {
-		/* make sure this one is the fallback_icon */
-		g_assert (head->next == head->prev);
-		g_assert (&factory->fallback_icon->recently_used_node == head->next);
+	if (clear_pathnames) {
+		/* fallback_icon hangs around, but we don't know if it
+		 * was ever inserted in the list
+		 */
+		g_assert (factory->recently_used_count == 0 ||
+			  factory->recently_used_count == 1);
+		if (factory->recently_used_count == 1) {
+			/* make sure this one is the fallback_icon */
+			g_assert (head->next == head->prev);
+			g_assert (&factory->fallback_icon->recently_used_node == head->next);
+		}
 	}
-
+		
 }
 
 static void
@@ -806,7 +821,7 @@
 	 * signal to mean only "thumbnails might have changed" if this ends up being slow
 	 * for some reason.
 	 */
-	nautilus_icon_factory_clear ();
+	nautilus_icon_factory_clear (TRUE);
 	g_signal_emit (global_icon_factory,
 			 signals[ICONS_CHANGED], 0);
 }
@@ -820,7 +835,7 @@
 	 * signal to mean only "thumbnails might have changed" if this ends up being slow
 	 * for some reason.
 	 */
-	nautilus_icon_factory_clear ();
+	nautilus_icon_factory_clear (TRUE);
 	g_signal_emit (global_icon_factory,
 			 signals[ICONS_CHANGED], 0);
 }
@@ -830,7 +845,7 @@
 {
 	show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
 
-	nautilus_icon_factory_clear ();
+	nautilus_icon_factory_clear (TRUE);
 	/* If the user disabled thumbnailing, remove all outstanding thumbnails */ 
 	if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_NEVER) {
 		nautilus_thumbnail_remove_all_from_queue ();
@@ -848,7 +863,7 @@
 	/* We don't know which data changed, so we have to assume that
 	 * any or all icons might have changed.
 	 */
-	nautilus_icon_factory_clear ();
+	nautilus_icon_factory_clear (FALSE);
 	g_signal_emit (get_icon_factory (), 
 			 signals[ICONS_CHANGED], 0);
 }				 
--- libnautilus-private/nautilus-directory-async.c	2007/10/02 13:28:27	13248
+++ libnautilus-private/nautilus-directory-async.c	2007/10/02 13:28:59	13249
@@ -594,7 +594,7 @@
 		NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE |
 		NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES;
 
-	nautilus_directory_invalidate_file_attributes (dir, attrs);
+	nautilus_directory_force_reload_internal (dir, attrs);
 }
 
 void