2 Configure module for the Midnight Commander
4 Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 The Free Software Foundation, Inc.
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software: you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation, either version 3 of the License,
13 or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "lib/global.h"
27 #include "lib/strutil.h"
28 #include "lib/mcconfig.h"
30 /*** global variables **************************************************/
32 /*** file scope macro definitions **************************************/
34 /*** file scope type declarations **************************************/
36 /*** file scope variables **********************************************/
38 /*** file scope functions **********************************************/
39 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
42 mc_config_normalize_before_save (const gchar
* value
)
47 if (mc_global
.utf8_display
)
48 return g_strdup (value
);
50 conv
= str_crt_conv_to ("UTF-8");
51 if (conv
== INVALID_CONV
)
52 return g_strdup (value
);
54 buffer
= g_string_new ("");
56 if (str_convert (conv
, value
, buffer
) == ESTR_FAILURE
)
58 g_string_free (buffer
, TRUE
);
59 return g_strdup (value
);
62 str_close_conv (conv
);
63 return g_string_free (buffer
, FALSE
);
66 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
67 /*** public functions **************************************************/
68 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
71 mc_config_set_string_raw (mc_config_t
* mc_config
, const gchar
* group
,
72 const gchar
* param
, const gchar
* value
)
74 if (!mc_config
|| !group
|| !param
|| !value
)
77 g_key_file_set_string (mc_config
->handle
, group
, param
, value
);
80 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
83 mc_config_set_string (const mc_config_t
* mc_config
, const gchar
* group
,
84 const gchar
* param
, const gchar
* value
)
88 if (!mc_config
|| !group
|| !param
|| !value
)
91 buffer
= mc_config_normalize_before_save (value
);
93 g_key_file_set_string (mc_config
->handle
, group
, param
, buffer
);
98 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
101 mc_config_set_bool (mc_config_t
* mc_config
, const gchar
* group
,
102 const gchar
* param
, gboolean value
)
104 if (!mc_config
|| !group
|| !param
)
107 g_key_file_set_boolean (mc_config
->handle
, group
, param
, value
);
110 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
113 mc_config_set_int (mc_config_t
* mc_config
, const gchar
* group
, const gchar
* param
, int value
)
115 if (!mc_config
|| !group
|| !param
)
118 g_key_file_set_integer (mc_config
->handle
, group
, param
, value
);
121 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
122 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
125 mc_config_set_string_list (mc_config_t
* mc_config
, const gchar
* group
,
126 const gchar
* param
, const gchar
* const value
[], gsize length
)
128 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
131 g_key_file_set_string_list (mc_config
->handle
, group
, param
, value
, length
);
134 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
138 mc_config_set_bool_list (mc_config_t
* mc_config
, const gchar
* group
,
139 const gchar
* param
, gboolean value
[], gsize length
)
141 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
144 g_key_file_set_boolean_list (mc_config
->handle
, group
, param
, value
, length
);
147 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
150 mc_config_set_int_list (mc_config_t
* mc_config
, const gchar
* group
,
151 const gchar
* param
, int value
[], gsize length
)
153 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
156 g_key_file_set_integer_list (mc_config
->handle
, group
, param
, value
, length
);
159 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */