if (!g_utf8_validate(buf, count, NULL))
{
gchar *utf8;
+
utf8 = g_locale_to_utf8(buf, count, NULL, NULL, NULL);
if (utf8)
{
{
while(work)
{
+ GList *work2;
gchar *ext = work->data;
work = work->next;
break;
}
- GList *work2 = fd->sidecar_files;
-
+ work2 = fd->sidecar_files;
while(work2)
{
FileData *sfd = work2->data;
else
p = "";
}
+
while (*p != '\0')
{
/* must escape \, ", `, and $ to avoid problems,
/* for example "%f" or "%{.crw;.raw;.cr2}f" */
if (*p == '{')
{
+ gchar *end;
+
p++;
- gchar *end = strchr(p, '}');
+ end = strchr(p, '}');
if (!end)
{
flags |= EDITOR_ERROR_SYNTAX;
/* use whole list */
GList *work = list;
gboolean ok = FALSE;
+
while (work)
{
FileData *fd = work->data;
if (ed->vd)
{
-
if (!ok)
{
gchar *buf;
}
else
{
-
GIOChannel *channel_output;
GIOChannel *channel_error;
+
channel_output = g_io_channel_unix_new(standard_output);
g_io_channel_set_flags(channel_output, G_IO_FLAG_NONBLOCK, NULL);
static gint editor_command_next_start(EditorData *ed)
{
-
if (ed->vd) editor_verbose_window_fill(ed->vd, "\n", 1);
if (ed->list && ed->count < ed->total)
{
/* handle the first element from the list */
GList *fd_element = ed->list;
+
ed->list = g_list_remove_link(ed->list, fd_element);
if (ed->callback)
cont = ed->callback(ed->list ? ed : NULL, ed->flags, fd_element, ed->data);
return editor_command_done(ed);
else
return editor_command_next_start(ed);
-
}
static gint editor_command_done(EditorData *ed)
{
gint flags;
- const gchar *text;
if (ed->vd)
{
+ const gchar *text;
+
if (ed->count == ed->total)
{
text = _("done");
return flags & EDITOR_ERROR_MASK;
}
+static gint is_valid_editor_command(gint n)
+{
+ return (n >= 0 && n < GQ_EDITOR_SLOTS
+ && options->editor_command[n]
+ && strlen(options->editor_command[n]) > 0);
+}
+
gint start_editor_from_filelist_full(gint n, GList *list, EditorCallback cb, gpointer data)
{
gchar *command;
gint error;
- if (n < 0 || n >= GQ_EDITOR_SLOTS || !list ||
- !options->editor_command[n] ||
- strlen(options->editor_command[n]) == 0) return FALSE;
+ if (!list) return FALSE;
+ if (!is_valid_editor_command(n)) return FALSE;
command = g_locale_from_utf8(options->editor_command[n], -1, NULL, NULL, NULL);
error = editor_command_start(command, options->editor_name[n], list, cb, data);
return start_editor_from_filelist_full(n, list, NULL, NULL);
}
-
gint start_editor_from_file_full(gint n, FileData *fd, EditorCallback cb, gpointer data)
{
GList *list;
gint editor_window_flag_set(gint n)
{
- if (n < 0 || n >= GQ_EDITOR_SLOTS ||
- !options->editor_command[n] ||
- strlen(options->editor_command[n]) == 0) return TRUE;
+ if (!is_valid_editor_command(n)) return TRUE;
return (editor_command_parse(options->editor_command[n], NULL, NULL) & EDITOR_KEEP_FS);
}
-
const gchar *editor_get_error_str(gint flags)
{
if (flags & EDITOR_ERROR_EMPTY) return _("Editor template is empty.");