Changed all source files for use new config module
Этот коммит содержится в:
родитель
5edb3a645e
Коммит
a70255f643
@ -1,7 +1,7 @@
|
||||
/* Some misc dialog boxes for the program.
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006 Free Software Foundation, Inc.
|
||||
2005, 2006, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Authors: 1994, 1995 Miguel de Icaza
|
||||
1995 Jakub Jelinek
|
||||
@ -42,7 +42,7 @@
|
||||
#include "widget.h" /* The widgets for the nice dialog manager */
|
||||
#include "wtools.h"
|
||||
#include "setup.h" /* For profile_name */
|
||||
#include "profile.h" /* Load/save user formats */
|
||||
#include "../src/mcconfig/mcconfig.h" /* Load/save user formats */
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
#include "command.h" /* For cmdline */
|
||||
#include "dir.h"
|
||||
@ -236,7 +236,7 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
|
||||
for (i = 0; i < LIST_TYPES; i++)
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
section = g_strconcat ("Temporal:", p, (char *) NULL);
|
||||
if (!profile_has_section (section, profile_name)) {
|
||||
if (! mc_config_has_group (mc_main_config, section)) {
|
||||
g_free (section);
|
||||
section = g_strdup (p);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
They normally operate on the current panel.
|
||||
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -65,7 +65,7 @@
|
||||
#include "ext.h" /* regex_command() */
|
||||
#include "boxes.h" /* cd_dialog() */
|
||||
#include "setup.h" /* save_setup() */
|
||||
#include "profile.h" /* PROFILE_NAME */
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "execute.h" /* toggle_panels() */
|
||||
#include "history.h"
|
||||
#include "strutil.h"
|
||||
@ -1294,8 +1294,6 @@ void
|
||||
save_setup_cmd (void)
|
||||
{
|
||||
save_setup ();
|
||||
sync_profiles ();
|
||||
|
||||
message (D_NORMAL, _(" Setup "), _(" Setup saved to ~/%s"), PROFILE_NAME);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Directory hotlist -- for the Midnight Commander
|
||||
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
1994 Radek Doulik
|
||||
@ -46,7 +46,7 @@
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "setup.h" /* For profile_bname */
|
||||
#include "profile.h" /* Load/save directories hotlist */
|
||||
#include "../src/mcconfig/mcconfig.h" /* Load/save directories hotlist */
|
||||
#include "wtools.h" /* QuickDialog */
|
||||
#include "panel.h" /* current_panel */
|
||||
#include "main.h" /* repaint_screen */
|
||||
@ -613,8 +613,7 @@ init_hotlist (int list_type)
|
||||
do_refresh ();
|
||||
|
||||
hotlist_state.expanded =
|
||||
GetPrivateProfileInt ("HotlistConfig", "expanded_view_of_groups",
|
||||
0, profile_name);
|
||||
mc_config_get_int (mc_main_config, "HotlistConfig", "expanded_view_of_groups", 0);
|
||||
|
||||
if (list_type == LIST_VFSLIST) {
|
||||
title = _("Active VFS directories");
|
||||
@ -1166,29 +1165,39 @@ char *hotlist_cmd (int vfs_or_hotlist)
|
||||
static void
|
||||
load_group (struct hotlist *grp)
|
||||
{
|
||||
void *profile_keys;
|
||||
char *key, *value;
|
||||
gchar **profile_keys, **keys;
|
||||
gsize len;
|
||||
char *group_section;
|
||||
struct hotlist *current = 0;
|
||||
|
||||
group_section = find_group_section (grp);
|
||||
|
||||
profile_keys = profile_init_iterator (group_section, profile_name);
|
||||
profile_keys = keys = mc_config_get_keys (mc_main_config, group_section, &len);
|
||||
|
||||
current_group = grp;
|
||||
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
add2hotlist (g_strdup (value), g_strdup (key), HL_TYPE_GROUP, 0);
|
||||
while (*profile_keys){
|
||||
add2hotlist (
|
||||
mc_config_get_string(mc_main_config, group_section, *profile_keys, ""),
|
||||
g_strdup (*profile_keys),
|
||||
HL_TYPE_GROUP,
|
||||
0);
|
||||
profile_keys++;
|
||||
}
|
||||
g_free (group_section);
|
||||
g_strfreev(keys);
|
||||
|
||||
profile_keys = profile_init_iterator (grp->directory, profile_name);
|
||||
profile_keys = keys = mc_config_get_keys (mc_main_config, grp->directory,&len);
|
||||
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
add2hotlist (g_strdup (value),g_strdup (key), HL_TYPE_ENTRY, 0);
|
||||
while (*profile_keys){
|
||||
add2hotlist (
|
||||
mc_config_get_string(mc_main_config,group_section,*profile_keys,""),
|
||||
g_strdup (*profile_keys),
|
||||
HL_TYPE_ENTRY,
|
||||
0);
|
||||
profile_keys++;
|
||||
}
|
||||
g_strfreev(keys);
|
||||
|
||||
for (current = grp->head; current; current = current->next)
|
||||
load_group (current);
|
||||
@ -1399,20 +1408,22 @@ static void
|
||||
clean_up_hotlist_groups (const char *section)
|
||||
{
|
||||
char *grp_section;
|
||||
void *profile_keys;
|
||||
char *key, *value;
|
||||
gchar **profile_keys, **keys;
|
||||
gsize len;
|
||||
|
||||
grp_section = g_strconcat (section, ".Group", (char *) NULL);
|
||||
if (profile_has_section (section, profile_name))
|
||||
profile_clean_section (section, profile_name);
|
||||
if (profile_has_section (grp_section, profile_name)) {
|
||||
profile_keys = profile_init_iterator (grp_section, profile_name);
|
||||
if (mc_config_has_group(mc_main_config, section))
|
||||
mc_config_del_group (mc_main_config, section);
|
||||
|
||||
while (profile_keys) {
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
clean_up_hotlist_groups (key);
|
||||
if (mc_config_has_group (mc_main_config, grp_section)) {
|
||||
profile_keys = keys = mc_config_get_keys (mc_main_config, grp_section,&len);
|
||||
|
||||
while (*profile_keys) {
|
||||
clean_up_hotlist_groups (*profile_keys);
|
||||
profile_keys++;
|
||||
}
|
||||
profile_clean_section (grp_section, profile_name);
|
||||
g_strfreev(keys);
|
||||
mc_config_del_group (mc_main_config, grp_section);
|
||||
}
|
||||
g_free (grp_section);
|
||||
}
|
||||
@ -1471,7 +1482,7 @@ load_hotlist (void)
|
||||
|
||||
if (remove_old_list) {
|
||||
clean_up_hotlist_groups ("Hotlist");
|
||||
sync_profiles ();
|
||||
mc_config_save_file (mc_main_config);
|
||||
}
|
||||
|
||||
stat (hotlist_file_name, &stat_buf);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Panel layout module for the Midnight Commander
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007 Free Software Foundation, Inc.
|
||||
2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written: 1995 Janne Kukonlehto
|
||||
1995 Miguel de Icaza
|
||||
@ -54,7 +54,7 @@
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "command.h"
|
||||
#include "profile.h" /* For sync_profiles() */
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "mouse.h"
|
||||
#include "main-widgets.h"
|
||||
#include "main.h"
|
||||
@ -538,7 +538,7 @@ void layout_cmd (void)
|
||||
}
|
||||
if (result == B_EXIT){
|
||||
save_layout ();
|
||||
sync_profiles ();
|
||||
mc_config_save_file (mc_main_config);
|
||||
}
|
||||
|
||||
destroy_dlg (layout_dlg);
|
||||
|
10
src/learn.c
10
src/learn.c
@ -1,6 +1,6 @@
|
||||
/* Learn keys
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2007 Free Software Foundation, Inc.
|
||||
2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written by: 1995 Jakub Jelinek
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include "color.h"
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "profile.h" /* Save profile */
|
||||
#include "../src/mcconfig/mcconfig.h" /* Save profile */
|
||||
#include "key.h"
|
||||
#include "setup.h"
|
||||
#include "main.h"
|
||||
@ -318,8 +318,8 @@ learn_save (void)
|
||||
for (i = 0; i < learn_total; i++) {
|
||||
if (learnkeys [i].sequence != NULL) {
|
||||
profile_changed = 1;
|
||||
WritePrivateProfileString (section, key_name_conv_tab [i].name,
|
||||
learnkeys [i].sequence, profile_name);
|
||||
mc_config_set_string(mc_main_config, section,
|
||||
key_name_conv_tab [i].name, learnkeys [i].sequence);
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ learn_save (void)
|
||||
* disk is much worse.
|
||||
*/
|
||||
if (profile_changed)
|
||||
sync_profiles ();
|
||||
mc_config_save_file (mc_main_config);
|
||||
|
||||
g_free (section);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
/*
|
||||
Provides a log file to ease tracing the program.
|
||||
|
||||
Copyright (C) 2006 Roland Illig <roland.illig@gmx.de>.
|
||||
Copyright (C) 2006, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written: 2006 Roland Illig <roland.illig@gmx.de>.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -33,6 +35,7 @@
|
||||
#include "global.h"
|
||||
#include "logging.h"
|
||||
#include "setup.h"
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
|
||||
@ -41,13 +44,10 @@ is_logging_enabled(void)
|
||||
{
|
||||
static gboolean logging_initialized = FALSE;
|
||||
static gboolean logging_enabled = FALSE;
|
||||
char *mc_ini;
|
||||
|
||||
if (!logging_initialized) {
|
||||
mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME);
|
||||
logging_enabled =
|
||||
get_int(mc_ini, "development.enable_logging", FALSE);
|
||||
g_free(mc_ini);
|
||||
logging_enabled = mc_config_get_int (mc_main_config,
|
||||
CONFIG_APP_SECTION, "development.enable_logging", FALSE);
|
||||
logging_initialized = TRUE;
|
||||
}
|
||||
return logging_enabled;
|
||||
|
10
src/main.c
10
src/main.c
@ -1,6 +1,6 @@
|
||||
/* Main program for the Midnight Commander
|
||||
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written by: 1994, 1995, 1996, 1997 Miguel de Icaza
|
||||
1994, 1995 Janne Kukonlehto
|
||||
@ -54,7 +54,7 @@
|
||||
#include "subshell.h"
|
||||
#include "key.h" /* For init_key() and mi_getch() */
|
||||
#include "setup.h" /* save_setup() */
|
||||
#include "profile.h" /* free_profiles() */
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "boxes.h" /* sort_box() */
|
||||
#include "layout.h"
|
||||
#include "cmd.h" /* Normal commands */
|
||||
@ -1477,11 +1477,9 @@ done_mc (void)
|
||||
static void
|
||||
done_mc_profile (void)
|
||||
{
|
||||
if (!auto_save_setup)
|
||||
profile_forget_profile (profile_name);
|
||||
sync_profiles ();
|
||||
if (auto_save_setup)
|
||||
mc_config_save_file (mc_main_config);
|
||||
done_setup ();
|
||||
free_profiles ();
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Configure box module for the Midnight Commander
|
||||
Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2007 Free Software Foundation, Inc.
|
||||
2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -38,7 +38,7 @@
|
||||
#include "widget.h"
|
||||
#include "setup.h" /* For save_setup() */
|
||||
#include "main.h"
|
||||
#include "profile.h" /* For sync_profiles */
|
||||
#include "../src/mcconfig/mcconfig.h" /* For mc_config_save_file */
|
||||
#include "strutil.h"
|
||||
|
||||
#include "panel.h" /* Needed for the externs */
|
||||
@ -243,7 +243,7 @@ void configure_box (void)
|
||||
/* If they pressed the save button */
|
||||
if (result == B_EXIT){
|
||||
save_configure ();
|
||||
sync_profiles ();
|
||||
mc_config_save_file (mc_main_config);
|
||||
}
|
||||
|
||||
destroy_dlg (conf_dlg);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* External panelize
|
||||
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2007 Free Software Foundation, Inc.
|
||||
2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Written by: 1995 Janne Kukonlehto
|
||||
1995 Jakub Jelinek
|
||||
@ -41,7 +41,7 @@
|
||||
#include "widget.h"
|
||||
#include "wtools.h" /* For common_dialog_repaint() */
|
||||
#include "setup.h" /* For profile_bname */
|
||||
#include "profile.h" /* Load/save directories panelize */
|
||||
#include "../src/mcconfig/mcconfig.h" /* Load/save directories panelize */
|
||||
#include "dir.h"
|
||||
#include "panel.h" /* current_panel */
|
||||
#include "main.h" /* repaint_screen */
|
||||
@ -312,39 +312,43 @@ external_panelize (void)
|
||||
|
||||
void load_panelize (void)
|
||||
{
|
||||
void *profile_keys;
|
||||
char *key, *value;
|
||||
gchar **profile_keys, **keys;
|
||||
gsize len;
|
||||
|
||||
profile_keys = profile_init_iterator (panelize_section, profile_name);
|
||||
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section,&len);
|
||||
|
||||
add2panelize (g_strdup (_("Other command")), g_strdup (""));
|
||||
|
||||
if (!profile_keys){
|
||||
if (!profile_keys || *profile_keys == NULL){
|
||||
add2panelize (g_strdup (_("Find rejects after patching")), g_strdup ("find . -name \\*.rej -print"));
|
||||
add2panelize (g_strdup (_("Find *.orig after patching")), g_strdup ("find . -name \\*.orig -print"));
|
||||
add2panelize (g_strdup (_("Find SUID and SGID programs")), g_strdup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
|
||||
return;
|
||||
}
|
||||
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
add2panelize (g_strdup (key), g_strdup (value));
|
||||
while (*profile_keys){
|
||||
add2panelize (
|
||||
g_strdup (*profile_keys),
|
||||
mc_config_get_string(mc_main_config,panelize_section,*profile_keys,"")
|
||||
);
|
||||
profile_keys++;
|
||||
}
|
||||
g_strfreev(keys);
|
||||
}
|
||||
|
||||
void save_panelize (void)
|
||||
{
|
||||
struct panelize *current = panelize;
|
||||
|
||||
profile_clean_section (panelize_section, profile_name);
|
||||
mc_config_del_group (mc_main_config, panelize_section);
|
||||
for (;current; current = current->next){
|
||||
if (strcmp (current->label, _("Other command")))
|
||||
WritePrivateProfileString (panelize_section,
|
||||
current->label,
|
||||
current->command,
|
||||
profile_name);
|
||||
mc_config_set_string(mc_main_config,
|
||||
panelize_section,
|
||||
current->label,
|
||||
current->command);
|
||||
}
|
||||
sync_profiles ();
|
||||
mc_config_save_file (mc_main_config);
|
||||
}
|
||||
|
||||
void done_panelize (void)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Panel managing.
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +46,7 @@
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
#include "setup.h" /* For loading/saving panel options */
|
||||
#include "user.h"
|
||||
#include "profile.h"
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "execute.h"
|
||||
#include "widget.h"
|
||||
#include "menu.h" /* menubar_visible */
|
||||
@ -1142,7 +1142,7 @@ panel_new (const char *panel_name)
|
||||
panel->search_buffer[0] = 0;
|
||||
panel->frame_size = frame_half;
|
||||
section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
|
||||
if (!profile_has_section (section, profile_name)) {
|
||||
if (!mc_config_has_group (mc_main_config, section)) {
|
||||
g_free (section);
|
||||
section = g_strdup (panel->panel_name);
|
||||
}
|
||||
|
301
src/setup.c
301
src/setup.c
@ -1,6 +1,6 @@
|
||||
/* Setup loading/saving.
|
||||
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007 Free Software Foundation, Inc.
|
||||
2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -33,7 +33,7 @@
|
||||
#include "panel.h"
|
||||
#include "main.h"
|
||||
#include "tree.h" /* xtree_mode */
|
||||
#include "profile.h"
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "setup.h"
|
||||
#include "mouse.h" /* To make view.h happy */
|
||||
#include "view.h" /* For the externs */
|
||||
@ -72,14 +72,11 @@ extern int num_history_items_recorded;
|
||||
|
||||
char *profile_name; /* .mc/ini */
|
||||
char *global_profile_name; /* mc.lib */
|
||||
char *panels_profile_name; /* .mc/panels.ini */
|
||||
|
||||
char setup_color_string [4096];
|
||||
char term_color_string [4096];
|
||||
char color_terminal_string [512];
|
||||
|
||||
#define load_int(a,b,c) GetPrivateProfileInt(a,b,c,profile_name)
|
||||
#define load_string(a,b,c,d,e) GetPrivateProfileString(a,b,c,d,e,profile_name)
|
||||
#define save_string WritePrivateProfileString
|
||||
char *setup_color_string;
|
||||
char *term_color_string;
|
||||
char *color_terminal_string;
|
||||
|
||||
int startup_left_mode;
|
||||
int startup_right_mode;
|
||||
@ -250,40 +247,35 @@ static const struct {
|
||||
void
|
||||
panel_save_setup (struct WPanel *panel, const char *section)
|
||||
{
|
||||
char buffer [BUF_TINY];
|
||||
char *buffer;
|
||||
int i;
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->reverse);
|
||||
save_string (section, "reverse", buffer, profile_name);
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->case_sensitive);
|
||||
save_string (section, "case_sensitive", buffer, profile_name);
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->exec_first);
|
||||
save_string (section, "exec_first", buffer, profile_name);
|
||||
mc_config_set_int(mc_panels_config, section, "reverse", panel->reverse);
|
||||
mc_config_set_int(mc_panels_config, section, "case_sensitive", panel->case_sensitive);
|
||||
mc_config_set_int(mc_panels_config, section, "exec_first", panel->exec_first);
|
||||
|
||||
for (i = 0; sort_names [i].key; i++)
|
||||
if (sort_names [i].sort_type == (sortfn *) panel->sort_type){
|
||||
save_string (section, "sort_order",
|
||||
sort_names [i].key, profile_name);
|
||||
mc_config_set_string(mc_panels_config, section, "sort_order", sort_names [i].key);
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; list_types [i].key; i++)
|
||||
if (list_types [i].list_type == panel->list_type){
|
||||
save_string (section, "list_mode", list_types [i].key, profile_name);
|
||||
mc_config_set_string(mc_panels_config, section, "list_mode", list_types [i].key);
|
||||
break;
|
||||
}
|
||||
|
||||
save_string (section, "user_format",
|
||||
panel->user_format, profile_name);
|
||||
mc_config_set_string(mc_panels_config, section, "user_format", panel->user_format);
|
||||
|
||||
for (i = 0; i < LIST_TYPES; i++){
|
||||
g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
|
||||
save_string (section, buffer,
|
||||
panel->user_status_format [i], profile_name);
|
||||
buffer = g_strdup_printf("user_status%d", i);
|
||||
mc_config_set_string(mc_panels_config, section, buffer, panel->user_status_format [i]);
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", panel->user_mini_status);
|
||||
save_string (section, "user_mini_status", buffer,
|
||||
profile_name);
|
||||
mc_config_set_int(mc_panels_config, section, "user_mini_status", panel->user_mini_status);
|
||||
mc_config_save_file (mc_panels_config);
|
||||
}
|
||||
|
||||
void
|
||||
@ -291,15 +283,14 @@ save_layout (void)
|
||||
{
|
||||
char *profile;
|
||||
int i;
|
||||
char buffer [BUF_TINY];
|
||||
|
||||
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
|
||||
|
||||
/* Save integer options */
|
||||
for (i = 0; layout [i].opt_name; i++){
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", *layout [i].opt_addr);
|
||||
save_string ("Layout", layout [i].opt_name, buffer, profile);
|
||||
mc_config_set_int(mc_main_config, "Layout", layout [i].opt_name, *layout [i].opt_addr);
|
||||
}
|
||||
mc_config_save_to_file (mc_main_config, profile);
|
||||
|
||||
g_free (profile);
|
||||
}
|
||||
@ -314,13 +305,13 @@ save_configure (void)
|
||||
|
||||
/* Save integer options */
|
||||
for (i = 0; int_options[i].opt_name; i++)
|
||||
set_int (profile, int_options[i].opt_name, *int_options[i].opt_addr);
|
||||
mc_config_set_int(mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name, *int_options[i].opt_addr);
|
||||
|
||||
/* Save string options */
|
||||
for (i = 0; str_options[i].opt_name != NULL; i++)
|
||||
set_config_string (profile, str_options[i].opt_name,
|
||||
*str_options[i].opt_addr);
|
||||
mc_config_set_string(mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, *str_options[i].opt_addr);
|
||||
|
||||
mc_config_save_to_file (mc_main_config, profile);
|
||||
g_free (profile);
|
||||
}
|
||||
|
||||
@ -331,8 +322,8 @@ panel_save_type (const char *section, int type)
|
||||
|
||||
for (i = 0; panel_types [i].opt_name; i++)
|
||||
if (panel_types [i].opt_type == type){
|
||||
save_string (section, "display", panel_types [i].opt_name,
|
||||
profile_name);
|
||||
mc_config_set_string(mc_panels_config, section,
|
||||
"display", panel_types [i].opt_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -350,25 +341,29 @@ save_panel_types (void)
|
||||
panel_save_type ("New Right Panel", type);
|
||||
if (type == view_listing)
|
||||
panel_save_setup (right_panel, right_panel->panel_name);
|
||||
|
||||
mc_config_set_string(mc_panels_config, "Dirs" , "other_dir",
|
||||
get_other_type () == view_listing
|
||||
? other_panel->cwd : ".");
|
||||
|
||||
if (current_panel != NULL)
|
||||
mc_config_set_string(mc_panels_config, "Dirs" , "current_is_left",
|
||||
get_current_index () == 0 ? "1" : "0");
|
||||
|
||||
mc_config_save_file (mc_panels_config);
|
||||
}
|
||||
|
||||
void
|
||||
save_setup (void)
|
||||
{
|
||||
char *profile;
|
||||
char *tmp_profile;
|
||||
|
||||
saving_setup = 1;
|
||||
profile = concat_dir_and_file (home_dir, PROFILE_NAME);
|
||||
|
||||
save_configure ();
|
||||
|
||||
save_layout ();
|
||||
save_string ("Dirs", "other_dir",
|
||||
get_other_type () == view_listing
|
||||
? other_panel->cwd : ".", profile);
|
||||
if (current_panel != NULL)
|
||||
WritePrivateProfileString ("Dirs", "current_is_left",
|
||||
get_current_index () == 0 ? "1" : "0", profile);
|
||||
|
||||
save_hotlist ();
|
||||
|
||||
save_panelize ();
|
||||
@ -376,21 +371,22 @@ save_setup (void)
|
||||
/* directory_history_save (); */
|
||||
|
||||
#if defined(USE_VFS) && defined (USE_NETCODE)
|
||||
WritePrivateProfileString ("Misc", "ftpfs_password",
|
||||
ftpfs_anonymous_passwd, profile);
|
||||
mc_config_set_string(mc_main_config, "Misc" , "ftpfs_password",
|
||||
ftpfs_anonymous_passwd);
|
||||
if (ftpfs_proxy_host)
|
||||
WritePrivateProfileString ("Misc", "ftp_proxy_host",
|
||||
ftpfs_proxy_host, profile);
|
||||
mc_config_set_string(mc_main_config, "Misc" , "ftp_proxy_host",
|
||||
ftpfs_proxy_host);
|
||||
#endif /* USE_VFS && USE_NETCODE */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
save_string( "Misc", "display_codepage",
|
||||
get_codepage_id( display_codepage ), profile_name );
|
||||
save_string( "Misc", "source_codepage",
|
||||
get_codepage_id( source_codepage ), profile_name );
|
||||
mc_config_set_string(mc_main_config, "Misc" , "display_codepage",
|
||||
get_codepage_id( display_codepage ));
|
||||
mc_config_set_string(mc_main_config, "Misc" , "source_codepage",
|
||||
get_codepage_id( source_codepage ));
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
g_free (profile);
|
||||
tmp_profile = concat_dir_and_file (home_dir, PROFILE_NAME);
|
||||
mc_config_save_to_file (mc_main_config, tmp_profile);
|
||||
g_free (tmp_profile);
|
||||
saving_setup = 0;
|
||||
}
|
||||
|
||||
@ -398,94 +394,79 @@ void
|
||||
panel_load_setup (WPanel *panel, const char *section)
|
||||
{
|
||||
int i;
|
||||
char buffer [BUF_TINY];
|
||||
char *buffer;
|
||||
|
||||
panel->reverse = load_int (section, "reverse", 0);
|
||||
panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
|
||||
panel->exec_first = load_int (section, "exec_first", 0);
|
||||
panel->reverse = mc_config_get_int(mc_panels_config, section, "reverse", 0);
|
||||
panel->case_sensitive = mc_config_get_int(mc_panels_config, section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
|
||||
panel->exec_first = mc_config_get_int(mc_panels_config, section, "exec_first", 0);
|
||||
|
||||
/* Load sort order */
|
||||
load_string (section, "sort_order", "name", buffer, sizeof (buffer));
|
||||
buffer = mc_config_get_string(mc_panels_config, section, "sort_order", "name");
|
||||
|
||||
panel->sort_type = (sortfn *) sort_name;
|
||||
for (i = 0; sort_names [i].key; i++)
|
||||
if ( g_strcasecmp (sort_names [i].key, buffer) == 0){
|
||||
panel->sort_type = sort_names [i].sort_type;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free(buffer);
|
||||
/* Load the listing mode */
|
||||
load_string (section, "list_mode", "full", buffer, sizeof (buffer));
|
||||
buffer = mc_config_get_string(mc_panels_config, section, "list_mode", "full");
|
||||
panel->list_type = list_full;
|
||||
for (i = 0; list_types [i].key; i++)
|
||||
if ( g_strcasecmp (list_types [i].key, buffer) == 0){
|
||||
panel->list_type = list_types [i].list_type;
|
||||
break;
|
||||
}
|
||||
g_free(buffer);
|
||||
|
||||
/* User formats */
|
||||
g_free (panel->user_format);
|
||||
panel->user_format = g_strdup (get_profile_string (section, "user_format",
|
||||
DEFAULT_USER_FORMAT,
|
||||
profile_name));
|
||||
panel->user_format = mc_config_get_string(mc_panels_config, section, "user_format", DEFAULT_USER_FORMAT);
|
||||
|
||||
for (i = 0; i < LIST_TYPES; i++){
|
||||
g_free (panel->user_status_format [i]);
|
||||
g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
|
||||
buffer = g_strdup_printf("user_status%d",i);
|
||||
panel->user_status_format [i] =
|
||||
g_strdup (get_profile_string (section, buffer,
|
||||
DEFAULT_USER_FORMAT, profile_name));
|
||||
mc_config_get_string(mc_panels_config, section, buffer, DEFAULT_USER_FORMAT);
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
panel->user_mini_status =
|
||||
load_int (section, "user_mini_status", 0);
|
||||
mc_config_get_int(mc_panels_config, section, "user_mini_status", 0);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
load_layout (char *profile_name)
|
||||
load_layout ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; layout [i].opt_name; i++)
|
||||
*layout [i].opt_addr =
|
||||
load_int ("Layout", layout [i].opt_name,
|
||||
*layout [i].opt_addr);
|
||||
mc_config_get_int(mc_main_config,"Layout", layout [i].opt_name, *layout [i].opt_addr);
|
||||
}
|
||||
|
||||
static int
|
||||
load_mode (const char *section)
|
||||
setup__load_panel_state (const char *section)
|
||||
{
|
||||
char buffer [20];
|
||||
char *buffer;
|
||||
int i;
|
||||
|
||||
int mode = view_listing;
|
||||
|
||||
/* Load the display mode */
|
||||
load_string (section, "display", "listing", buffer, sizeof (buffer));
|
||||
buffer = mc_config_get_string(mc_panels_config, section, "display", "listing");
|
||||
|
||||
for (i = 0; panel_types [i].opt_name; i++)
|
||||
if ( g_strcasecmp (panel_types [i].opt_name, buffer) == 0){
|
||||
mode = panel_types [i].opt_type;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free(buffer);
|
||||
return mode;
|
||||
}
|
||||
|
||||
#ifdef USE_NETCODE
|
||||
static char *
|
||||
do_load_string (const char *s, const char *ss, const char *def)
|
||||
{
|
||||
char *buffer = g_malloc (BUF_SMALL);
|
||||
char *p;
|
||||
|
||||
load_string (s, ss, def, buffer, BUF_SMALL);
|
||||
|
||||
p = g_strdup (buffer);
|
||||
g_free (buffer);
|
||||
return p;
|
||||
}
|
||||
#endif /* !USE_NETCODE */
|
||||
|
||||
char *
|
||||
setup_init (void)
|
||||
{
|
||||
@ -522,6 +503,7 @@ load_setup (void)
|
||||
{
|
||||
char *profile;
|
||||
int i;
|
||||
char *buffer;
|
||||
|
||||
profile = setup_init ();
|
||||
|
||||
@ -533,34 +515,34 @@ load_setup (void)
|
||||
g_free (global_profile_name);
|
||||
global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib");
|
||||
}
|
||||
panels_profile_name = concat_dir_and_file (home_dir, PANELS_PROFILE_NAME);
|
||||
|
||||
mc_main_config = mc_config_init(profile);
|
||||
mc_panels_config = mc_config_init(panels_profile_name);
|
||||
|
||||
/* Load integer boolean options */
|
||||
for (i = 0; int_options[i].opt_name; i++)
|
||||
*int_options[i].opt_addr =
|
||||
get_int (profile, int_options[i].opt_name, *int_options[i].opt_addr);
|
||||
mc_config_get_int(mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name, *int_options[i].opt_addr);
|
||||
|
||||
/* Load string options */
|
||||
for (i = 0; str_options[i].opt_name != NULL; i++)
|
||||
*str_options[i].opt_addr = get_config_string (profile,
|
||||
str_options[i].opt_name, str_options[i].opt_defval);
|
||||
*str_options[i].opt_addr =
|
||||
mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, str_options[i].opt_defval);
|
||||
|
||||
load_layout (profile);
|
||||
load_layout ();
|
||||
|
||||
load_panelize ();
|
||||
|
||||
startup_left_mode = load_mode ("New Left Panel");
|
||||
startup_right_mode = load_mode ("New Right Panel");
|
||||
startup_left_mode = setup__load_panel_state ("New Left Panel");
|
||||
startup_right_mode = setup__load_panel_state ("New Right Panel");
|
||||
|
||||
/* At least one of the panels is a listing panel */
|
||||
if (startup_left_mode != view_listing && startup_right_mode!=view_listing)
|
||||
startup_left_mode = view_listing;
|
||||
|
||||
if (!other_dir){
|
||||
char *buffer;
|
||||
|
||||
buffer = (char*) g_malloc (MC_MAXPATHLEN);
|
||||
load_string ("Dirs", "other_dir", ".", buffer,
|
||||
MC_MAXPATHLEN);
|
||||
buffer = mc_config_get_string(mc_panels_config, "Dirs", "other_dir", ".");
|
||||
if (vfs_file_is_local (buffer))
|
||||
other_dir = buffer;
|
||||
else
|
||||
@ -568,51 +550,46 @@ load_setup (void)
|
||||
}
|
||||
|
||||
boot_current_is_left =
|
||||
GetPrivateProfileInt ("Dirs", "current_is_left", 1, profile);
|
||||
mc_config_get_int(mc_panels_config, "Dirs", "current_is_left", 1);
|
||||
|
||||
#ifdef USE_NETCODE
|
||||
ftpfs_proxy_host = do_load_string ("Misc", "ftp_proxy_host", "gate");
|
||||
ftpfs_proxy_host = mc_config_get_string(mc_main_config, "Misc", "ftp_proxy_host", "gate");
|
||||
#endif
|
||||
|
||||
load_string ("Misc", "find_ignore_dirs", "", setup_color_string,
|
||||
sizeof (setup_color_string));
|
||||
setup_color_string = mc_config_get_string(mc_main_config, "Misc", "find_ignore_dirs", "");
|
||||
if (setup_color_string [0])
|
||||
find_ignore_dirs = g_strconcat (":", setup_color_string, ":", (char *) NULL);
|
||||
g_free(setup_color_string);
|
||||
|
||||
/* The default color and the terminal dependent color */
|
||||
load_string ("Colors", "base_color", "", setup_color_string,
|
||||
sizeof (setup_color_string));
|
||||
load_string ("Colors", getenv ("TERM"), "",
|
||||
term_color_string, sizeof (term_color_string));
|
||||
load_string ("Colors", "color_terminals", "",
|
||||
color_terminal_string, sizeof (color_terminal_string));
|
||||
setup_color_string = mc_config_get_string(mc_main_config, "Colors", "base_color", "");
|
||||
term_color_string = mc_config_get_string(mc_main_config, "Colors", getenv ("TERM"), "");
|
||||
color_terminal_string = mc_config_get_string(mc_main_config, "Colors", "color_terminals", "");
|
||||
|
||||
/* Load the directory history */
|
||||
/* directory_history_load (); */
|
||||
/* Remove the temporal entries */
|
||||
profile_clean_section ("Temporal:New Left Panel", profile_name);
|
||||
profile_clean_section ("Temporal:New Right Panel", profile_name);
|
||||
mc_config_del_group (mc_panels_config, "Temporal:New Left Panel");
|
||||
mc_config_del_group (mc_panels_config, "Temporal:New Right Panel");
|
||||
#if defined(USE_VFS) && defined (USE_NETCODE)
|
||||
ftpfs_init_passwd ();
|
||||
#endif /* USE_VFS && USE_NETCODE */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if ( load_codepages_list() > 0 ) {
|
||||
char cpname[128];
|
||||
load_string( "Misc", "display_codepage", "",
|
||||
cpname, sizeof(cpname) );
|
||||
if ( cpname[0] != '\0' )
|
||||
buffer = mc_config_get_string(mc_main_config, "Misc", "display_codepage", "");
|
||||
if ( buffer[0] != '\0' )
|
||||
{
|
||||
display_codepage = get_codepage_index( cpname );
|
||||
display_codepage = get_codepage_index( buffer );
|
||||
cp_display = get_codepage_id (display_codepage);
|
||||
}
|
||||
load_string( "Misc", "source_codepage", "",
|
||||
cpname, sizeof(cpname) );
|
||||
if ( cpname[0] != '\0' )
|
||||
g_free(buffer);
|
||||
buffer = mc_config_get_string(mc_main_config, "Misc", "source_codepage", "");
|
||||
if ( buffer[0] != '\0' )
|
||||
{
|
||||
source_codepage = get_codepage_index( cpname );
|
||||
source_codepage = get_codepage_index( buffer );
|
||||
cp_source = get_codepage_id (source_codepage);
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
init_translation_table( source_codepage, display_codepage );
|
||||
if ( get_codepage_id( display_codepage ) )
|
||||
@ -624,13 +601,14 @@ load_setup (void)
|
||||
char *
|
||||
load_anon_passwd ()
|
||||
{
|
||||
char buffer [255];
|
||||
char *buffer;
|
||||
|
||||
load_string ("Misc", "ftpfs_password", "", buffer, sizeof (buffer));
|
||||
buffer = mc_config_get_string(mc_main_config, "Misc", "ftpfs_password", "");
|
||||
if (buffer [0])
|
||||
return g_strdup (buffer);
|
||||
else
|
||||
return 0;
|
||||
return buffer;
|
||||
|
||||
g_free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
#endif /* USE_VFS && USE_NETCODE */
|
||||
|
||||
@ -638,41 +616,67 @@ void done_setup (void)
|
||||
{
|
||||
g_free (profile_name);
|
||||
g_free (global_profile_name);
|
||||
g_free(color_terminal_string);
|
||||
g_free(term_color_string);
|
||||
g_free(setup_color_string);
|
||||
mc_config_deinit(mc_main_config);
|
||||
mc_config_deinit(mc_panels_config);
|
||||
done_hotlist ();
|
||||
done_panelize ();
|
||||
/* directory_history_free (); */
|
||||
}
|
||||
|
||||
static void
|
||||
load_keys_from_section (const char *terminal, const char *profile_name)
|
||||
load_keys_from_section (const char *terminal, mc_config_t *cfg)
|
||||
{
|
||||
char *section_name;
|
||||
void *profile_keys;
|
||||
char *key, *value, *valcopy;
|
||||
gchar **profile_keys, **keys;
|
||||
gchar **values, **curr_values;
|
||||
char *valcopy, *value;
|
||||
int key_code;
|
||||
gsize len, values_len;
|
||||
|
||||
if (!terminal)
|
||||
return;
|
||||
|
||||
section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
|
||||
profile_keys = profile_init_iterator (section_name, profile_name);
|
||||
g_free (section_name);
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);
|
||||
|
||||
while (*profile_keys){
|
||||
|
||||
/* copy=other causes all keys from [terminal:other] to be loaded. */
|
||||
if (g_strcasecmp (key, "copy") == 0) {
|
||||
load_keys_from_section (value, profile_name);
|
||||
if (g_strcasecmp (*profile_keys, "copy") == 0) {
|
||||
valcopy = mc_config_get_string (cfg, section_name, *profile_keys, "");
|
||||
load_keys_from_section (valcopy, cfg);
|
||||
g_free(valcopy);
|
||||
profile_keys++;
|
||||
continue;
|
||||
}
|
||||
curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
|
||||
|
||||
key_code = lookup_key (key);
|
||||
key_code = lookup_key (*profile_keys);
|
||||
if (key_code){
|
||||
valcopy = convert_controls (value);
|
||||
define_sequence (key_code, valcopy, MCKEY_NOACTION);
|
||||
g_free (valcopy);
|
||||
if (curr_values){
|
||||
while (*curr_values){
|
||||
valcopy = convert_controls (*curr_values);
|
||||
define_sequence (key_code, valcopy, MCKEY_NOACTION);
|
||||
g_free (valcopy);
|
||||
curr_values++;
|
||||
}
|
||||
} else {
|
||||
value = mc_config_get_string (cfg, section_name, *profile_keys, "");
|
||||
valcopy = convert_controls (value);
|
||||
define_sequence (key_code, valcopy, MCKEY_NOACTION);
|
||||
g_free (valcopy);
|
||||
g_free(value);
|
||||
}
|
||||
}
|
||||
profile_keys++;
|
||||
if (values)
|
||||
g_strfreev(values);
|
||||
}
|
||||
g_strfreev(keys);
|
||||
g_free (section_name);
|
||||
}
|
||||
|
||||
void load_key_defs (void)
|
||||
@ -681,11 +685,16 @@ void load_key_defs (void)
|
||||
* Load keys from mc.lib before ~/.mc/ini, so that the user
|
||||
* definitions override global settings.
|
||||
*/
|
||||
load_keys_from_section ("general", global_profile_name);
|
||||
load_keys_from_section (getenv ("TERM"), global_profile_name);
|
||||
load_keys_from_section ("general", profile_name);
|
||||
load_keys_from_section (getenv ("TERM"), profile_name);
|
||||
mc_config_t *mc_global_config;
|
||||
|
||||
mc_global_config = mc_config_init(global_profile_name);
|
||||
if (mc_global_config != NULL)
|
||||
{
|
||||
load_keys_from_section ("general", mc_global_config);
|
||||
load_keys_from_section (getenv ("TERM"), mc_global_config);
|
||||
mc_config_deinit(mc_global_config);
|
||||
}
|
||||
load_keys_from_section ("general", mc_main_config);
|
||||
load_keys_from_section (getenv ("TERM"), mc_main_config);
|
||||
|
||||
/* We don't want a huge database loaded in core */
|
||||
free_profile_name (global_profile_name);
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ void panel_load_setup (struct WPanel *panel, const char *section);
|
||||
extern char *profile_name;
|
||||
extern char *global_profile_name;
|
||||
|
||||
extern char setup_color_string[];
|
||||
extern char term_color_string[];
|
||||
extern char color_terminal_string[];
|
||||
extern char *setup_color_string;
|
||||
extern char *term_color_string;
|
||||
extern char *color_terminal_string;
|
||||
|
||||
extern int startup_left_mode;
|
||||
extern int startup_right_mode;
|
||||
@ -35,5 +35,6 @@ extern int mouse_close_dialog;
|
||||
|
||||
#define PROFILE_NAME ".mc/ini"
|
||||
#define HOTLIST_FILENAME ".mc/hotlist"
|
||||
#define PANELS_PROFILE_NAME ".mc/panels.ini"
|
||||
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Contains a storage of the file system tree representation
|
||||
*
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written: 1994, 1996 Janne Kukonlehto
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "treestore.h"
|
||||
#include "profile.h"
|
||||
#include "../src/mcconfig/mcconfig.h"
|
||||
#include "setup.h"
|
||||
|
||||
#define TREE_SIGNATURE "Midnight Commander TreeStore v 2.0"
|
||||
@ -729,17 +729,22 @@ static void
|
||||
process_special_dirs(GList ** special_dirs, char *file)
|
||||
{
|
||||
char *token;
|
||||
char *buffer = g_malloc(4096);
|
||||
char *buffer;
|
||||
char *s;
|
||||
mc_config_t *cfg;
|
||||
|
||||
GetPrivateProfileString("Special dirs", "list",
|
||||
"", buffer, 4096, file);
|
||||
cfg = mc_config_init(file);
|
||||
if (cfg == NULL)
|
||||
return;
|
||||
|
||||
buffer = mc_config_get_string(cfg, "Special dirs", "list", "");
|
||||
s = buffer;
|
||||
while ((token = strtok(s, ",")) != NULL) {
|
||||
*special_dirs = g_list_prepend(*special_dirs, g_strdup(token));
|
||||
s = NULL;
|
||||
}
|
||||
g_free(buffer);
|
||||
mc_config_deinit(cfg);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
33
src/util.c
33
src/util.c
@ -1,6 +1,6 @@
|
||||
/* Various utilities
|
||||
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2007 Free Software Foundation, Inc.
|
||||
2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||
Written 1994, 1995, 1996 by:
|
||||
Miguel de Icaza, Janne Kukonlehto, Dugan Porter,
|
||||
Jakub Jelinek, Mauricio Plaza.
|
||||
@ -39,7 +39,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "profile.h"
|
||||
#include "main.h" /* mc_home */
|
||||
#include "cmd.h" /* guess_message_value */
|
||||
#include "mountlist.h"
|
||||
@ -52,7 +51,6 @@
|
||||
#include "charsets.h"
|
||||
#endif
|
||||
|
||||
static const char app_text [] = "Midnight-Commander";
|
||||
int easy_patterns = 1;
|
||||
|
||||
extern void str_replace(char *s, char from, char to)
|
||||
@ -497,35 +495,6 @@ extension (const char *filename)
|
||||
return (d != NULL) ? d + 1 : "";
|
||||
}
|
||||
|
||||
int
|
||||
get_int (const char *file, const char *key, int def)
|
||||
{
|
||||
return GetPrivateProfileInt (app_text, key, def, file);
|
||||
}
|
||||
|
||||
int
|
||||
set_int (const char *file, const char *key, int value)
|
||||
{
|
||||
char buffer [BUF_TINY];
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%d", value);
|
||||
return WritePrivateProfileString (app_text, key, buffer, file);
|
||||
}
|
||||
|
||||
extern char *
|
||||
get_config_string (const char *file, const char *key, const char *defval)
|
||||
{
|
||||
char buffer[1024];
|
||||
(void)GetPrivateProfileString (app_text, key, defval, buffer, sizeof(buffer), file);
|
||||
return g_strdup (buffer);
|
||||
}
|
||||
|
||||
extern void
|
||||
set_config_string (const char *file, const char *key, const char *val)
|
||||
{
|
||||
(void)WritePrivateProfileString (app_text, key, val, file);
|
||||
}
|
||||
|
||||
int
|
||||
exist_file (const char *name)
|
||||
{
|
||||
|
@ -92,12 +92,6 @@ char *diff_two_paths (const char *first, const char *second);
|
||||
/* Returns the basename of fname. The result is a pointer into fname. */
|
||||
const char *x_basename (const char *fname);
|
||||
|
||||
/* Profile managing functions */
|
||||
int set_int (const char *, const char *, int);
|
||||
int get_int (const char *, const char *, int);
|
||||
extern char * get_config_string (const char *, const char *, const char *);
|
||||
extern void set_config_string (const char *, const char *, const char *);
|
||||
|
||||
char *load_file (const char *filename);
|
||||
char *load_mc_home_file (const char *filename, char ** allocated_filename);
|
||||
|
||||
|
27
src/widget.c
27
src/widget.c
@ -1,7 +1,7 @@
|
||||
/* Widgets for the Midnight Commander
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Authors: 1994, 1995 Radek Doulik
|
||||
1994, 1995 Miguel de Icaza
|
||||
@ -46,7 +46,7 @@
|
||||
#include "widget.h"
|
||||
#include "win.h"
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
#include "profile.h" /* for history loading and saving */
|
||||
#include "../src/mcconfig/mcconfig.h" /* for history loading and saving */
|
||||
#include "wtools.h" /* For common_dialog_repaint() */
|
||||
#include "main.h" /* for `slow_terminal' */
|
||||
#include "strutil.h"
|
||||
@ -892,6 +892,8 @@ history_get (const char *input_name)
|
||||
int i;
|
||||
GList *hist;
|
||||
char *profile;
|
||||
mc_config_t *cfg;
|
||||
char *this_entry;
|
||||
|
||||
hist = NULL;
|
||||
|
||||
@ -902,17 +904,19 @@ history_get (const char *input_name)
|
||||
if (!*input_name)
|
||||
return NULL;
|
||||
profile = concat_dir_and_file (home_dir, HISTORY_FILE_NAME);
|
||||
cfg = mc_config_init(profile);
|
||||
for (i = 0;; i++) {
|
||||
char key_name[BUF_TINY];
|
||||
char this_entry[BUF_LARGE];
|
||||
g_snprintf (key_name, sizeof (key_name), "%d", i);
|
||||
GetPrivateProfileString (input_name, key_name, "", this_entry,
|
||||
sizeof (this_entry), profile);
|
||||
if (!*this_entry)
|
||||
this_entry = mc_config_get_string(cfg, input_name, key_name, "");
|
||||
if (!*this_entry){
|
||||
g_free(this_entry);
|
||||
break;
|
||||
}
|
||||
|
||||
hist = list_append_unique (hist, g_strdup (this_entry));
|
||||
hist = list_append_unique (hist, this_entry);
|
||||
}
|
||||
mc_config_deinit(cfg);
|
||||
g_free (profile);
|
||||
|
||||
/* return pointer to the last entry in the list */
|
||||
@ -926,6 +930,7 @@ history_put (const char *input_name, GList *h)
|
||||
{
|
||||
int i;
|
||||
char *profile;
|
||||
mc_config_t *cfg;
|
||||
|
||||
if (!input_name)
|
||||
return;
|
||||
@ -957,8 +962,10 @@ history_put (const char *input_name, GList *h)
|
||||
for (i = 0; i < num_history_items_recorded - 1 && h->prev; i++)
|
||||
h = g_list_previous (h);
|
||||
|
||||
cfg = mc_config_init(profile);
|
||||
|
||||
if (input_name)
|
||||
profile_clean_section (input_name, profile);
|
||||
mc_config_del_group(cfg,input_name);
|
||||
|
||||
/* dump histories into profile */
|
||||
for (i = 0; h; h = g_list_next (h)) {
|
||||
@ -970,11 +977,11 @@ history_put (const char *input_name, GList *h)
|
||||
if (text && *text) {
|
||||
char key_name[BUF_TINY];
|
||||
g_snprintf (key_name, sizeof (key_name), "%d", i++);
|
||||
WritePrivateProfileString (input_name, key_name, text,
|
||||
profile);
|
||||
mc_config_set_string(cfg,input_name, key_name, text);
|
||||
}
|
||||
}
|
||||
|
||||
mc_config_deinit(cfg);
|
||||
g_free (profile);
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user