utf8-encoded.
Previously, non-utf8 strings from rc file caused some issues.
*-----------------------------------------------------------------------------
*/
+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));
}
}
*/
typedef gint (*EditorCallback) (gpointer ed, gint flags, GList *list, gpointer data);
+void editor_set_name(gint n, gchar *name);
+void editor_set_command(gint n, gchar *command);
void editor_resume(gpointer ed);
for (i = 0; i < GQ_EDITOR_SLOTS; i++)
{
- options->editor[i].name = NULL;
- options->editor[i].command = NULL;
+ editor_set_name(i, NULL);
+ editor_set_command(i, NULL);
}
editor_reset_defaults();
for (i = 0; i < GQ_EDITOR_SLOTS; i++)
{
+ gchar *command = NULL;
+
if (i < GQ_EDITOR_GENERIC_SLOTS)
{
- g_free(options->editor[i].name);
- options->editor[i].name = NULL;
+ gchar *name = NULL;
+
buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i]));
- if (buf && strlen(buf) > 0) options->editor[i].name = g_strdup(buf);
+ if (buf && strlen(buf) > 0) name = g_strdup(buf);
+ editor_set_name(i, name);
+ g_free(name);
}
- g_free(options->editor[i].command);
- options->editor[i].command = NULL;
buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i]));
if (buf && strlen(buf) > 0)
{
i+1, options->editor[i].name, buf);
}
- options->editor[i].command = g_strdup(buf);
+ command = g_strdup(buf);
}
+
+ editor_set_command(i, command);
+ g_free(command);
}
if (errmsg->str[0])
#include "rcfile.h"
#include "bar_exif.h"
+#include "editors.h"
#include "filefilter.h"
#include "secure_save.h"
#include "slideshow.h"
if (i > 0 && i <= GQ_EDITOR_SLOTS)
{
const gchar *ptr;
- i--;
- g_free(options->editor[i].name);
- g_free(options->editor[i].command);
- options->editor[i].name = quoted_value(value_all, &ptr);
- options->editor[i].command = quoted_value(ptr, NULL);
+ i--;
+ editor_set_name(i, quoted_value(value_all, &ptr));
+ editor_set_command(i, quoted_value(ptr, NULL));
}
continue;
}