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, const gchar *param, gboolean value)
114 {
115 if (mc_config != NULL && group != NULL && param != NULL)
116 g_key_file_set_boolean (mc_config->handle, group, param, value);
117 }
118
119
120
121 void
122 mc_config_set_int (mc_config_t *mc_config, const gchar *group, const gchar *param, int value)
123 {
124 if (mc_config != NULL && group != NULL && param != NULL)
125 g_key_file_set_integer (mc_config->handle, group, param, value);
126 }
127
128
129
130 void
131 mc_config_set_string_list (mc_config_t *mc_config, const gchar *group,
132 const gchar *param, const gchar *const value[], gsize length)
133 {
134 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
135 g_key_file_set_string_list (mc_config->handle, group, param, value, length);
136 }
137
138
139
140 void
141 mc_config_set_bool_list (mc_config_t *mc_config, const gchar *group,
142 const gchar *param, gboolean value[], gsize length)
143 {
144 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
145 g_key_file_set_boolean_list (mc_config->handle, group, param, value, length);
146 }
147
148
149
150 void
151 mc_config_set_int_list (mc_config_t *mc_config, const gchar *group,
152 const gchar *param, int value[], gsize length)
153 {
154 if (mc_config != NULL && group != NULL && param != NULL && value != NULL && length != 0)
155 g_key_file_set_integer_list (mc_config->handle, group, param, value, length);
156 }
157
158