1
1

Ticket #2071: a bit cleanup of getting profile name.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2013-06-17 13:02:02 +04:00
родитель e066a25cc5
Коммит d9b41df7a1
4 изменённых файлов: 36 добавлений и 32 удалений

Просмотреть файл

@ -59,7 +59,7 @@
#include "lib/util.h" /* Q_() */
#include "lib/widget.h"
#include "src/setup.h" /* For profile_name */
#include "src/setup.h"
#include "src/history.h" /* MC_HISTORY_ESC_TIMEOUT */
#include "src/execute.h" /* pause_after_run */
#ifdef ENABLE_BACKGROUND

Просмотреть файл

@ -17,6 +17,7 @@
Norbert Warmuth, 1997
Miguel de Icaza, 1996, 1999
Slava Zanko <slavazanko@gmail.com>, 2013
Andrew Borodin <aborodin@vmail.ru>, 2013
This file is part of the Midnight Commander.
@ -58,7 +59,7 @@
#include "lib/hook.h"
#include "lib/util.h"
#include "src/setup.h"
#include "src/setup.h" /* setup_init() */
#include "treestore.h"
@ -536,7 +537,7 @@ remove_entry (tree_entry * entry)
/* --------------------------------------------------------------------------------------------- */
static void
process_special_dirs (GList ** special_dirs, char *file)
process_special_dirs (GList ** special_dirs, const char *file)
{
gchar **buffers, **start_buff;
mc_config_t *cfg;
@ -572,10 +573,13 @@ should_skip_directory (const vfs_path_t * vpath)
if (!loaded)
{
loaded = TRUE;
setup_init ();
const char *profile_name;
profile_name = setup_init ();
process_special_dirs (&special_dirs, profile_name);
process_special_dirs (&special_dirs, global_profile_name);
loaded = TRUE;
}
for (l = special_dirs; l != NULL; l = g_list_next (l))

Просмотреть файл

@ -2,7 +2,7 @@
Setup loading/saving.
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2009, 2010, 2011
2006, 2007, 2009, 2010, 2011, 2013
The Free Software Foundation, Inc.
This file is part of the Midnight Commander.
@ -83,7 +83,6 @@
/*** global variables ****************************************************************************/
char *profile_name; /* ${XDG_CONFIG_HOME}/mc/ini */
char *global_profile_name; /* mc.lib */
/* Only used at program boot */
@ -221,6 +220,7 @@ GArray *macros_list;
/*** file scope variables ************************************************************************/
static char *profile_name = NULL; /* ${XDG_CONFIG_HOME}/mc/ini */
static char *panels_profile_name = NULL; /* ${XDG_CACHE_HOME}/mc/panels.ini */
/* *INDENT-OFF* */
@ -871,41 +871,42 @@ save_panel_types (void)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
char *
const char *
setup_init (void)
{
char *profile;
char *inifile;
if (profile_name != NULL)
return profile_name;
profile = mc_config_get_full_path (MC_CONFIG_FILE);
if (!exist_file (profile))
if (profile_name == NULL)
{
inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", NULL);
if (exist_file (inifile))
char *profile;
profile = mc_config_get_full_path (MC_CONFIG_FILE);
if (!exist_file (profile))
{
g_free (profile);
profile = inifile;
}
else
{
g_free (inifile);
inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", NULL);
char *inifile;
inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", NULL);
if (exist_file (inifile))
{
g_free (profile);
profile = inifile;
}
else
{
g_free (inifile);
inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", NULL);
if (!exist_file (inifile))
g_free (inifile);
else
{
g_free (profile);
profile = inifile;
}
}
}
profile_name = profile;
}
profile_name = profile;
return profile;
return profile_name;
}
/* --------------------------------------------------------------------------------------------- */
@ -913,7 +914,7 @@ setup_init (void)
void
load_setup (void)
{
char *profile;
const char *profile;
size_t i;
char *buffer;
const char *kt;
@ -1136,11 +1137,11 @@ done_setup (void)
g_free (clipboard_store_path);
g_free (clipboard_paste_path);
g_free (profile_name);
g_free (global_profile_name);
g_free (mc_global.tty.color_terminal_string);
g_free (mc_global.tty.term_color_string);
g_free (mc_global.tty.setup_color_string);
g_free (profile_name);
g_free (panels_profile_name);
mc_config_deinit (mc_main_config);
mc_config_deinit (mc_panels_config);

Просмотреть файл

@ -73,7 +73,6 @@ struct mc_fhl_struct;
/*** global variables defined in .c file *********************************************************/
/* global paremeters */
extern char *profile_name;
extern char *global_profile_name;
extern int confirm_delete;
extern int confirm_directory_hotlist_delete;
@ -135,7 +134,7 @@ extern GArray *macros_list;
/*** declarations of public functions ************************************************************/
char *setup_init (void);
const char *setup_init (void);
void load_setup (void);
gboolean save_setup (gboolean save_options, gboolean save_panel_options);
void done_setup (void);