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
)
48 if (mc_global
.utf8_display
)
49 return g_strdup (value
);
51 conv
= str_crt_conv_to ("UTF-8");
52 if (conv
== INVALID_CONV
)
53 return g_strdup (value
);
55 buffer
= g_string_new ("");
57 ok
= (str_convert (conv
, value
, buffer
) != ESTR_FAILURE
);
58 str_close_conv (conv
);
62 g_string_free (buffer
, TRUE
);
63 return g_strdup (value
);
66 return g_string_free (buffer
, FALSE
);
69 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
70 /*** public functions **************************************************/
71 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
74 mc_config_set_string_raw (mc_config_t
* mc_config
, const gchar
* group
,
75 const gchar
* param
, const gchar
* value
)
77 if (!mc_config
|| !group
|| !param
|| !value
)
80 g_key_file_set_string (mc_config
->handle
, group
, param
, value
);
83 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
86 mc_config_set_string_raw_value (mc_config_t
* mc_config
, const gchar
* group
,
87 const gchar
* param
, const gchar
* value
)
89 if (!mc_config
|| !group
|| !param
|| !value
)
92 g_key_file_set_value (mc_config
->handle
, group
, param
, value
);
95 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
98 mc_config_set_string (const mc_config_t
* mc_config
, const gchar
* group
,
99 const gchar
* param
, const gchar
* value
)
103 if (!mc_config
|| !group
|| !param
|| !value
)
106 buffer
= mc_config_normalize_before_save (value
);
108 g_key_file_set_string (mc_config
->handle
, group
, param
, buffer
);
113 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
116 mc_config_set_bool (mc_config_t
* mc_config
, const gchar
* group
,
117 const gchar
* param
, gboolean value
)
119 if (!mc_config
|| !group
|| !param
)
122 g_key_file_set_boolean (mc_config
->handle
, group
, param
, value
);
125 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
128 mc_config_set_int (mc_config_t
* mc_config
, const gchar
* group
, const gchar
* param
, int value
)
130 if (!mc_config
|| !group
|| !param
)
133 g_key_file_set_integer (mc_config
->handle
, group
, param
, value
);
136 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
137 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
140 mc_config_set_string_list (mc_config_t
* mc_config
, const gchar
* group
,
141 const gchar
* param
, const gchar
* const value
[], gsize length
)
143 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
146 g_key_file_set_string_list (mc_config
->handle
, group
, param
, value
, length
);
149 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
153 mc_config_set_bool_list (mc_config_t
* mc_config
, const gchar
* group
,
154 const gchar
* param
, gboolean value
[], gsize length
)
156 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
159 g_key_file_set_boolean_list (mc_config
->handle
, group
, param
, value
, length
);
162 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
165 mc_config_set_int_list (mc_config_t
* mc_config
, const gchar
* group
,
166 const gchar
* param
, int value
[], gsize length
)
168 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
171 g_key_file_set_integer_list (mc_config
->handle
, group
, param
, value
, length
);
174 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */