1 /* Configure module for the Midnight Commander
2 Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3 2007, 2009 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "lib/global.h"
23 #include "lib/strutil.h"
24 #include "lib/mcconfig.h"
26 /*** global variables **************************************************/
28 extern int utf8_display
;
30 /*** file scope macro definitions **************************************/
32 /*** file scope type declarations **************************************/
34 /*** file scope variables **********************************************/
36 /*** file scope functions **********************************************/
37 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
40 mc_config_normalize_before_save (const gchar
* value
)
46 return g_strdup (value
);
48 conv
= str_crt_conv_to ("UTF-8");
49 if (conv
== INVALID_CONV
)
50 return g_strdup (value
);
52 buffer
= g_string_new ("");
54 if (str_convert (conv
, value
, buffer
) == ESTR_FAILURE
)
56 g_string_free (buffer
, TRUE
);
57 return g_strdup (value
);
60 str_close_conv (conv
);
61 return g_string_free (buffer
, FALSE
);
64 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
65 /*** public functions **************************************************/
66 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
69 mc_config_set_string_raw (mc_config_t
* mc_config
, const gchar
* group
,
70 const gchar
* param
, const gchar
* value
)
72 if (!mc_config
|| !group
|| !param
|| !value
)
75 g_key_file_set_string (mc_config
->handle
, group
, param
, value
);
78 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
81 mc_config_set_string (mc_config_t
* mc_config
, const gchar
* group
,
82 const gchar
* param
, const gchar
* value
)
86 if (!mc_config
|| !group
|| !param
|| !value
)
89 buffer
= mc_config_normalize_before_save (value
);
91 g_key_file_set_string (mc_config
->handle
, group
, param
, buffer
);
96 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
99 mc_config_set_bool (mc_config_t
* mc_config
, const gchar
* group
,
100 const gchar
* param
, gboolean value
)
102 if (!mc_config
|| !group
|| !param
)
105 g_key_file_set_boolean (mc_config
->handle
, group
, param
, value
);
108 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
111 mc_config_set_int (mc_config_t
* mc_config
, const gchar
* group
, const gchar
* param
, int value
)
113 if (!mc_config
|| !group
|| !param
)
116 g_key_file_set_integer (mc_config
->handle
, group
, param
, value
);
119 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
120 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
123 mc_config_set_string_list (mc_config_t
* mc_config
, const gchar
* group
,
124 const gchar
* param
, const gchar
* const value
[], gsize length
)
126 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
129 g_key_file_set_string_list (mc_config
->handle
, group
, param
, value
, length
);
132 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
136 mc_config_set_bool_list (mc_config_t
* mc_config
, const gchar
* group
,
137 const gchar
* param
, gboolean value
[], gsize length
)
139 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
142 g_key_file_set_boolean_list (mc_config
->handle
, group
, param
, value
, length
);
145 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
148 mc_config_set_int_list (mc_config_t
* mc_config
, const gchar
* group
,
149 const gchar
* param
, int value
[], gsize length
)
151 if (!mc_config
|| !group
|| !param
|| !value
|| length
== 0)
154 g_key_file_set_integer_list (mc_config
->handle
, group
, param
, value
, length
);
157 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */