Index: src/anjuta.c
===================================================================
--- src/anjuta.c	(revision 4054)
+++ src/anjuta.c	(working copy)
@@ -32,8 +32,7 @@
 #define ANJUTA_REMEMBERED_PLUGINS "anjuta.remembered.plugins"
 #define ANJUTA_SESSION_SKIP_LAST "anjuta.session.skip.last"
 #define ANJUTA_SESSION_SKIP_LAST_FILES "anjuta.session.skip.last.files"
-#define USER_SESSION_PATH_NEW (g_build_filename (g_get_home_dir (), ".anjuta", \
-												 "session", NULL))
+#define USER_SESSION_PATH_NEW (anjuta_util_get_user_cache_file_path ("session/", NULL))
 
 #define DEFAULT_PROFILE "file://"PACKAGE_DATA_DIR"/profiles/default.profile"
 #define USER_PROFILE_NAME "user"
@@ -337,8 +336,7 @@
 	
 	/* Load user session profile */
 	profile_name = g_path_get_basename (DEFAULT_PROFILE);
-	session_profile = g_build_filename (g_get_home_dir(), ".anjuta",
-										profile_name, NULL);
+	session_profile = anjuta_util_get_user_cache_file_path (profile_name, NULL);
 	if (g_file_test (session_profile, G_FILE_TEST_EXISTS))
 	{
 		anjuta_profile_add_plugins_from_xml (profile, session_profile,
Index: plugins/symbol-browser/plugin.c
===================================================================
--- plugins/symbol-browser/plugin.c	(revision 4054)
+++ plugins/symbol-browser/plugin.c	(working copy)
@@ -22,6 +22,7 @@
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libanjuta/anjuta-shell.h>
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
 #include <libanjuta/interfaces/ianjuta-help.h>
 #include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-project-manager.h>
@@ -351,7 +352,7 @@
 	}
 }
 
-#define LOCAL_TAGS_DIR ".anjuta/tags"
+#define LOCAL_TAGS_SUBDIR "tags/"
 
 // add a new project
 static void
@@ -401,7 +402,7 @@
 	if (anjuta_preferences_get_int (sv_plugin->prefs,
 											"symbol_browser.tags_auto_load"))
 	{
-		gchar* dirname = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
+		gchar* dirname = anjuta_util_get_user_cache_file_path (LOCAL_TAGS_SUBDIR,NULL);
 		GList* packages = ianjuta_project_manager_get_packages (pm, NULL);
 		GList* node;
 		GString* str = g_string_new ("");
Index: plugins/symbol-browser/an_symbol_prefs.c
===================================================================
--- plugins/symbol-browser/an_symbol_prefs.c	(revision 4054)
+++ plugins/symbol-browser/an_symbol_prefs.c	(working copy)
@@ -28,14 +28,15 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/anjuta-launcher.h>
+#include <libanjuta/anjuta-utils.h>
 
 #include "an_symbol_prefs.h"
 #include "tm_tagmanager.h"
 
 #define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-symbol-browser-plugin.glade"
 #define ICON_FILE "anjuta-symbol-browser-plugin-48.png"
-#define LOCAL_TAGS_DIR ".anjuta/tags"
-#define SYSTEM_TAGS_CACHE ".anjuta/system-tags.cache"
+#define LOCAL_TAGS_SUBDIR "tags/"
+#define SYSTEM_TAGS_CACHE "system-tags.cache"
 #define SYMBOL_BROWSER_TAGS "symbol.browser.tags"
 #define CREATE_GLOBAL_TAGS PACKAGE_DATA_DIR"/scripts/create_global_tags.sh"
 
@@ -52,7 +53,7 @@
 {
 	gchar *output_file;
 	
-	output_file = g_build_filename (g_get_home_dir (), SYSTEM_TAGS_CACHE, NULL);
+	output_file = anjuta_util_get_user_cache_file_path (SYSTEM_TAGS_CACHE, NULL);
 	
 	DEBUG_PRINT ("Recreating system tags cache: %s", output_file);
 	
@@ -73,7 +74,7 @@
 	GList *tags_files;
 	gchar *output_file;
 	
-	output_file = g_build_filename (g_get_home_dir (), SYSTEM_TAGS_CACHE, NULL);
+	output_file = anjuta_util_get_user_cache_file_path (SYSTEM_TAGS_CACHE, NULL);
 	
 	DEBUG_PRINT ("Recreating system tags cache: %s", output_file);
 	
@@ -170,7 +171,7 @@
 	store = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING,
 								G_TYPE_STRING);
 	
-	local_tags_dir = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
+	local_tags_dir = anjuta_util_get_user_cache_file_path (LOCAL_TAGS_SUBDIR, NULL);
 	tags_dirs = g_list_prepend (tags_dirs, local_tags_dir);
 	
 	/* Load the tags files */
@@ -437,10 +438,14 @@
 		argv = g_new0 (gchar*, argc);
 		
 		argv[0] = g_strdup ("anjuta-tags");
-		tmp = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, name, NULL);
-		argv[1] = g_strconcat (tmp, ".anjutatags", NULL);
-		g_free (tmp);
-		
+
+		{
+			gchar *tmp = NULL;
+			tmp = anjuta_util_get_user_cache_file_path ("tags", name, NULL);
+			argv[1] = g_strconcat (tmp, ".anjutatags", NULL);
+			g_free (tmp);
+		}
+
 		argc = 2;
 		if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
 		{
@@ -473,13 +478,9 @@
 		}
 		
 		/* Create local tags directory */
