Skip to content

Commit ce401d7

Browse files
committed
Merge branch '1851_xdg_fix'
* 1851_xdg_fix: Tweak description of MC_HOME environment variable. Ticket #1851: fixed support of XDG_* shell variables
2 parents 42f2b04 + e4fc99d commit ce401d7

File tree

8 files changed

+67
-26
lines changed

8 files changed

+67
-26
lines changed

doc/man/es/mc.1.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,8 +3727,8 @@ personal o de sistema.
37273727
To change default home directory of MC, you can use
37283728
.BR MC_HOME
37293729
environment variable. The value of MC_HOME must be an absolute path. If MC_HOME
3730-
variable is unset or empty, HOME variable is used. If HOME variable is unset
3731-
or empty, MC home directory is get from GLib library.
3730+
is unset or empty, HOME variable is used. If HOME is unset or empty, MC
3731+
directories are get from GLib library.
37323732
.\"SKIP_SECTION"
37333733
.SH "LICENCIA"
37343734
Este programa se distribuye en los términos que recoge la Licencia Pública

doc/man/hu/mc.1.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,8 +3242,8 @@ használja a home, vagy rendszerszintű alkalmazás menü helyett.
32423242
To change default home directory of MC, you can use
32433243
.BR MC_HOME
32443244
environment variable. The value of MC_HOME must be an absolute path. If MC_HOME
3245-
variable is unset or empty, HOME variable is used. If HOME variable is unset
3246-
or empty, MC home directory is get from GLib library.
3245+
is unset or empty, HOME variable is used. If HOME is unset or empty, MC
3246+
directories are get from GLib library.
32473247
.\"NODE "AVAILABILITY"
32483248
.SH "A Midnight Commander frissítése"
32493249
A program legutolsó verzióját az ftp.nuclecu.unam.mx címen a

doc/man/it/mc.1.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,8 +3231,8 @@ al posto del menu delle applicazioni utente o di sistema.
32313231
To change default home directory of MC, you can use
32323232
.BR MC_HOME
32333233
environment variable. The value of MC_HOME must be an absolute path. If MC_HOME
3234-
variable is unset or empty, HOME variable is used. If HOME variable is unset
3235-
or empty, MC home directory is get from GLib library.
3234+
is unset or empty, HOME variable is used. If HOME is unset or empty, MC
3235+
directories are get from GLib library.
32363236
.\"SKIP_SECTION"
32373237
.SH "LICENZA"
32383238
Questo programma è distribuito sotto i termini della Licenza Generale

doc/man/mc.1.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,11 +4161,11 @@ The directory list for the directory tree and tree view features.
41614161
Local user\-defined menu. If this file is present, it is used instead of
41624162
the home or system\-wide applications menu.
41634163
.PP
4164-
To change default home directory of MC, you can use
4164+
To change default root directory of MC, you can use
41654165
.BR MC_HOME
41664166
environment variable. The value of MC_HOME must be an absolute path. If MC_HOME
4167-
variable is unset or empty, HOME variable is used. If HOME variable is unset
4168-
or empty, MC home directory is get from GLib library.
4167+
is unset or empty, HOME variable is used. If HOME is unset or empty, MC
4168+
directories are get from GLib library.
41694169
.\"SKIP_SECTION"
41704170
.SH "LICENSE"
41714171
This program is distributed under the terms of the GNU General Public

doc/man/pl/mc.1.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,8 +2937,8 @@ jest używany zamiast pliku w katalogu domowym i ogólnosystemowego.
29372937
To change default home directory of MC, you can use
29382938
.BR MC_HOME
29392939
environment variable. The value of MC_HOME must be an absolute path. If MC_HOME
2940-
variable is unset or empty, HOME variable is used. If HOME variable is unset
2941-
or empty, MC home directory is get from GLib library.
2940+
is unset or empty, HOME variable is used. If HOME is unset or empty, MC
2941+
directories are get from GLib library.
29422942
.\"SKIP_SECTION"
29432943
.SH LICENCJA
29442944
Program jest dystrybuowany na zasadach licencji GNU General Public License

doc/man/ru/mc.1.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4557,12 +4557,12 @@ Commander; используется только в тех случаях, ко
45574557
используется вместо файла меню из домашнего каталога пользователя и
45584558
общесистемного меню.
45594559
.PP
4560-
Для того, чтобы изменить домашний каталог MC, установленный по умолчанию,
4560+
Для того, чтобы изменить корневой каталог MC, установленный по умолчанию,
45614561
можно использовать переменную окружения
45624562
.BR MC_HOME .
45634563
Значением этой переменный должен быть абсолютный путь. Если переменная MC_HOME
45644564
не определена или пуста, используется переменная окружения HOME. Если и HOME
4565-
не определена или пуста, домашний каталог MC определяется средствами библиотеки GLib.
4565+
не определена или пуста, каталоги MC определяются средствами библиотеки GLib.
45664566
.\"SKIP_SECTION"
45674567
.\" "LICENSE"
45684568
.SH Лицензия

