Convert NASettings to a private singleton
[nautilus-actions.git] / src / io-desktop / nadp-xdg-dirs.c
blobd44130d622741f839a5278e0b7714f29871e0981
1 /*
2 * Nautilus-Actions
3 * A Nautilus extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 * This Program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This Program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this Library; see the file COPYING. If not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307, USA.
24 * Authors:
25 * Frederic Ruaudel <grumz@grumz.net>
26 * Rodrigo Moya <rodrigo@gnome-db.org>
27 * Pierre Wieser <pwieser@trychlos.org>
28 * ... and many others (see AUTHORS)
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
35 #include <api/na-core-utils.h>
37 #include "nadp-xdg-dirs.h"
39 /**
40 * nadp_xdg_dirs_get_data_dirs:
42 * Returns: the ordered list of data directories, most important first,
43 * as a GSList of newly allocated strings.
45 * The returned list, along with the pointed out strings, should be
46 * freed by the caller.
48 GSList *
49 nadp_xdg_dirs_get_data_dirs( void )
51 GSList *listdirs;
52 gchar *userdir;
53 GSList *datadirs;
55 userdir = nadp_xdg_dirs_get_user_data_dir();
56 listdirs = g_slist_prepend( NULL, userdir );
58 datadirs = nadp_xdg_dirs_get_system_data_dirs();
59 listdirs = g_slist_concat( listdirs, datadirs );
61 return( listdirs );
64 /**
65 * nadp_xdg_dirs_get_user_data_dir:
67 * Returns: the path to the single base directory relative to which
68 * user-specific data files should be written, as a newly allocated
69 * string.
71 * This directory is defined by the environment variable XDG_DATA_HOME.
72 * It defaults to ~/.local/share.
73 * cf. http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
75 * The returned string should be g_free() by the caller.
77 gchar *
78 nadp_xdg_dirs_get_user_data_dir( void )
80 gchar *dir;
82 dir = g_strdup( g_get_user_data_dir());
84 return( dir );
87 /**
88 * nadp_xdg_dirs_get_system_data_dirs:
90 * Returns: the set of preference ordered base directories relative to
91 * which data files should be written, as a GSList of newly allocated
92 * strings.
94 * This set of directories is defined by the environment variable
95 * XDG_DATA_DIRS. It defaults to /usr/local/share:/usr/share.
97 * source: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
99 * The returned list, along with the pointed out strings, should be freed
100 * by the caller.
102 GSList *
103 nadp_xdg_dirs_get_system_data_dirs( void )
105 const gchar **dirs;
106 GSList *paths;
108 dirs = ( const gchar ** ) g_get_system_data_dirs();
110 paths = na_core_utils_slist_from_array( dirs );
112 return( paths );