-		tmp = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
-		if ((pid = fork()) == 0)
-		{
-			execlp ("mkdir", "mkdir", "-p", tmp, NULL);
-			perror ("Could not execute mkdir");
-		}
-		waitpid (pid, NULL, 0);
+
+		tmp = anjuta_util_get_user_cache_file_path (LOCAL_TAGS_SUBDIR, NULL);
+
 		g_free (tmp);
 		
 		/* Execute anjuta-tags to create tags for the given files */
@@ -538,27 +539,20 @@
 		gchar *tmp;
 		pid_t pid;
 		
-		/* Create local tags directory */
-		tmp = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
-		if ((pid = fork()) == 0)
-		{
-			execlp ("mkdir", "mkdir", "-p", tmp, NULL);
-			perror ("Could not execute mkdir");
-		}
-		waitpid (pid, NULL, 0);
-		g_free (tmp);
-		
 		uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (fileselection));
 		
 		node = uris;
 		while (node)
 		{
-			gchar *dest, *src, *basename;
+			gchar *dest, *src;
 			
 			src = node->data;
-			basename = g_path_get_basename (src);
-			dest = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, basename, NULL);
-			g_free (basename);
+			{
+				gchar *basename;
+				basename = g_path_get_basename (src);
+				dest = anjuta_util_get_user_cache_file_path ("tags", basename, NULL);
+				g_free (basename);
+			}
 			
 			/* Copy the tags file in local tags directory */
 			GnomeVFSURI* source_uri = gnome_vfs_uri_new(src);
