diff src/editors.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 7148e125bf23
children 8adf248bf5c9
line wrap: on
line diff
--- a/src/editors.c	Fri May 30 08:36:23 2008 +0000
+++ b/src/editors.c	Fri May 30 08:39:52 2008 +0000
@@ -93,16 +93,31 @@
  *-----------------------------------------------------------------------------
  */
 
+void editor_set_name(gint n, gchar *name)
+{
+	if (n < 0 || n >= GQ_EDITOR_SLOTS) return;
+
+	g_free(options->editor[n].name);
+	
+	options->editor[n].name = name ? utf8_validate_or_convert(name) : NULL;
+}
+
+void editor_set_command(gint n, gchar *command)
+{
+	if (n < 0 || n >= GQ_EDITOR_SLOTS) return;
+
+	g_free(options->editor[n].command);
+	options->editor[n].command = command ? utf8_validate_or_convert(command) : NULL;
+}
+
 void editor_reset_defaults(void)
 {
 	gint i;
 
 	for (i = 0; i < GQ_EDITOR_SLOTS; i++)
 		{
-		g_free(options->editor[i].name);
-		options->editor[i].name = g_strdup(_(editor_slot_defaults[i].name));
-		g_free(options->editor[i].command);
-		options->editor[i].command = g_strdup(editor_slot_defaults[i].command);
+		editor_set_name(i, _(editor_slot_defaults[i].name));
+		editor_set_command(i, _(editor_slot_defaults[i].command));
 		}
 }