diff options
author | bl0ckeduser <[email protected]> | 2014-07-05 13:06:33 -0400 |
---|---|---|
committer | bl0ckeduser <[email protected]> | 2014-07-05 13:06:33 -0400 |
commit | e2c56fc2f8182c361684b9ae29beb998749912dc (patch) | |
tree | 98ea7036783365093e7ac492e4642c599897e32d | |
parent | 055af122062667206828a6e971d7c8cc8b29d519 (diff) | |
download | caja-e2c56fc2f8182c361684b9ae29beb998749912dc.tar.bz2 caja-e2c56fc2f8182c361684b9ae29beb998749912dc.tar.xz |
Handle metadata key deletions (fixes #296)
-rw-r--r-- | libcaja-private/caja-desktop-metadata.c | 26 |
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); |