@@ -612,8 +606,7 @@
 		if (tags_filename)
 		{
 			gchar *file_path, *path;
-			path = g_build_filename (g_get_home_dir(), LOCAL_TAGS_DIR,
-									 tags_filename, NULL);
+			path = anjuta_util_get_user_cache_file_path ("tags", tags_filename, NULL);
 			file_path = g_strconcat (path, ".anjutatags.gz", NULL);
 			
 			if (!g_file_test (file_path, G_FILE_TEST_EXISTS))
@@ -739,13 +732,7 @@
 		return; /* Already running */
 	
 	/* Create local tags directory */	
-	tmp = g_build_filename (g_get_home_dir (), LOCAL_TAGS_DIR, NULL);
-	if ((pid = fork()) == 0)
-	{
-		execlp ("mkdir", "mkdir", "-p", tmp, NULL);
-		perror ("Could not execute mkdir");
-	}
-	waitpid (pid, NULL, 0);
+	tmp = anjuta_util_get_user_cache_file_path (LOCAL_TAGS_SUBDIR,NULL);
 	g_free (tmp);
 	
 	plugin->launcher = anjuta_launcher_new ();
@@ -877,8 +864,7 @@
 {
 	gchar *system_tags_path;
 	/* Load gloabal tags on gtk idle */
-	system_tags_path = g_build_filename (g_get_home_dir(), ".anjuta",
-										 "system-tags.cache", NULL);
+	system_tags_path = anjuta_util_get_user_cache_file_path (SYSTEM_TAGS_CACHE,NULL);
 	if (!tm_workspace_load_global_tags (system_tags_path))
 	{
 		g_message ("Added idle loop to create global tags");
Index: plugins/tools/plugin.h
===================================================================
--- plugins/tools/plugin.h	(revision 4054)
+++ plugins/tools/plugin.h	(working copy)
@@ -32,9 +32,7 @@
 #define MENU_PLACEHOLDER "/MenuMain/PlaceHolderToolMenus/MenuTools"
 
 #define ANJUTA_TOOLS_DIRECTORY PACKAGE_DATA_DIR"/tools"
-#define LOCAL_ANJUTA_TOOLS_DIRECTORY "/.anjuta"
 #define TOOLS_FILE	"tools-2.xml"
-#define LOCAL_ANJUTA_SCRIPT_DIRECTORY "/.anjuta/script"
 
 /*---------------------------------------------------------------------------*/
 
Index: plugins/tools/fileop.c
===================================================================
--- plugins/tools/fileop.c	(revision 4054)
+++ plugins/tools/fileop.c	(working copy)
@@ -529,7 +529,7 @@
 	g_free (file_name);
 
 	/* Now, user tools */
-	file_name = g_build_filename (g_get_home_dir(), LOCAL_ANJUTA_TOOLS_DIRECTORY, TOOLS_FILE, NULL);
+	file_name = anjuta_util_get_user_data_file_path (TOOLS_FILE, NULL);
 	ok = atp_tool_list_load_from_file (atp_plugin_get_tool_list(plugin), file_name, ATP_TSTORE_LOCAL);
 	g_free (file_name);
 	if (!ok)
@@ -697,7 +697,7 @@
 	gboolean ok;
 
 	/* Save local tools */
-	file_name = g_build_filename (g_get_home_dir(), LOCAL_ANJUTA_TOOLS_DIRECTORY, TOOLS_FILE, NULL);
+	file_name = anjuta_util_get_user_data_file_path (TOOLS_FILE, NULL);
 	if (NULL == (f = fopen(file_name, "w")))
 	{
 		anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell),_("Unable to open %s for writing"), file_name);
Index: plugins/tools/editor.c
===================================================================
--- plugins/tools/editor.c	(revision 4054)
+++ plugins/tools/editor.c	(working copy)
@@ -642,9 +642,8 @@
 			}
 			name = atp_remove_mnemonic (command);
 			g_free (command);
-			command = g_build_filename (g_get_home_dir(),
-										LOCAL_ANJUTA_SCRIPT_DIRECTORY,
-										name, NULL);
+
+			command = anjuta_util_get_user_data_file_path ('scripts/', name, NULL);
 			g_free (name);
 
 			/* Find a new file name */
@@ -784,7 +783,9 @@
 			GFile* file;
 
 			/* Check that default script directory exist */
-			data = g_build_filename (g_get_home_dir(), LOCAL_ANJUTA_SCRIPT_DIRECTORY, NULL);
+			data = anjuta_util_get_user_data_file_path ("scripts/", NULL);
+
+			// TODO: Replace with g_mkdir_with_parents
 			make_directory (data);
 			g_free (data);
 
Index: plugins/project-wizard/druid.c
===================================================================
--- plugins/project-wizard/druid.c	(revision 4054)
+++ plugins/project-wizard/druid.c	(working copy)
@@ -35,6 +35,7 @@
 #include "autogen.h"
 
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
 #include <libanjuta/interfaces/ianjuta-wizard.h>
 
 #include <gnome.h>
@@ -47,7 +48,9 @@
 /*---------------------------------------------------------------------------*/
 
 #define PROJECT_WIZARD_DIRECTORY PACKAGE_DATA_DIR"/project"
-#define LOCAL_PROJECT_WIZARD_DIRECTORY "/.anjuta/project"
+/* Uncomment if you want to keep project wizards in a non-standard dir 
+#define LOCAL_PROJECT_WIZARD_DIRECTORY anjuta_utils_data_dir/projects/ 
+*/
 #define PIXMAP_APPWIZ_LOGO PACKAGE_DATA_DIR"/glade/applogo.png"
 #define PIXMAP_APPWIZ_WATERMARK PACKAGE_DATA_DIR"/glade/appwizard.png"
 
@@ -295,7 +298,11 @@
 
 	/* Fill list with all project in directory */
 	ok = npw_header_list_readdir (this->header_list, PROJECT_WIZARD_DIRECTORY);
+#ifdef LOCAL_PROJECT_WIZARD_DIRECTORY
 	local_dir = g_build_filename (g_get_home_dir(), LOCAL_PROJECT_WIZARD_DIRECTORY, NULL);
+#else
+	local_dir = anjuta_util_get_user_data_file_path ("projects/",NULL);
+#endif
 	ok = npw_header_list_readdir (this->header_list, local_dir) || ok;
 	g_free (local_dir);
 	if (!ok)
Index: plugins/valgrind/vggeneralprefs.c
===================================================================
--- plugins/valgrind/vggeneralprefs.c	(revision 4054)
+++ plugins/valgrind/vggeneralprefs.c	(working copy)
@@ -52,7 +52,7 @@
 #define RUN_LIBC_FREERES_KEY "/apps/anjuta/valgrind/general/run-libc-freeres"
 #define SUPPRESSIONS_KEY     "/apps/anjuta/valgrind/general/suppressions"
 
-#define SUPPRESSIONS_DEFAULT_FILE	".anjuta/valgrind.supp"
+#define SUPPRESSIONS_DEFAULT_FILE	"valgrind.supp"
 
 static void vg_general_prefs_class_init (VgGeneralPrefsClass *klass);
 static void vg_general_prefs_init (VgGeneralPrefs *prefs);
@@ -258,7 +258,7 @@
 	if (!(str_file = gconf_client_get_string (gconf, SUPPRESSIONS_KEY, &err)) || err != NULL) {
 		int fd;
 		
-		str_file = g_build_filename (g_get_home_dir (), SUPPRESSIONS_DEFAULT_FILE, NULL);
+		str_file = anjuta_util_get_user_config_file_path (SUPPRESSIONS_DEFAULT_FILE, NULL);
 		if ((fd = open (str_file, O_WRONLY | O_CREAT, 0666)) == -1) {
 			g_free (str_file);
 			str_file = NULL;
Index: plugins/valgrind/vgrule-list.c
===================================================================
--- plugins/valgrind/vgrule-list.c	(revision 4054)
+++ plugins/valgrind/vgrule-list.c	(working copy)
@@ -35,6 +35,7 @@
 
 #include <glib/gi18n.h>
 #include <gconf/gconf-client.h>
+#include <libanjuta/anjuta-utils.h>
 
 #include "vgrule-list.h"
 #include "vgmarshal.h"
@@ -692,7 +693,7 @@
 		gconf = gconf_client_get_default ();
 		
 		// FIXME: hardcoded path
-		list->filename = g_strdup_printf ("%s/.anjuta/valgrind.supp", getenv ("HOME"));
+		list->filename = anjuta_util_get_user_config_file_path ("valgrind.supp", NULL);
 		gconf_client_set_string (gconf, SUPPRESSIONS_KEY, list->filename, NULL);
 		g_object_unref (gconf);
 	}
Index: plugins/editor/style-editor.c
===================================================================
--- plugins/editor/style-editor.c	(revision 4054)
+++ plugins/editor/style-editor.c	(working copy)
@@ -834,8 +834,7 @@
 	gchar *filename;
 	
 	sync_to_props (se);
-	filename = g_build_filename (g_get_home_dir (), ".anjuta",
-								 "editor-style.properties", NULL);
+	filename = anjuta_util_get_user_config_file_path ("scintilla","editor-style.properties",NULL);
 	ofile = fopen (filename, "w");
 	if (!ofile) {
 		DEBUG_PRINT ("Could not open %s for writing", filename);
Index: plugins/editor/text_editor.c
===================================================================
--- plugins/editor/text_editor.c	(revision 4054)
+++ plugins/editor/text_editor.c	(working copy)
@@ -1949,16 +1949,13 @@
 	g_free (propfile);
 	g_free (propdir);
 
-	propdir = g_build_filename (g_get_home_dir(), ".anjuta" PREF_SUFFIX "/", NULL);
-	propfile = g_build_filename (g_get_home_dir(), ".anjuta" PREF_SUFFIX,
-								 "editor-style.properties", NULL);
+	propdir = anjuta_util_get_user_config_file_path ("scintilla/",NULL);
+	propfile = anjuta_util_get_user_config_file_path ("scintilla","editor-style.properties",NULL);
 	/* DEBUG_PRINT ("Reading file: %s", propfile); */
 	
 	/* Create user.properties file, if it doesn't exist */
 	if (g_file_test (propfile, G_FILE_TEST_EXISTS) == FALSE) {
-		gchar* old_propfile = g_build_filename (g_get_home_dir(),
-												".anjuta"PREF_SUFFIX,
-												"session.properties", NULL);
+		gchar* old_propfile = anjuta_util_get_user_config_file_path ("scintilla", "session.properties", NULL);
 		if (g_file_test (old_propfile, G_FILE_TEST_EXISTS) == TRUE)
 			anjuta_util_copy_file (old_propfile, propfile, FALSE);
 		g_free (old_propfile);
Index: plugins/symbol-db/plugin.c
===================================================================
--- plugins/symbol-db/plugin.c	(revision 4054)
+++ plugins/symbol-db/plugin.c	(working copy)
@@ -27,6 +27,7 @@
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 #include <libanjuta/anjuta-shell.h>
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
 #include <libanjuta/interfaces/ianjuta-document-manager.h>
 #include <libanjuta/interfaces/ianjuta-symbol-manager.h>
 #include <libanjuta/interfaces/ianjuta-project-manager.h>
@@ -56,7 +57,7 @@
 #define CTAGS_PATH			"/usr/bin/ctags"
 #define CHOOSER_WIDGET		"preferences_folder:text:/:0:symboldb.root"
 
-#define LOCAL_ANJUTA_GLOBAL_DB_DIRECTORY 	"/.anjuta"
+#define LOCAL_ANJUTA_GLOBAL_DB_DIRECTORY 	anjuta_utils_get_user_cache_uri(".")
 
 
 static gpointer parent_class;
@@ -1182,8 +1183,7 @@
 	/* the globals one too */
 	symbol_db->sdbe_globals = symbol_db_engine_new ();
 	/* open it */
-	home_anjuta_dir = g_strdup_printf ("%s%s", g_get_home_dir(),
-									   LOCAL_ANJUTA_GLOBAL_DB_DIRECTORY);
+	home_anjuta_dir = anjuta_util_get_user_cache_file_path (".");
 	symbol_db_engine_open_db (symbol_db->sdbe_globals, 
 							  home_anjuta_dir, "/");
 	g_free (home_anjuta_dir);
Index: plugins/macro/macro-db.c
===================================================================
--- plugins/macro/macro-db.c	(revision 4054)
+++ plugins/macro/macro-db.c	(working copy)
@@ -22,13 +22,14 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include <stdlib.h>
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
 
 #define PREDEFINED_MACRO_FILE PACKAGE_DATA_DIR"/macros.xml"
 
 static gchar *
 get_user_macro_path ()
 {
-	return g_strconcat (getenv ("HOME"), "/.anjuta/macros.xml", NULL);
+	return anjuta_util_get_user_data_file_path ("macro.xml", NULL);
 }
 				   
 static gboolean
Index: global-tags/create_global_tags.sh.in
===================================================================
--- global-tags/create_global_tags.sh.in	(revision 4054)
+++ global-tags/create_global_tags.sh.in	(working copy)
@@ -57,7 +57,7 @@
 
 echo "Generating System tags..."
 
-mkdir -p "$HOME/.anjuta/tags"
+mkdir -p "$XDG_CACHE_HOME/anjuta/tags/"
 
 # pkg-config libraries
 PKG_CONFIG=`which pkg-config 2>/dev/null`
@@ -92,11 +92,11 @@
 		# echo $PKG_CFLAGS
 	    package=`basename "$pkg_file" '.pc'`
 	    # if [ ! -e $BASEDIR/tags/$package.anjutatags.gz ] ; then
-		echo "Creating tags file: $HOME/.anjuta/tags/$package.anjutatags.gz ..."
-		anjuta_tags "$HOME/.anjuta/tags/$package.anjutatags" $PKG_CFLAGS > /dev/null
+		echo "Creating tags file: $XDG_CACHE_HOME/anjuta/tags/$package.anjutatags.gz ..."
+		anjuta_tags "$XDG_CACHE_HOME/anjuta/tags/$package.anjutatags" $PKG_CFLAGS > /dev/null
 	    # fi
 	done
     done
 	echo "Done"
-    echo "This is just a timestamp" > $HOME/.anjuta/system-tags.cache
+    echo "This is just a timestamp" > $XDG_CACHE_HOME/anjuta/system-tags.cache
 fi
Index: libanjuta/anjuta-ui.h
===================================================================
--- libanjuta/anjuta-ui.h	(revision 4054)
+++ libanjuta/anjuta-ui.h	(working copy)
@@ -34,6 +34,7 @@
  */
 #include <gtk/gtkaccelgroup.h>
 #include <gtk/gtkuimanager.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
Index: libanjuta/anjuta-utils.c
===================================================================
--- libanjuta/anjuta-utils.c	(revision 4054)
+++ libanjuta/anjuta-utils.c	(working copy)
@@ -793,12 +793,34 @@
 }
 
 gboolean
-anjuta_util_create_dir (const gchar * d)
+anjuta_util_create_dir (const gchar* path)
 {
-	if (g_file_test (d, G_FILE_TEST_IS_DIR))
-		return TRUE;
-	if (mkdir (d, 0755))
+	GFile *dir = g_file_new_for_path (path);
+	GError *err = NULL;
+
+	if (g_file_query_exists (dir, NULL))
+	{
+		GFileInfo *info = g_file_query_info (dir, 
+				G_FILE_ATTRIBUTE_STANDARD_TYPE, 
+				G_FILE_QUERY_INFO_NONE, 
+				NULL, NULL);
+		if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
+		{
+			g_message ("Warning: %s is a file. \n \
+					It is trying to be treated as a directory.",g_file_get_path (dir));
+			g_object_unref (dir);
+			return FALSE;
+		}
+		g_object_unref (info);
+	}
+	else if (!g_file_make_directory (dir, NULL, &err))
+	{
+		g_warning ("Error directory:\n %s", err->message);
+		g_object_unref (dir);
 		return FALSE;
+	}
+	g_object_unref (dir);
+
 	return TRUE;
 }
 
@@ -1025,6 +1047,7 @@
 	return buffer;
 }
 
+/* FIXME: Use gio instead */
 /* Diff the text contained in uri with text. Return true if files
 differ, FALSE if they are identical.
 FIXME: Find a better algorithm, this seems ineffective */
@@ -1477,35 +1500,6 @@
 	g_free (command);
 }
 
-/**
- * anjuta_utils_get_user_config_dir:
- *
- * Returns a base directory in which to store user-specific application 
- * configuration information such as user preferences and settings. 
- *
- * Return value: a new allocated string with the user config directory.
- */
-gchar *
-anjuta_util_get_user_config_dir ()
-{
-	gchar *folder;
-	
-	folder =  g_build_filename (g_get_user_config_dir (), "anjuta", NULL);
-	
-	if (!g_file_test (folder, G_FILE_TEST_IS_DIR))
-	{
-		if (g_mkdir (folder, 755) == -1)
-		{
-			g_warning ("There was an error creating the Anjuta config directory");
-			g_free (folder);
-			
-			return NULL;
-		}
-	}
-
-	return folder;
-}
-
 /* The following functions are taken from gedit */
 
 /* Note that this function replace home dir with ~ */
@@ -1624,3 +1618,161 @@
 	return g_string_free (truncated, FALSE);
 }
 