lib/mcconfig/paths.c

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ static char *mc_cache_str = NULL;
5252
static char *mc_data_str = NULL;
5353

5454
static const char *homedir = NULL;
55+
/* value of $MC_HOME */
56+
static const char *mc_home = NULL;
5557

5658
static gboolean config_dir_present = FALSE;
5759

@@ -276,18 +278,56 @@ mc_config_init_config_paths (GError ** error)
276278
if (xdg_vars_initialized)
277279
return;
278280

281+
/* init mc_home and homedir if not yet */
282+
(void) mc_config_get_home_dir ();
283+
279284
#ifdef MC_HOMEDIR_XDG
280-
dir = g_build_filename (mc_config_get_home_dir (), ".config", (char *) NULL);
281-
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
282-
g_free (dir);
285+
if (mc_home != NULL)
286+
{
287+
dir = g_build_filename (mc_home, ".config", (char *) NULL);
288+
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
289+
g_free (dir);
283290

284-
dir = g_build_filename (mc_config_get_home_dir (), ".cache", (char *) NULL);
285-
mc_cache_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
286-
g_free (dir);
291+
dir = g_build_filename (mc_home, ".cache", (char *) NULL);
292+
mc_cache_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
293+
g_free (dir);
287294

288-
dir = g_build_filename (mc_config_get_home_dir (), ".local", "share", (char *) NULL);
289-
mc_data_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
290-
g_free (dir);
295+
dir = g_build_filename (mc_home, ".local", "share", (char *) NULL);
296+
mc_data_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
297+
g_free (dir);
298+
}
299+
else
300+
{
301+
dir = (char *) g_get_user_config_dir ();
302+
if (dir != NULL && *dir != '\0')
303+
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
304+
else
305+
{
306+
dir = g_build_filename (homedir, ".config", (char *) NULL);
307+
mc_config_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
308+
g_free (dir);
309+
}
310+
311+
dir = (char *) g_get_user_cache_dir ();
312+
if (dir != NULL && *dir != '\0')
313+
mc_cache_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
314+
else
315+
{
316+
dir = g_build_filename (homedir, ".cache", (char *) NULL);
317+
mc_cache_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
318+
g_free (dir);
319+
}
320+
321+
dir = (char *) g_get_user_data_dir ();
322+
if (dir != NULL && *dir != '\0')
323+
mc_data_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
324+
else
325+
{
326+
dir = g_build_filename (homedir, ".local", "share", (char *) NULL);
327+
mc_data_str = mc_config_init_one_config_path (dir, MC_USERCONF_DIR, error);
328+
g_free (dir);
329+
}
330+
}
291331

292332
mc_config_fix_migrated_rules ();
293333
#else /* MC_HOMEDIR_XDG */
@@ -302,8 +342,7 @@ mc_config_init_config_paths (GError ** error)
302342
dir = g_build_filename (mc_config_get_home_dir (), MC_USERCONF_DIR, (char *) NULL);
303343
}
304344

305-
mc_data_str = mc_cache_str = mc_config_str =
306-
mc_config_init_one_config_path (dir, "", error);
345+
mc_data_str = mc_cache_str = mc_config_str = mc_config_init_one_config_path (dir, "", error);
307346

308347
g_free (dir);
309348
#endif /* MC_HOMEDIR_XDG */
@@ -363,6 +402,8 @@ mc_config_get_home_dir (void)
363402
homedir = g_getenv ("MC_HOME");
364403
if (homedir == NULL || *homedir == '\0')
365404
homedir = g_getenv ("HOME");
405+
else
406+
mc_home = homedir;
366407
if (homedir == NULL || *homedir == '\0')
367408
homedir = g_get_home_dir ();
368409
}
@@ -499,7 +540,7 @@ mc_config_get_full_vpath (const char *config_name)
499540

500541
str_path = mc_config_get_full_path (config_name);
501542

502-
ret_vpath = vfs_path_from_str(str_path);
543+
ret_vpath = vfs_path_from_str (str_path);
503544
g_free (str_path);
504545
return ret_vpath;
505546
}

src/textconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ show_version (void)
177177
void
178178
show_datadirs_extended (void)
179179
{
180-
(void) printf ("%s %s\n", _("Home directory:"), mc_config_get_home_dir ());
180+
(void) printf ("%s %s\n", _("Root directory:"), mc_config_get_home_dir ());
181181
(void) puts ("");
182182

183183
PRINTF_GROUP (_("System data"));

0 commit comments

Comments
 (0)