From 60a6029ad0b773b488a701f1c3f210fabbcfdded Mon Sep 17 00:00:00 2001 From: bl0ckeduser Date: Sat, 5 Jul 2014 13:06:33 -0400 Subject: Handle metadata key deletions (fixes #296) --- libcaja-private/caja-desktop-metadata.c | 26 ++++++++++++++++++++++---- 1 file 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); -- cgit v1.2.1