+/* 
+ * Functions to implement XDG Base Directory Specification
+ * http://standards.freedesktop.org/basedir-spec/latest/index.html
+ * Use this to save any config/cache/data files
+ *
+ */
+
+static gchar*
+anjuta_util_construct_pathv (const gchar* str, va_list str_list) 
+{
+	GPtrArray *str_arr;
+	gchar* tmp_str;
+
+	str_arr = g_ptr_array_new();
+	g_ptr_array_add (str_arr, (gpointer) str);
+
+	/* Extract elements from va_list */
+	if (str != NULL)
+	{
+		while ((tmp_str = va_arg (str_list, const gchar*)) != NULL) 
+		{
+			g_ptr_array_add (str_arr, tmp_str);
+		}
+		va_end (str_list);
+	}
+	
+	/* Terminate the list */
+	g_ptr_array_add (str_arr, (gpointer) NULL);
+
+	tmp_str = g_build_filenamev ((gchar*) str_arr->pdata);
+	g_ptr_array_free (str_arr, TRUE);
+	
+	return tmp_str;
+}
+
+static GFile*
+anjuta_util_get_user_cache_filev (const gchar* path, va_list list)
+{
+	gchar *uri_str, *base_path, *dir;
+	GFile *uri;
+	const gchar anjuta_prefix[] = "anjuta";
+	base_path = g_build_filename (g_get_user_cache_dir(), anjuta_prefix, path, NULL);
+
+	uri_str = anjuta_util_construct_pathv (base_path, list);
+	g_free (base_path);
+
+	uri = g_file_new_for_path (uri_str);
+	dir = g_path_get_dirname (uri_str);
+	g_free(uri_str);
+	if (!anjuta_util_create_dir (dir)) return NULL;
+
+	return uri;
+}
+
+GFile*
+anjuta_util_get_user_cache_file (const gchar* path, ...)
+{
+	va_list list;
+	va_start (list, path);
+	return anjuta_util_get_user_cache_filev (path, list);
+}
+
+static GFile*
+anjuta_util_get_user_config_filev (const gchar* path, va_list list)
+{
+	gchar *uri_str, *base_path, *dir;
+	GFile *uri;
+	const gchar anjuta_prefix[] = "anjuta";
+	base_path = g_build_filename (g_get_user_config_dir(), anjuta_prefix, path, NULL);
+
+	uri_str = anjuta_util_construct_pathv (base_path, list);
+	g_free (base_path);
+
+	uri = g_file_new_for_path (uri_str);
+	dir = g_path_get_dirname (uri_str);
+	g_free(uri_str);
+	if (!anjuta_util_create_dir (dir)) return NULL;
+
+	return uri;
+}
+
+GFile*
+anjuta_util_get_user_config_file (const gchar* path, ...)
+{
+	va_list list;
+	va_start (list, path);
+	return anjuta_util_get_user_config_filev (path, list);
+}
+
+static GFile*
+anjuta_util_get_user_data_filev (const gchar* path, va_list list)
+{
+	gchar *uri_str, *base_path, *dir;
+	GFile *uri;
+	const gchar anjuta_prefix[] = "anjuta";
+	base_path = g_build_filename (g_get_user_data_dir(), anjuta_prefix, path, NULL);
+
+	uri_str = anjuta_util_construct_pathv (base_path, list);
+	g_free (base_path);
+
+	uri = g_file_new_for_path (uri_str);
+	dir = g_path_get_dirname (uri_str);
+	g_free(uri_str);
+	if (!anjuta_util_create_dir (dir)) return NULL;
+
+	return uri;
+}
+
+GFile*
+anjuta_util_get_user_data_file (const gchar* path, ...)
+{
+	va_list list;
+	va_start (list, path);
+	return anjuta_util_get_user_data_filev (path, list);
+}
+
+gchar*
+anjuta_util_get_user_cache_file_path (const gchar* path, ...)
+{
+	va_list list;
+	GFile *file;
+	gchar *file_path;
+	va_start (list, path);
+	file = anjuta_util_get_user_cache_filev (path, list);
+	file_path = g_file_get_path (file);
+	g_object_unref (file);
+
+	return file_path;
+}
+
+gchar*
+anjuta_util_get_user_config_file_path (const gchar* path, ...)
+{
+	va_list list;
+	GFile *file;
+	gchar *file_path; 
+	va_start (list, path);
+	file = anjuta_util_get_user_config_filev (path, list);
+	file_path = g_file_get_path (file);
+	g_object_unref (file);
+
+	return file_path;
+}
+
+gchar*
+anjuta_util_get_user_data_file_path (const gchar* path, ...)
+{
+	va_list list;
+	GFile *file;
+	gchar *file_path;;
+	va_start (list, path);
+	file = anjuta_util_get_user_data_filev (path, list);
+	file_path = g_file_get_path (file);
+	g_object_unref (file);
+
+	return file_path;
+}
+
Index: libanjuta/anjuta-utils.h
===================================================================
--- libanjuta/anjuta-utils.h	(revision 4054)
+++ libanjuta/anjuta-utils.h	(working copy)
@@ -23,6 +23,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <sys/types.h>
+#include <gio/gio.h>
 
 #include <libanjuta/anjuta-preferences.h>
 
