Proposed patch to gnome-vfs
- From: Jody Goldberg <jody gnome org>
- To: gnome2-release-team gnome org
- Cc: desktop-devel-list gnome org
- Subject: Proposed patch to gnome-vfs
- Date: Tue, 4 Jun 2002 20:35:11 -0400
Symptom :
---------
Changing the icon of a custom mime type does not work
Problem :
---------
While the file-type capplet is saving the changed mime type some of
the _set_ operations look up the old values to see if things have
changed. Calling _get_ can trigger a reload, which effictively
throws out the and pending edits.
Proposed Solution :
-------------------
I do not know enough about the internals of gnome-vfs to solve this
nicely. What we really want IMHO is to not reload things if there
are pending edits. However, there is a potentially simple
workaround which doesn't require an api change.
void gnome_vfs_mime_freeze (void);
void gnome_vfs_mime_thaw (void);
These are documented to block _writing_ and appear to only be used
in the file-type capplet. I'd like to extend the definition to
block reading too.
May I commit ?
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v
retrieving revision 1.1326
diff -u -w -r1.1326 ChangeLog
--- ChangeLog 3 Jun 2002 22:43:54 -0000 1.1326
+++ ChangeLog 5 Jun 2002 00:20:12 -0000
@@ -1,3 +1,9 @@
+2002-06-04 Jody Goldberg <jody gnome org>
+
+ * libgnomevfs/gnome-vfs-mime-info.c (reload_if_needed) : honour
+ gnome_vfs_is_frozen.
+ (gnome_vfs_is_frozen) : rename from should_write_file_back.
+
2002-06-04 Kristian Rietveld <kris gtk org>
* libgnomevfs/gnome-vfs-standard-callbacks.h: add
Index: libgnomevfs/gnome-vfs-mime-info.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-info.c,v
retrieving revision 1.62
diff -u -w -r1.62 gnome-vfs-mime-info.c
--- libgnomevfs/gnome-vfs-mime-info.c 1 May 2002 23:19:32 -0000 1.62
+++ libgnomevfs/gnome-vfs-mime-info.c 5 Jun 2002 00:20:12 -0000
@@ -128,8 +128,8 @@
/* To initialize the module automatically */
static gboolean gnome_vfs_mime_inited = FALSE;
-/* you will write back the file if and only if this var' value is 0 */
-static int should_write_file_back = 0;
+/* you will write back or reload the file if and only if this var' value is 0 */
+static int gnome_vfs_is_frozen = 0;
static GList *current_lang = NULL;
/* we want to replace the previous key if the current key has a higher
@@ -159,7 +159,6 @@
/* Prototypes */
-static void reload_if_needed (void);
static GnomeVFSResult write_back_mime_user_file (void);
static GnomeVFSResult write_back_keys_user_file (void);
static const char * gnome_vfs_mime_get_registered_mime_type_key (const char *mime_type,
@@ -683,6 +682,9 @@
gboolean need_reload = FALSE;
struct stat s;
+ if (gnome_vfs_is_frozen > 0)
+ return;
+
if (now > last_checked + 5)
need_reload = TRUE;
@@ -777,7 +779,7 @@
void
gnome_vfs_mime_freeze (void)
{
- should_write_file_back++;
+ gnome_vfs_is_frozen++;
}
@@ -792,9 +794,9 @@
void
gnome_vfs_mime_thaw (void)
{
- should_write_file_back--;
+ gnome_vfs_is_frozen--;
- if (should_write_file_back == 0) {
+ if (gnome_vfs_is_frozen == 0) {
write_back_mime_user_file ();
write_back_keys_user_file ();
}
@@ -858,7 +860,7 @@
retval = set_value_real (mime_type, key, value, specific_types_user);
- if (should_write_file_back == 0) {
+ if (gnome_vfs_is_frozen == 0) {
return write_back_keys_user_file ();
}
@@ -1460,7 +1462,7 @@
result = set_value_real (mime_type, key, value, registered_types_user);
- if (should_write_file_back == 0) {
+ if (gnome_vfs_is_frozen == 0) {
result = write_back_mime_user_file ();
}
Index: libgnomevfs/gnome-vfs-mime-info.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-info.h,v
retrieving revision 1.21
diff -u -w -r1.21 gnome-vfs-mime-info.h
--- libgnomevfs/gnome-vfs-mime-info.h 6 Sep 2001 08:05:24 -0000 1.21
+++ libgnomevfs/gnome-vfs-mime-info.h 5 Jun 2002 00:20:12 -0000
@@ -31,7 +31,9 @@
/* functions to freeze/thaw the internal hash tables to
avoid writing them back to disk everytime you modify
- them through the _set_ functions */
+ them through the _set_ functions, or accidentally
+ reloading them from disk during an edit.
+ */
void gnome_vfs_mime_freeze (void);
void gnome_vfs_mime_thaw (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]