Extract get_xdg_config_dirs()
This commit is contained in:
parent
021fdcc97c
commit
f453b9dd43
26
src/sdtui.c
26
src/sdtui.c
|
@ -61,6 +61,21 @@ unichar_width (gunichar ch)
|
||||||
return 1 + g_unichar_iswide (ch);
|
return 1 + g_unichar_iswide (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// At times, GLib even with its sheer size is surprisingly useless,
|
||||||
|
// and I need to port some code over from "liberty".
|
||||||
|
|
||||||
|
static gchar **
|
||||||
|
get_xdg_config_dirs (void)
|
||||||
|
{
|
||||||
|
GPtrArray *paths = g_ptr_array_new ();
|
||||||
|
g_ptr_array_add (paths, (gpointer) g_get_user_config_dir ());
|
||||||
|
for (const gchar *const *system = g_get_system_config_dirs ();
|
||||||
|
*system; system++)
|
||||||
|
g_ptr_array_add (paths, (gpointer) *system);
|
||||||
|
g_ptr_array_add (paths, NULL);
|
||||||
|
return (gchar **) g_ptr_array_free (paths, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Application -------------------------------------------------------------
|
// --- Application -------------------------------------------------------------
|
||||||
|
|
||||||
#define ATTRIBUTE_TABLE(XX) \
|
#define ATTRIBUTE_TABLE(XX) \
|
||||||
|
@ -320,12 +335,7 @@ static void
|
||||||
app_load_config (Application *self, GError **e)
|
app_load_config (Application *self, GError **e)
|
||||||
{
|
{
|
||||||
GKeyFile *kf = g_key_file_new ();
|
GKeyFile *kf = g_key_file_new ();
|
||||||
GPtrArray *paths = g_ptr_array_new ();
|
gchar **paths = get_xdg_config_dirs ();
|
||||||
g_ptr_array_add (paths, (gpointer) g_get_user_config_dir ());
|
|
||||||
for (const gchar *const *system = g_get_system_config_dirs ();
|
|
||||||
*system; system++)
|
|
||||||
g_ptr_array_add (paths, (gpointer) *system);
|
|
||||||
g_ptr_array_add (paths, NULL);
|
|
||||||
|
|
||||||
// XXX: if there are dashes in the final path component,
|
// XXX: if there are dashes in the final path component,
|
||||||
// the function tries to replace them with directory separators,
|
// the function tries to replace them with directory separators,
|
||||||
|
@ -333,8 +343,8 @@ app_load_config (Application *self, GError **e)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
g_key_file_load_from_dirs (kf,
|
g_key_file_load_from_dirs (kf,
|
||||||
PROJECT_NAME G_DIR_SEPARATOR_S PROJECT_NAME ".conf",
|
PROJECT_NAME G_DIR_SEPARATOR_S PROJECT_NAME ".conf",
|
||||||
(const gchar **) paths->pdata, NULL, 0, &error);
|
(const gchar **) paths, NULL, 0, &error);
|
||||||
g_ptr_array_free (paths, TRUE);
|
g_strfreev (paths);
|
||||||
|
|
||||||
// TODO: proper error handling showing all relevant information;
|
// TODO: proper error handling showing all relevant information;
|
||||||
// we can afford that here since the terminal hasn't been initialized yet
|
// we can afford that here since the terminal hasn't been initialized yet
|
||||||
|
|
Loading…
Reference in New Issue