This source file includes following definitions.
- mc_config_normalize_before_save
- mc_config_set_string_raw
- mc_config_set_string_raw_value
- mc_config_set_string
- mc_config_set_bool
- mc_config_set_int
- mc_config_set_string_list
- mc_config_set_bool_list
- mc_config_set_int_list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <config.h>
24
25 #include "lib/global.h"
26 #include "lib/strutil.h"
27
28 #include "lib/mcconfig.h"
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 static gchar *
45 mc_config_normalize_before_save (const gchar * value)
46 {
47 GIConv conv;
48 GString *buffer;
49 gboolean ok;
50
51 if (mc_global.utf8_display)
52 return g_strdup (value);
53
54 conv = str_crt_conv_to ("UTF-8");
55 if (conv == INVALID_CONV)
56 return g_strdup (value);
57
58 buffer = g_string_new ("");
59
60 ok = (str_convert (conv, value, buffer) != ESTR_FAILURE);
61 str_close_conv (conv);
62
63 if (!ok)
64 {
65 g_string_free (buffer, TRUE);
66 return g_strdup (value);
67 }
68
69 return g_string_free (buffer, FALSE);
70 }
71
72
73
74
75
76 void
77 mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group,
78 const gchar * param, const gchar * value)
79 {
80 if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
81 g_key_file_set_string (mc_config->handle, group, param, value);
82 }
83
84
85
86 void
87 mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
88 const gchar * param, const gchar * value)
89 {
90 if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
91 g_key_file_set_value (mc_config->handle, group, param, value);
92 }
93
94
95
96 void
97 mc_config_set_string (mc_config_t * mc_config, const gchar * group,
98 const gchar * param, const gchar * value)
99 {
100 if (mc_config != NULL && group != NULL && param != NULL && value != NULL)
101 {
102 gchar *buffer;
103
104 buffer = mc_config_normalize_before_save (value);
105 g_key_file_set_string (mc_config->handle, group, param, buffer);
106 g_free (buffer);
107 }
108 }
109
110
111
112 void
113 mc_config_set_bool (mc_config_t * mc_config, const gchar * group,
114 const gchar * param, gboolean value)
115 {
116 if (mc_config != NULL && group != NULL && param != NULL)
117 g_key_file_set_boolean (mc_config->handle, group, param, value);
118 }
119
120
121
122 void
123 mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int value)
124 {
125 if (mc_config != NULL && group != NULL && param != NULL)
126 g_key_file_set_integer (mc_config->handle, group, param, value);
127 }
128
129
130
131 void
132 mc_config_set_string_list (mc_config_t * mc_config, const gchar * group,
133 const gchar * param, const gchar * const value[], gsize length)
134 {
135 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
136 g_key_file_set_string_list (mc_config->handle, group, param, value, length);
137 }
138
139
140
141 void
142 mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group,
143 const gchar * param, gboolean value[], gsize length)
144 {
145 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
146 g_key_file_set_boolean_list (mc_config->handle, group, param, value, length);
147 }
148
149
150
151 void
152 mc_config_set_int_list (mc_config_t * mc_config, const gchar * group,
153 const gchar * param, int value[], gsize length)
154 {
155 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
156 g_key_file_set_integer_list (mc_config->handle, group, param, value, length);
157 }
158
159