From 6affbe33e90b4157380eff3dad6a9654c9a24443 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 22 Jul 2010 17:07:52 -0400 Subject: Migrate ~/.evolution to XDG base directories. Migration runs just before the main loop starts. It's just a sequence of local directory and file renames. --- e-util/e-signature.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'e-util/e-signature.c') diff --git a/e-util/e-signature.c b/e-util/e-signature.c index c4ae7ed69d..6eb84c3704 100644 --- a/e-util/e-signature.c +++ b/e-util/e-signature.c @@ -32,6 +32,7 @@ #include #include +#include #include "e-signature.h" @@ -493,6 +494,24 @@ e_signature_set_from_xml (ESignature *signature, const gchar *xml) break; } + /* If the signature is not a script, replace the directory + * part with the current signatures directory. This makes + * moving the signatures directory transparent. */ + if (!e_signature_get_is_script (signature)) { + const gchar *user_data_dir; + gchar *basename; + gchar *filename; + + user_data_dir = e_get_user_data_dir (); + + filename = signature->priv->filename; + basename = g_path_get_basename (filename); + signature->priv->filename = g_build_filename ( + user_data_dir, "signatures", basename, NULL); + g_free (basename); + g_free (filename); + } + cur = cur->next; } @@ -544,13 +563,25 @@ e_signature_to_xml (ESignature *signature) string = e_signature_get_filename (signature); if (string != NULL) { - node = xmlNewTextChild ( - root, NULL, (xmlChar *) "filename", - (xmlChar *) string); - if (e_signature_get_is_script (signature)) + + /* For scripts we save the full filename, + * for normal signatures just the basename. */ + if (e_signature_get_is_script (signature)) { + node = xmlNewTextChild ( + root, NULL, (xmlChar *) "filename", + (xmlChar *) string); xmlSetProp ( node, (xmlChar *) "script", (xmlChar *) "true"); + } else { + gchar *basename; + + basename = g_path_get_basename (string); + node = xmlNewTextChild ( + root, NULL, (xmlChar *) "filename", + (xmlChar *) basename); + g_free (basename); + } } } else { /* this is to make Evolution-1.4 and older 1.5 versions happy */ -- cgit v1.2.3