comparison src/preferences.c @ 768:ff51413f098d

Use functions to set editors name and command and ensure they are utf8-encoded. Previously, non-utf8 strings from rc file caused some issues.
author zas_
date Fri, 30 May 2008 08:39:52 +0000
parents a7289f9e8d29
children ee33d2ddb661
comparison
equal deleted inserted replaced
767:e73d30e0c896 768:ff51413f098d
159 { 159 {
160 GString *errmsg = g_string_new(""); 160 GString *errmsg = g_string_new("");
161 161
162 for (i = 0; i < GQ_EDITOR_SLOTS; i++) 162 for (i = 0; i < GQ_EDITOR_SLOTS; i++)
163 { 163 {
164 gchar *command = NULL;
165
164 if (i < GQ_EDITOR_GENERIC_SLOTS) 166 if (i < GQ_EDITOR_GENERIC_SLOTS)
165 { 167 {
166 g_free(options->editor[i].name); 168 gchar *name = NULL;
167 options->editor[i].name = NULL; 169
168 buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i])); 170 buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i]));
169 if (buf && strlen(buf) > 0) options->editor[i].name = g_strdup(buf); 171 if (buf && strlen(buf) > 0) name = g_strdup(buf);
172 editor_set_name(i, name);
173 g_free(name);
170 } 174 }
171 175
172 g_free(options->editor[i].command);
173 options->editor[i].command = NULL;
174 buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i])); 176 buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i]));
175 if (buf && strlen(buf) > 0) 177 if (buf && strlen(buf) > 0)
176 { 178 {
177 gint flags = editor_command_parse(buf, NULL, NULL); 179 gint flags = editor_command_parse(buf, NULL, NULL);
178 180
181 if (errmsg->str[0]) g_string_append(errmsg, "\n\n"); 183 if (errmsg->str[0]) g_string_append(errmsg, "\n\n");
182 g_string_append_printf(errmsg, _("%s\n#%d \"%s\":\n%s"), editor_get_error_str(flags), 184 g_string_append_printf(errmsg, _("%s\n#%d \"%s\":\n%s"), editor_get_error_str(flags),
183 i+1, options->editor[i].name, buf); 185 i+1, options->editor[i].name, buf);
184 186
185 } 187 }
186 options->editor[i].command = g_strdup(buf); 188 command = g_strdup(buf);
187 } 189 }
190
191 editor_set_command(i, command);
192 g_free(command);
188 } 193 }
189 194
190 if (errmsg->str[0]) 195 if (errmsg->str[0])
191 { 196 {
192 file_util_warning_dialog(_("Invalid editor command"), errmsg->str, GTK_STOCK_DIALOG_ERROR, NULL); 197 file_util_warning_dialog(_("Invalid editor command"), errmsg->str, GTK_STOCK_DIALOG_ERROR, NULL);