@@ -123,9 +124,14 @@
 							   const gchar *doc_id,
 							   const gchar *file_name);
 
-gchar *anjuta_util_get_user_config_dir (void);
+/* XDG BaseDir specifcation functions */
+GFile* anjuta_util_get_user_data_file (const gchar* path, ...);
+GFile* anjuta_util_get_user_cache_file (const gchar* path, ...);
+GFile* anjuta_util_get_user_config_file (const gchar* path, ...);
+gchar* anjuta_util_get_user_data_file_path (const gchar* path, ...);
+gchar* anjuta_util_get_user_cache_file_path (const gchar* path, ...);
+gchar* anjuta_util_get_user_config_file_path (const gchar* path, ...);
 
-
 /* Temporarily copied here */
 
 #define ANJUTA_TYPE_BEGIN(class_name, prefix, parent_type) \
Index: libanjuta/anjuta-ui.c
===================================================================
--- libanjuta/anjuta-ui.c	(revision 4054)
+++ libanjuta/anjuta-ui.c	(working copy)
@@ -951,17 +951,7 @@
 static gchar *
 anjuta_ui_get_accel_file (void)
 {
-	gchar *anjuta_dir = NULL;
-	gchar *filename = NULL;
-
-	anjuta_dir = anjuta_util_get_user_config_dir ();
-
-	if (anjuta_dir != NULL)
-		filename = g_build_filename (anjuta_dir, "anjuta-accels", NULL);
-	
-	g_free (anjuta_dir);
-
-	return filename;
+	return anjuta_util_get_user_config_file_path ("anjuta-accels", NULL);
 }
 
 void
@@ -989,3 +979,4 @@
 		g_free (filename);
 	}
 }
+
