summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbl0ckeduser <[email protected]>2014-07-05 13:06:33 -0400
committerinfirit <[email protected]>2014-07-11 14:27:31 +0200
commit60a6029ad0b773b488a701f1c3f210fabbcfdded (patch)
treefe5bafc6b56abdf4dbd2a8f4e61e9546090e547f
parent29a2daf41a15db9d9db06a4ba9c55d271cbecdcb (diff)
downloadcaja-60a6029ad0b773b488a701f1c3f210fabbcfdded.tar.bz2
caja-60a6029ad0b773b488a701f1c3f210fabbcfdded.tar.xz
Handle metadata key deletions (fixes #296)
-rw-r--r--libcaja-private/caja-desktop-metadata.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/libcaja-private/caja-desktop-metadata.c b/libcaja-private/caja-desktop-metadata.c
index 8434ec08..c9e136bc 100644
--- a/libcaja-private/caja-desktop-metadata.c
+++ b/libcaja-private/caja-desktop-metadata.c
@@ -146,13 +146,31 @@ caja_desktop_set_metadata_string (CajaFile *file,
const gchar *string)
{
GKeyFile *keyfile;
+ GError *error = NULL;
keyfile = get_keyfile ();
- g_key_file_set_string (keyfile,
- name,
- key,
- string);
+ if (string != NULL) {
+ g_key_file_set_string (keyfile,
+ name,
+ key,
+ string);
+ } else {
+ /* NULL as value is taken to mean that we want to remove the key */
+
+ g_key_file_remove_key (keyfile,
+ name,
+ key,
+ &error);
+
+ if (error != NULL) {
+ g_warning ("Couldn't remove the key '%s' from '%s' in the keyfile: %s",
+ key,
+ name,
+ error->message);
+ g_error_free (error);
+ }
+ }
save_in_idle (keyfile);