Sort headers using clang-tidy
[geeqie.git] / src / editors.cc
index faac3d3..a074d56 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "editors.h"
 
+#include <config.h>
+
+#include "compat.h"
+#include "debug.h"
 #include "filedata.h"
 #include "filefilter.h"
+#include "intl.h"
+#include "main-defines.h"
+#include "main.h"
+#include "options.h"
 #include "pixbuf-util.h"
 #include "ui-fileops.h"
-#include "ui-spinner.h"
 #include "utilops.h"
 
-#define EDITOR_WINDOW_WIDTH 500
-#define EDITOR_WINDOW_HEIGHT 300
+enum {
+       EDITOR_WINDOW_WIDTH = 500,
+       EDITOR_WINDOW_HEIGHT = 300
+};
 
 
 
-typedef struct _EditorVerboseData EditorVerboseData;
-struct _EditorVerboseData {
+struct EditorVerboseData {
        GenericDialog *gd;
        GtkWidget *button_close;
        GtkWidget *button_stop;
@@ -44,8 +51,7 @@ struct _EditorVerboseData {
        GtkWidget *spinner;
 };
 
-typedef struct _EditorData EditorData;
-struct _EditorData {
+struct EditorData {
        EditorFlags flags;
        GPid pid;
        GList *list;
@@ -71,7 +77,7 @@ static EditorFlags editor_command_done(EditorData *ed);
  *-----------------------------------------------------------------------------
  */
 
-GHashTable *editors = NULL;
+GHashTable *editors = nullptr;
 GtkListStore *desktop_file_list;
 gboolean editors_finished = FALSE;
 
@@ -92,7 +98,7 @@ void editor_description_free(EditorDescription *editor)
        g_free(editor->menu_path);
        g_free(editor->hotkey);
        g_free(editor->comment);
-       string_list_free(editor->ext_list);
+       g_list_free_full(editor->ext_list, g_free);
        g_free(editor->file);
        g_free(editor);
 }
@@ -101,13 +107,14 @@ static GList *editor_mime_types_to_extensions(gchar **mime_types)
 {
        /** @FIXME this should be rewritten to use the shared mime database, as soon as we switch to gio */
 
-       static const gchar *conv_table[][2] = {
+       static constexpr const gchar *conv_table[][2] = {
                {"image/*",             "*"},
                {"image/bmp",           ".bmp"},
                {"image/gif",           ".gif"},
                {"image/heic",          ".heic"},
                {"image/jpeg",          ".jpeg;.jpg;.mpo"},
                {"image/jpg",           ".jpg;.jpeg"},
+               {"image/jxl",           ".jxl"},
                {"image/webp",          ".webp"},
                {"image/pcx",           ".pcx"},
                {"image/png",           ".png"},
@@ -154,18 +161,17 @@ static GList *editor_mime_types_to_extensions(gchar **mime_types)
                {"image/x-xbitmap",     ".xbm"},
                {"image/x-xcf",         ".xcf"},
                {"image/x-xpixmap",     ".xpm"},
-               {"image/x-x3f",         ".x3f"},
                {"application/x-navi-animation",                ".ani"},
                {"application/x-ptoptimizer-script",    ".pto"},
-               {NULL, NULL}};
+       };
 
-       gint i, j;
-       GList *list = NULL;
+       gint i;
+       GList *list = nullptr;
 
        for (i = 0; mime_types[i]; i++)
-               for (j = 0; conv_table[j][0]; j++)
-                       if (strcmp(mime_types[i], conv_table[j][0]) == 0)
-                               list = g_list_concat(list, filter_to_list(conv_table[j][1]));
+               for (const auto& c : conv_table)
+                       if (strcmp(mime_types[i], c[0]) == 0)
+                               list = g_list_concat(list, filter_to_list(c[1]));
 
        return list;
 }
@@ -177,7 +183,9 @@ gboolean editor_read_desktop_file(const gchar *path)
        gchar *extensions;
        gchar *type;
        const gchar *key = filename_from_path(path);
-       gchar **categories, **only_show_in, **not_show_in;
+       gchar **categories;
+       gchar **only_show_in;
+       gchar **not_show_in;
        gchar *try_exec;
        GtkTreeIter iter;
        gboolean category_geeqie = FALSE;
@@ -187,13 +195,13 @@ gboolean editor_read_desktop_file(const gchar *path)
        if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */
 
        key_file = g_key_file_new();
-       if (!g_key_file_load_from_file(key_file, path, 0, NULL))
+       if (!g_key_file_load_from_file(key_file, path, static_cast<GKeyFileFlags>(0), nullptr))
                {
                g_key_file_free(key_file);
                return FALSE;
                }
 
-       type = g_key_file_get_string(key_file, DESKTOP_GROUP, "Type", NULL);
+       type = g_key_file_get_string(key_file, DESKTOP_GROUP, "Type", nullptr);
        if (!type || strcmp(type, "Application") != 0)
                {
                /* We only consider desktop entries of Application type */
@@ -210,13 +218,13 @@ gboolean editor_read_desktop_file(const gchar *path)
 
        g_hash_table_insert(editors, editor->key, editor);
 
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", NULL)
-           || g_key_file_get_boolean(key_file, DESKTOP_GROUP, "NoDisplay", NULL))
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", nullptr)
+           || g_key_file_get_boolean(key_file, DESKTOP_GROUP, "NoDisplay", nullptr))
                {
                editor->hidden = TRUE;
                }
 
-       categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", NULL, NULL);
+       categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", nullptr, nullptr);
        if (categories)
                {
                gboolean found = FALSE;
@@ -243,7 +251,7 @@ gboolean editor_read_desktop_file(const gchar *path)
                editor->ignored = TRUE;
                }
 
-       only_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "OnlyShowIn", NULL, NULL);
+       only_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "OnlyShowIn", nullptr, nullptr);
        if (only_show_in)
                {
                gboolean found = FALSE;
@@ -258,7 +266,7 @@ gboolean editor_read_desktop_file(const gchar *path)
                g_strfreev(only_show_in);
                }
 
-       not_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "NotShowIn", NULL, NULL);
+       not_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "NotShowIn", nullptr, nullptr);
        if (not_show_in)
                {
                gboolean found = FALSE;
@@ -274,7 +282,7 @@ gboolean editor_read_desktop_file(const gchar *path)
                }
 
 
-       try_exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "TryExec", NULL);
+       try_exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "TryExec", nullptr);
        if (try_exec && !editor->hidden && !editor->ignored)
                {
                gchar *try_exec_res = g_find_program_in_path(try_exec);
@@ -290,8 +298,8 @@ gboolean editor_read_desktop_file(const gchar *path)
                return TRUE;
                }
 
-       editor->name = g_key_file_get_locale_string(key_file, DESKTOP_GROUP, "Name", NULL, NULL);
-       editor->icon = g_key_file_get_string(key_file, DESKTOP_GROUP, "Icon", NULL);
+       editor->name = g_key_file_get_locale_string(key_file, DESKTOP_GROUP, "Name", nullptr, nullptr);
+       editor->icon = g_key_file_get_string(key_file, DESKTOP_GROUP, "Icon", nullptr);
 
        /* Icon key can be either a full path (absolute with file name extension) or an icon name (without extension) */
        if (editor->icon && !g_path_is_absolute(editor->icon))
@@ -311,24 +319,24 @@ gboolean editor_read_desktop_file(const gchar *path)
        if (editor->icon && !register_theme_icon_as_stock(editor->key, editor->icon))
                {
                g_free(editor->icon);
-               editor->icon = NULL;
+               editor->icon = nullptr;
                }
 
-       editor->exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "Exec", NULL);
+       editor->exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "Exec", nullptr);
 
-       editor->menu_path = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-Menu-Path", NULL);
+       editor->menu_path = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-Menu-Path", nullptr);
        if (!editor->menu_path) editor->menu_path = g_strdup("PluginsMenu");
 
-       editor->hotkey = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-Hotkey", NULL);
+       editor->hotkey = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-Hotkey", nullptr);
 
-       editor->comment = g_key_file_get_string(key_file, DESKTOP_GROUP, "Comment", NULL);
+       editor->comment = g_key_file_get_string(key_file, DESKTOP_GROUP, "Comment", nullptr);
 
-       extensions = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-File-Extensions", NULL);
+       extensions = g_key_file_get_string(key_file, DESKTOP_GROUP, "X-Geeqie-File-Extensions", nullptr);
        if (extensions)
                editor->ext_list = filter_to_list(extensions);
        else
                {
-               gchar **mime_types = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "MimeType", NULL, NULL);
+               gchar **mime_types = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "MimeType", nullptr, nullptr);
                if (mime_types)
                        {
                        editor->ext_list = editor_mime_types_to_extensions(mime_types);
@@ -337,13 +345,13 @@ gboolean editor_read_desktop_file(const gchar *path)
                        }
                }
 
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Keep-Fullscreen", NULL)) editor->flags |= EDITOR_KEEP_FS;
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose", NULL)) editor->flags |= EDITOR_VERBOSE;
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose-Multi", NULL)) editor->flags |= EDITOR_VERBOSE_MULTI;
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Filter", NULL)) editor->flags |= EDITOR_DEST;
-       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Terminal", NULL)) editor->flags |= EDITOR_TERMINAL;
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Keep-Fullscreen", nullptr)) editor->flags = static_cast<EditorFlags>(editor->flags | EDITOR_KEEP_FS);
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose", nullptr)) editor->flags = static_cast<EditorFlags>(editor->flags | EDITOR_VERBOSE);
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose-Multi", nullptr)) editor->flags = static_cast<EditorFlags>(editor->flags | EDITOR_VERBOSE_MULTI);
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Filter", nullptr)) editor->flags = static_cast<EditorFlags>(editor->flags | EDITOR_DEST);
+       if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Terminal", nullptr)) editor->flags = static_cast<EditorFlags>(editor->flags | EDITOR_TERMINAL);
 
-       editor->flags |= editor_command_parse(editor, NULL, FALSE, NULL);
+       editor->flags = static_cast<EditorFlags>(editor->flags | editor_command_parse(editor, nullptr, FALSE, nullptr));
 
        if ((editor->flags & EDITOR_NO_PARAM) && !category_geeqie) editor->hidden = TRUE;
 
@@ -356,7 +364,7 @@ gboolean editor_read_desktop_file(const gchar *path)
        disabled = FALSE;
        while (work)
                {
-               if (g_strcmp0(path, work->data) == 0)
+               if (g_strcmp0(path, static_cast<const gchar *>(work->data)) == 0)
                        {
                        disabled = TRUE;
                        break;
@@ -378,19 +386,19 @@ gboolean editor_read_desktop_file(const gchar *path)
        return TRUE;
 }
 
-static gboolean editor_remove_desktop_file_cb(gpointer UNUSED(key), gpointer value, gpointer UNUSED(user_data))
+static gboolean editor_remove_desktop_file_cb(gpointer, gpointer value, gpointer)
 {
-       EditorDescription *editor = value;
+       auto editor = static_cast<EditorDescription *>(value);
        return editor->hidden || editor->ignored;
 }
 
-void editor_table_finish(void)
+void editor_table_finish()
 {
-       g_hash_table_foreach_remove(editors, editor_remove_desktop_file_cb, NULL);
+       g_hash_table_foreach_remove(editors, editor_remove_desktop_file_cb, nullptr);
        editors_finished = TRUE;
 }
 
-void editor_table_clear(void)
+void editor_table_clear()
 {
        if (desktop_file_list)
                {
@@ -404,7 +412,7 @@ void editor_table_clear(void)
                {
                g_hash_table_destroy(editors);
                }
-       editors = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)editor_description_free);
+       editors = g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, reinterpret_cast<GDestroyNotify>(editor_description_free));
        editors_finished = FALSE;
 }
 
@@ -422,7 +430,7 @@ static GList *editor_add_desktop_dir(GList *list, const gchar *path)
                /* dir not found */
                return list;
                }
-       while ((dir = readdir(dp)) != NULL)
+       while ((dir = readdir(dp)) != nullptr)
                {
                gchar *namel = dir->d_name;
 
@@ -438,14 +446,14 @@ static GList *editor_add_desktop_dir(GList *list, const gchar *path)
        return list;
 }
 
-GList *editor_get_desktop_files(void)
+GList *editor_get_desktop_files()
 {
        gchar *path;
        gchar *xdg_data_dirs;
        gchar *all_dirs;
        gchar **split_dirs;
        gint i;
-       GList *list = NULL;
+       GList *list = nullptr;
 
        xdg_data_dirs = getenv("XDG_DATA_DIRS");
        if (xdg_data_dirs && xdg_data_dirs[0])
@@ -473,10 +481,10 @@ GList *editor_get_desktop_files(void)
        return list;
 }
 
-static void editor_list_add_cb(gpointer UNUSED(key), gpointer value, gpointer data)
+static void editor_list_add_cb(gpointer, gpointer value, gpointer data)
 {
-       GList **listp = data;
-       EditorDescription *editor = value;
+       auto listp = static_cast<GList **>(data);
+       auto editor = static_cast<EditorDescription *>(value);
 
        /* do not show the special commands in any list, they are called explicitly */
        if (strcmp(editor->key, CMD_COPY) == 0 ||
@@ -495,8 +503,8 @@ static void editor_list_add_cb(gpointer UNUSED(key), gpointer value, gpointer da
 
 static gint editor_sort(gconstpointer a, gconstpointer b)
 {
-       const EditorDescription *ea = a;
-       const EditorDescription *eb = b;
+       auto ea = static_cast<const EditorDescription *>(a);
+       auto eb = static_cast<const EditorDescription *>(b);
        gchar *caseless_name_ea;
        gchar *caseless_name_eb;
        gchar *collate_key_ea;
@@ -520,11 +528,11 @@ static gint editor_sort(gconstpointer a, gconstpointer b)
        return ret;
 }
 
-GList *editor_list_get(void)
+GList *editor_list_get()
 {
-       GList *editors_list = NULL;
+       GList *editors_list = nullptr;
 
-       if (!editors_finished) return NULL;
+       if (!editors_finished) return nullptr;
 
        g_hash_table_foreach(editors, editor_list_add_cb, &editors_list);
        editors_list = g_list_sort(editors_list, editor_sort);
@@ -539,7 +547,7 @@ static void editor_verbose_data_free(EditorData *ed)
 {
        if (!ed->vd) return;
        g_free(ed->vd);
-       ed->vd = NULL;
+       ed->vd = nullptr;
 }
 
 static void editor_data_free(EditorData *ed)
@@ -551,16 +559,16 @@ static void editor_data_free(EditorData *ed)
 
 static void editor_verbose_window_close(GenericDialog *gd, gpointer data)
 {
-       EditorData *ed = data;
+       auto ed = static_cast<EditorData *>(data);
 
        generic_dialog_close(gd);
        editor_verbose_data_free(ed);
        if (ed->pid == -1) editor_data_free(ed); /* the process has already terminated */
 }
 
-static void editor_verbose_window_stop(GenericDialog *UNUSED(gd), gpointer data)
+static void editor_verbose_window_stop(GenericDialog *, gpointer data)
 {
-       EditorData *ed = data;
+       auto ed = static_cast<EditorData *>(data);
        ed->stopping = TRUE;
        ed->count = 0;
        editor_verbose_window_progress(ed, _("stopping..."));
@@ -570,7 +578,7 @@ static void editor_verbose_window_enable_close(EditorVerboseData *vd)
 {
        vd->gd->cancel_cb = editor_verbose_window_close;
 
-       spinner_set_interval(vd->spinner, -1);
+       gtk_spinner_stop(GTK_SPINNER(vd->spinner));
        gtk_widget_set_sensitive(vd->button_stop, FALSE);
        gtk_widget_set_sensitive(vd->button_close, TRUE);
 }
@@ -585,46 +593,45 @@ static EditorVerboseData *editor_verbose_window(EditorData *ed, const gchar *tex
        vd = g_new0(EditorVerboseData, 1);
 
        vd->gd = file_util_gen_dlg(_("Edit command results"), "editor_results",
-                                  NULL, FALSE,
-                                  NULL, ed);
+                                  nullptr, FALSE,
+                                  nullptr, ed);
        buf = g_strdup_printf(_("Output of %s"), text);
-       generic_dialog_add_message(vd->gd, NULL, buf, NULL, FALSE);
+       generic_dialog_add_message(vd->gd, nullptr, buf, nullptr, FALSE);
        g_free(buf);
-       //~ vd->button_stop = generic_dialog_add_button(vd->gd, GTK_STOCK_STOP, NULL,
-                                                  //~ editor_verbose_window_stop, FALSE);
-       vd->button_stop = generic_dialog_add_button(vd->gd, "process-stop", NULL,
+       vd->button_stop = generic_dialog_add_button(vd->gd, GQ_ICON_STOP, nullptr,
                                                   editor_verbose_window_stop, FALSE);
        gtk_widget_set_sensitive(vd->button_stop, FALSE);
-       vd->button_close = generic_dialog_add_button(vd->gd, GTK_STOCK_CLOSE, NULL,
+       vd->button_close = generic_dialog_add_button(vd->gd, GQ_ICON_CLOSE, _("Close"),
                                                    editor_verbose_window_close, TRUE);
        gtk_widget_set_sensitive(vd->button_close, FALSE);
 
-       scrolled = gtk_scrolled_window_new(NULL, NULL);
-       gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+       scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+       gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
                                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_box_pack_start(GTK_BOX(vd->gd->vbox), scrolled, TRUE, TRUE, 5);
+       gq_gtk_box_pack_start(GTK_BOX(vd->gd->vbox), scrolled, TRUE, TRUE, 5);
        gtk_widget_show(scrolled);
 
        vd->text = gtk_text_view_new();
        gtk_text_view_set_editable(GTK_TEXT_VIEW(vd->text), FALSE);
        gtk_widget_set_size_request(vd->text, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_HEIGHT);
-       gtk_container_add(GTK_CONTAINER(scrolled), vd->text);
+       gq_gtk_container_add(GTK_WIDGET(scrolled), vd->text);
        gtk_widget_show(vd->text);
 
        hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-       gtk_box_pack_start(GTK_BOX(vd->gd->vbox), hbox, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(vd->gd->vbox), hbox, FALSE, FALSE, 0);
        gtk_widget_show(hbox);
 
        vd->progress = gtk_progress_bar_new();
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(vd->progress), 0.0);
-       gtk_box_pack_start(GTK_BOX(hbox), vd->progress, TRUE, TRUE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(hbox), vd->progress, TRUE, TRUE, 0);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(vd->progress), "");
        gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(vd->progress), TRUE);
        gtk_widget_show(vd->progress);
 
-       vd->spinner = spinner_new(NULL, SPINNER_SPEED);
-       gtk_box_pack_start(GTK_BOX(hbox), vd->spinner, FALSE, FALSE, 0);
+       vd->spinner = gtk_spinner_new();
+       gtk_spinner_start(GTK_SPINNER(vd->spinner));
+       gq_gtk_box_pack_start(GTK_BOX(hbox), vd->spinner, FALSE, FALSE, 0);
        gtk_widget_show(vd->spinner);
 
        gtk_widget_show(vd->gd->dialog);
@@ -633,7 +640,7 @@ static EditorVerboseData *editor_verbose_window(EditorData *ed, const gchar *tex
        return vd;
 }
 
-static void editor_verbose_window_fill(EditorVerboseData *vd, gchar *text, gint len)
+static void editor_verbose_window_fill(EditorVerboseData *vd, const gchar *text, gint len)
 {
        GtkTextBuffer *buffer;
        GtkTextIter iter;
@@ -649,7 +656,7 @@ static void editor_verbose_window_progress(EditorData *ed, const gchar *text)
 
        if (ed->total)
                {
-               gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ed->vd->progress), (gdouble)ed->count / ed->total);
+               gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ed->vd->progress), static_cast<gdouble>(ed->count) / ed->total);
                }
 
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ed->vd->progress), (text) ? text : "");
@@ -657,19 +664,19 @@ static void editor_verbose_window_progress(EditorData *ed, const gchar *text)
 
 static gboolean editor_verbose_io_cb(GIOChannel *source, GIOCondition condition, gpointer data)
 {
-       EditorData *ed = data;
+       auto ed = static_cast<EditorData *>(data);
        gchar buf[512];
        gsize count;
 
        if (condition & G_IO_IN)
                {
-               while (g_io_channel_read_chars(source, buf, sizeof(buf), &count, NULL) == G_IO_STATUS_NORMAL)
+               while (g_io_channel_read_chars(source, buf, sizeof(buf), &count, nullptr) == G_IO_STATUS_NORMAL)
                        {
-                       if (!g_utf8_validate(buf, count, NULL))
+                       if (!g_utf8_validate(buf, count, nullptr))
                                {
                                gchar *utf8;
 
-                               utf8 = g_locale_to_utf8(buf, count, NULL, NULL, NULL);
+                               utf8 = g_locale_to_utf8(buf, count, nullptr, nullptr, nullptr);
                                if (utf8)
                                        {
                                        editor_verbose_window_fill(ed->vd, utf8, -1);
@@ -689,30 +696,27 @@ static gboolean editor_verbose_io_cb(GIOChannel *source, GIOCondition condition,
 
        if (condition & (G_IO_ERR | G_IO_HUP))
                {
-               g_io_channel_shutdown(source, TRUE, NULL);
+               g_io_channel_shutdown(source, TRUE, nullptr);
                return FALSE;
                }
 
        return TRUE;
 }
 
-typedef enum {
+enum PathType {
        PATH_FILE,
        PATH_FILE_URL,
        PATH_DEST
-} PathType;
+};
 
 
 static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_sidecars, PathType type, const EditorDescription *editor)
 {
-       GString *string;
        gchar *pathl;
-       const gchar *p = NULL;
+       const gchar *p = nullptr;
 
        DEBUG_2("editor_command_path_parse: %s %d %d %s", fd->path, consider_sidecars, type, editor->key);
 
-       string = g_string_new("");
-
        if (type == PATH_FILE || type == PATH_FILE_URL)
                {
                GList *work = editor->ext_list;
@@ -724,7 +728,7 @@ static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_si
                        while (work)
                                {
                                GList *work2;
-                               gchar *ext = work->data;
+                               auto ext = static_cast<gchar *>(work->data);
                                work = work->next;
 
                                if (strcmp(ext, "*") == 0 ||
@@ -734,10 +738,10 @@ static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_si
                                        break;
                                        }
 
-                               work2 = consider_sidecars ? fd->sidecar_files : NULL;
+                               work2 = consider_sidecars ? fd->sidecar_files : nullptr;
                                while (work2)
                                        {
-                                       FileData *sfd = work2->data;
+                                       auto sfd = static_cast<FileData *>(work2->data);
                                        work2 = work2->next;
 
                                        if (g_ascii_strcasecmp(ext, sfd->extension) == 0)
@@ -748,7 +752,7 @@ static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_si
                                        }
                                if (p) break;
                                }
-                       if (!p) return NULL;
+                       if (!p) return nullptr;
                        }
                }
        else if (type == PATH_DEST)
@@ -760,8 +764,8 @@ static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_si
                }
 
        g_assert(p);
-       string = g_string_append(string, p);
 
+       GString *string = g_string_new(p);
        if (type == PATH_FILE_URL) g_string_prepend(string, "file://");
        pathl = path_from_utf8(string->str);
        g_string_free(string, TRUE);
@@ -769,50 +773,91 @@ static gchar *editor_command_path_parse(const FileData *fd, gboolean consider_si
        if (pathl && !pathl[0]) /* empty string case */
                {
                g_free(pathl);
-               pathl = NULL;
+               pathl = nullptr;
                }
 
        DEBUG_2("editor_command_path_parse: return %s", pathl);
        return pathl;
 }
 
-static GString *append_quoted(GString *str, const char *s, gboolean single_quotes, gboolean double_quotes)
+struct CommandBuilder
 {
-       const char *p;
+       ~CommandBuilder()
+       {
+               if (!str) return;
 
-       if (!single_quotes)
-               {
-               if (!double_quotes)
-                       g_string_append_c(str, '\'');
-               else
-                       g_string_append(str, "\"'");
-               }
+               g_string_free(str, TRUE);
+       }
 
-       for (p = s; *p != '\0'; p++)
-               {
-               if (*p == '\'')
-                       g_string_append(str, "'\\''");
-               else
-                       g_string_append_c(str, *p);
-               }
+       void init()
+       {
+               if (str) return;
 
-       if (!single_quotes)
-               {
-               if (!double_quotes)
-                       g_string_append_c(str, '\'');
-               else
-                       g_string_append(str, "'\"");
-               }
+               str = g_string_new("");
+       }
 
-       return str;
-}
+       void append(const gchar *val)
+       {
+               if (!str) return;
+
+               str = g_string_append(str, val);
+       }
+
+       void append_c(gchar c)
+       {
+               if (!str) return;
+
+               str = g_string_append_c(str, c);
+       }
+
+       void append_quoted(const char *s, gboolean single_quotes, gboolean double_quotes)
+       {
+               if (!str) return;
+
+               if (!single_quotes)
+                       {
+                       if (!double_quotes)
+                               str = g_string_append_c(str, '\'');
+                       else
+                               str = g_string_append(str, "\"'");
+                       }
+
+               for (const char *p = s; *p != '\0'; p++)
+                       {
+                       if (*p == '\'')
+                               str = g_string_append(str, "'\\''");
+                       else
+                               str = g_string_append_c(str, *p);
+                       }
+
+               if (!single_quotes)
+                       {
+                       if (!double_quotes)
+                               str = g_string_append_c(str, '\'');
+                       else
+                               str = g_string_append(str, "'\"");
+                       }
+       }
+
+       gchar *get_command()
+       {
+               if (!str) return nullptr;
+
+               auto command = g_string_free(str, FALSE);
+               str = nullptr;
+               return command;
+       }
+
+private:
+       GString *str{nullptr};
+};
 
 
 EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output)
 {
-       EditorFlags flags = 0;
+       auto flags = static_cast<EditorFlags>(0);
        const gchar *p;
-       GString *result = NULL;
+       CommandBuilder result;
        gboolean escape = FALSE;
        gboolean single_quotes = FALSE;
        gboolean double_quotes = FALSE;
@@ -820,12 +865,14 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
        DEBUG_2("editor_command_parse: %s %d %d", editor->key, consider_sidecars, !!output);
 
        if (output)
-               result = g_string_new("");
+               {
+               *output = nullptr;
+               result.init();
+               }
 
-       if (editor->exec == NULL || editor->exec[0] == '\0')
+       if (editor->exec == nullptr || editor->exec[0] == '\0')
                {
-               flags |= EDITOR_ERROR_EMPTY;
-               goto err;
+               return static_cast<EditorFlags>(flags | EDITOR_ERROR_EMPTY);
                }
 
        p = editor->exec;
@@ -839,16 +886,16 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
                if (escape)
                        {
                        escape = FALSE;
-                       if (output) result = g_string_append_c(result, *p);
+                       result.append_c(*p);
                        }
                else if (*p == '\\')
                        {
                        if (!single_quotes) escape = TRUE;
-                       if (output) result = g_string_append_c(result, *p);
+                       result.append_c(*p);
                        }
                else if (*p == '\'')
                        {
-                       if (output) result = g_string_append_c(result, *p);
+                       result.append_c(*p);
                        if (!single_quotes && !double_quotes)
                                single_quotes = TRUE;
                        else if (single_quotes)
@@ -856,7 +903,7 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
                        }
                else if (*p == '"')
                        {
-                       if (output) result = g_string_append_c(result, *p);
+                       result.append_c(*p);
                        if (!single_quotes && !double_quotes)
                                double_quotes = TRUE;
                        else if (double_quotes)
@@ -864,7 +911,7 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
                        }
                else if (*p == '%' && p[1])
                        {
-                       gchar *pathl = NULL;
+                       gchar *pathl = nullptr;
 
                        p++;
 
@@ -872,21 +919,19 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
                                {
                                case 'f': /* single file */
                                case 'u': /* single url */
-                                       flags |= EDITOR_FOR_EACH;
+                                       flags = static_cast<EditorFlags>(flags | EDITOR_FOR_EACH);
                                        if (flags & EDITOR_SINGLE_COMMAND)
                                                {
-                                               flags |= EDITOR_ERROR_INCOMPATIBLE;
-                                               goto err;
+                                               return static_cast<EditorFlags>(flags | EDITOR_ERROR_INCOMPATIBLE);
                                                }
                                        if (list)
                                                {
                                                /* use the first file from the list */
                                                if (!list->data)
                                                        {
-                                                       flags |= EDITOR_ERROR_NO_FILE;
-                                                       goto err;
+                                                       return static_cast<EditorFlags>(flags | EDITOR_ERROR_NO_FILE);
                                                        }
-                                               pathl = editor_command_path_parse((FileData *)list->data,
+                                               pathl = editor_command_path_parse(static_cast<FileData *>(list->data),
                                                                                  consider_sidecars,
                                                                                  (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
                                                                                  editor);
@@ -898,7 +943,7 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
 
                                                        while (!pathl && work)
                                                                {
-                                                               FileData *fd = work->data;
+                                                               auto fd = static_cast<FileData *>(work->data);
                                                                pathl = editor_command_path_parse(fd,
                                                                                                  consider_sidecars,
                                                                                                  (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
@@ -909,24 +954,19 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
 
                                                if (!pathl)
                                                        {
-                                                       flags |= EDITOR_ERROR_NO_FILE;
-                                                       goto err;
-                                                       }
-                                               if (output)
-                                                       {
-                                                       result = append_quoted(result, pathl, single_quotes, double_quotes);
+                                                       return static_cast<EditorFlags>(flags | EDITOR_ERROR_NO_FILE);
                                                        }
+                                               result.append_quoted(pathl, single_quotes, double_quotes);
                                                g_free(pathl);
                                                }
                                        break;
 
                                case 'F':
                                case 'U':
-                                       flags |= EDITOR_SINGLE_COMMAND;
+                                       flags = static_cast<EditorFlags>(flags | EDITOR_SINGLE_COMMAND);
                                        if (flags & (EDITOR_FOR_EACH | EDITOR_DEST))
                                                {
-                                               flags |= EDITOR_ERROR_INCOMPATIBLE;
-                                               goto err;
+                                               return static_cast<EditorFlags>(flags | EDITOR_ERROR_INCOMPATIBLE);
                                                }
 
                                        if (list)
@@ -937,54 +977,43 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
 
                                                while (work)
                                                        {
-                                                       FileData *fd = work->data;
+                                                       auto fd = static_cast<FileData *>(work->data);
                                                        pathl = editor_command_path_parse(fd, consider_sidecars, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor);
                                                        if (pathl)
                                                                {
                                                                ok = TRUE;
 
-                                                               if (output)
+                                                               if (work != list)
                                                                        {
-                                                                       ok = TRUE;
-                                                                       if (work != list) g_string_append_c(result, ' ');
-                                                                       result = append_quoted(result, pathl, single_quotes, double_quotes);
+                                                                       result.append_c(' ');
                                                                        }
+                                                               result.append_quoted(pathl, single_quotes, double_quotes);
                                                                g_free(pathl);
                                                                }
                                                        work = work->next;
                                                        }
                                                if (!ok)
                                                        {
-                                                       flags |= EDITOR_ERROR_NO_FILE;
-                                                       goto err;
+                                                       return static_cast<EditorFlags>(flags | EDITOR_ERROR_NO_FILE);
                                                        }
                                                }
                                        break;
                                case 'i':
                                        if (editor->icon && *editor->icon)
                                                {
-                                               if (output)
-                                                       {
-                                                       result = g_string_append(result, "--icon ");
-                                                       result = append_quoted(result, editor->icon, single_quotes, double_quotes);
-                                                       }
+                                               result.append("--icon ");
+                                               result.append_quoted(editor->icon, single_quotes, double_quotes);
                                                }
                                        break;
                                case 'c':
-                                       if (output)
-                                               {
-                                               result = append_quoted(result, editor->name, single_quotes, double_quotes);
-                                               }
+                                       result.append_quoted(editor->name, single_quotes, double_quotes);
                                        break;
                                case 'k':
-                                       if (output)
-                                               {
-                                               result = append_quoted(result, editor->file, single_quotes, double_quotes);
-                                               }
+                                       result.append_quoted(editor->file, single_quotes, double_quotes);
                                        break;
                                case '%':
                                        /* %% = % escaping */
-                                       if (output) result = g_string_append_c(result, *p);
+                                       result.append_c(*p);
                                        break;
                                case 'd':
                                case 'D':
@@ -995,41 +1024,31 @@ EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, g
                                        /* deprecated according to spec, ignore */
                                        break;
                                default:
-                                       flags |= EDITOR_ERROR_SYNTAX;
-                                       goto err;
+                                       return static_cast<EditorFlags>(flags | EDITOR_ERROR_SYNTAX);
                                }
                        }
                else
                        {
-                       if (output) result = g_string_append_c(result, *p);
+                       result.append_c(*p);
                        }
                p++;
                }
 
-       if (!(flags & (EDITOR_FOR_EACH | EDITOR_SINGLE_COMMAND))) flags |= EDITOR_NO_PARAM;
+       if (!(flags & (EDITOR_FOR_EACH | EDITOR_SINGLE_COMMAND))) flags = static_cast<EditorFlags>(flags | EDITOR_NO_PARAM);
 
        if (output)
                {
-               *output = g_string_free(result, FALSE);
+               *output = result.get_command();
                DEBUG_3("Editor cmd: %s", *output);
                }
 
        return flags;
-
-
-err:
-       if (output)
-               {
-               g_string_free(result, TRUE);
-               *output = NULL;
-               }
-       return flags;
 }
 
 
 static void editor_child_exit_cb(GPid pid, gint status, gpointer data)
 {
-       EditorData *ed = data;
+       auto ed = static_cast<EditorData *>(data);
        g_spawn_close_pid(pid);
        ed->pid = -1;
 
@@ -1040,7 +1059,7 @@ static void editor_child_exit_cb(GPid pid, gint status, gpointer data)
 static EditorFlags editor_command_one(const EditorDescription *editor, GList *list, EditorData *ed)
 {
        gchar *command;
-       FileData *fd = (ed->flags & EDITOR_NO_PARAM) ? NULL : list->data;;
+       auto fd = static_cast<FileData *>((ed->flags & EDITOR_NO_PARAM) ? nullptr : list->data);;
        GPid pid;
        gint standard_output;
        gint standard_error;
@@ -1048,7 +1067,7 @@ static EditorFlags editor_command_one(const EditorDescription *editor, GList *li
 
        ed->pid = -1;
        ed->flags = editor->flags;
-       ed->flags |= editor_command_parse(editor, list, TRUE, &command);
+       ed->flags = static_cast<EditorFlags>(ed->flags | editor_command_parse(editor, list, TRUE, &command));
 
        ok = !EDITOR_ERRORS(ed->flags);
 
@@ -1063,7 +1082,7 @@ static EditorFlags editor_command_one(const EditorDescription *editor, GList *li
                        if (!ok) log_printf("ERROR: cannot execute shell command '%s'\n", options->shell.path);
                        }
 
-               if (!ok) ed->flags |= EDITOR_ERROR_CANT_EXEC;
+               if (!ok) ed->flags = static_cast<EditorFlags>(ed->flags | EDITOR_ERROR_CANT_EXEC);
                }
 
        if (ok)
@@ -1077,7 +1096,7 @@ static EditorFlags editor_command_one(const EditorDescription *editor, GList *li
                if (options->shell.options && *options->shell.options)
                        args[n++] = options->shell.options;
                args[n++] = command;
-               args[n] = NULL;
+               args[n] = nullptr;
 
                if ((ed->flags & EDITOR_DEST) && fd && fd->change && fd->change->dest) /** @FIXME error handling */
                        {
@@ -1088,18 +1107,18 @@ static EditorFlags editor_command_one(const EditorDescription *editor, GList *li
                        g_unsetenv("GEEQIE_DESTINATION");
                        }
 
-               ok = g_spawn_async_with_pipes(working_directory, args, NULL,
+               ok = g_spawn_async_with_pipes(working_directory, args, nullptr,
                                      G_SPAWN_DO_NOT_REAP_CHILD, /* GSpawnFlags */
-                                     NULL, NULL,
+                                     nullptr, nullptr,
                                      &pid,
-                                     NULL,
-                                     ed->vd ? &standard_output : NULL,
-                                     ed->vd ? &standard_error : NULL,
-                                     NULL);
+                                     nullptr,
+                                     ed->vd ? &standard_output : nullptr,
+                                     ed->vd ? &standard_error : nullptr,
+                                     nullptr);
 
                g_free(working_directory);
 
-               if (!ok) ed->flags |= EDITOR_ERROR_CANT_EXEC;
+               if (!ok) ed->flags = static_cast<EditorFlags>(ed->flags | EDITOR_ERROR_CANT_EXEC);
                }
 
        if (ok)
@@ -1125,26 +1144,28 @@ static EditorFlags editor_command_one(const EditorDescription *editor, GList *li
                        GIOChannel *channel_error;
 
                        channel_output = g_io_channel_unix_new(standard_output);
-                       g_io_channel_set_flags(channel_output, G_IO_FLAG_NONBLOCK, NULL);
-                       g_io_channel_set_encoding(channel_output, NULL, NULL);
+                       g_io_channel_set_flags(channel_output, G_IO_FLAG_NONBLOCK, nullptr);
+                       g_io_channel_set_encoding(channel_output, nullptr, nullptr);
 
-                       g_io_add_watch_full(channel_output, G_PRIORITY_HIGH, G_IO_IN | G_IO_ERR | G_IO_HUP,
-                                           editor_verbose_io_cb, ed, NULL);
+                       g_io_add_watch_full(channel_output, G_PRIORITY_HIGH, static_cast<GIOCondition>(G_IO_IN | G_IO_ERR | G_IO_HUP),
+                                           editor_verbose_io_cb, ed, nullptr);
+                       g_io_add_watch_full(channel_output, G_PRIORITY_HIGH, static_cast<GIOCondition>(G_IO_IN | G_IO_ERR | G_IO_HUP),
+                                           editor_verbose_io_cb, ed, nullptr);
                        g_io_channel_unref(channel_output);
 
                        channel_error = g_io_channel_unix_new(standard_error);
-                       g_io_channel_set_flags(channel_error, G_IO_FLAG_NONBLOCK, NULL);
-                       g_io_channel_set_encoding(channel_error, NULL, NULL);
+                       g_io_channel_set_flags(channel_error, G_IO_FLAG_NONBLOCK, nullptr);
+                       g_io_channel_set_encoding(channel_error, nullptr, nullptr);
 
-                       g_io_add_watch_full(channel_error, G_PRIORITY_HIGH, G_IO_IN | G_IO_ERR | G_IO_HUP,
-                                           editor_verbose_io_cb, ed, NULL);
+                       g_io_add_watch_full(channel_error, G_PRIORITY_HIGH, static_cast<GIOCondition>(G_IO_IN | G_IO_ERR | G_IO_HUP),
+                                           editor_verbose_io_cb, ed, nullptr);
                        g_io_channel_unref(channel_error);
                        }
                }
 
        g_free(command);
 
-       return EDITOR_ERRORS(ed->flags);
+       return static_cast<EditorFlags>(EDITOR_ERRORS(ed->flags));
 }
 
 static EditorFlags editor_command_next_start(EditorData *ed)
@@ -1156,7 +1177,7 @@ static EditorFlags editor_command_next_start(EditorData *ed)
                FileData *fd;
                EditorFlags error;
 
-               fd = (ed->flags & EDITOR_NO_PARAM) ? NULL : ed->list->data;
+               fd = static_cast<FileData *>((ed->flags & EDITOR_NO_PARAM) ? nullptr : ed->list->data);
 
                if (ed->vd)
                        {
@@ -1170,7 +1191,7 @@ static EditorFlags editor_command_next_start(EditorData *ed)
                error = editor_command_one(ed->editor, ed->list, ed);
                if (!error && ed->vd)
                        {
-                       gtk_widget_set_sensitive(ed->vd->button_stop, (ed->list != NULL) );
+                       gtk_widget_set_sensitive(ed->vd->button_stop, (ed->list != nullptr) );
                        if ((ed->flags & EDITOR_FOR_EACH) && fd)
                                {
                                editor_verbose_window_fill(ed->vd, fd->path, strlen(fd->path));
@@ -1179,7 +1200,7 @@ static EditorFlags editor_command_next_start(EditorData *ed)
                        }
 
                if (!error)
-                       return 0;
+                       return static_cast<EditorFlags>(0);
 
                /* command was not started, call the finish immediately */
                return editor_command_next_finish(ed, 0);
@@ -1194,7 +1215,7 @@ static EditorFlags editor_command_next_finish(EditorData *ed, gint status)
        gint cont = ed->stopping ? EDITOR_CB_SKIP : EDITOR_CB_CONTINUE;
 
        if (status)
-               ed->flags |= EDITOR_ERROR_STATUS;
+               ed->flags = static_cast<EditorFlags>(ed->flags | EDITOR_ERROR_STATUS);
 
        if (ed->flags & EDITOR_FOR_EACH)
                {
@@ -1204,7 +1225,7 @@ static EditorFlags editor_command_next_finish(EditorData *ed, gint status)
                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);
+                       cont = ed->callback(ed->list ? ed : nullptr, ed->flags, fd_element, ed->data);
                        if (ed->stopping && cont == EDITOR_CB_CONTINUE) cont = EDITOR_CB_SKIP;
                        }
                filelist_free(fd_element);
@@ -1213,15 +1234,15 @@ static EditorFlags editor_command_next_finish(EditorData *ed, gint status)
                {
                /* handle whole list */
                if (ed->callback)
-                       cont = ed->callback(NULL, ed->flags, ed->list, ed->data);
+                       cont = ed->callback(nullptr, ed->flags, ed->list, ed->data);
                filelist_free(ed->list);
-               ed->list = NULL;
+               ed->list = nullptr;
                }
 
        switch (cont)
                {
                case EDITOR_CB_SUSPEND:
-                       return EDITOR_ERRORS(ed->flags);
+                       return static_cast<EditorFlags>(EDITOR_ERRORS(ed->flags));
                case EDITOR_CB_SKIP:
                        return editor_command_done(ed);
                }
@@ -1249,15 +1270,15 @@ static EditorFlags editor_command_done(EditorData *ed)
        /* free the not-handled items */
        if (ed->list)
                {
-               ed->flags |= EDITOR_ERROR_SKIPPED;
-               if (ed->callback) ed->callback(NULL, ed->flags, ed->list, ed->data);
+               ed->flags = static_cast<EditorFlags>(ed->flags | EDITOR_ERROR_SKIPPED);
+               if (ed->callback) ed->callback(nullptr, ed->flags, ed->list, ed->data);
                filelist_free(ed->list);
-               ed->list = NULL;
+               ed->list = nullptr;
                }
 
        ed->count = 0;
 
-       flags = EDITOR_ERRORS(ed->flags);
+       flags = static_cast<EditorFlags>(EDITOR_ERRORS(ed->flags));
 
        if (!ed->vd) editor_data_free(ed);
 
@@ -1266,12 +1287,12 @@ static EditorFlags editor_command_done(EditorData *ed)
 
 void editor_resume(gpointer ed)
 {
-       editor_command_next_start(ed);
+       editor_command_next_start(reinterpret_cast<EditorData *>(ed));
 }
 
 void editor_skip(gpointer ed)
 {
-       editor_command_done(ed);
+       editor_command_done(static_cast<EditorData *>(ed));
 }
 
 static EditorFlags editor_command_start(const EditorDescription *editor, const gchar *text, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data)
@@ -1279,7 +1300,7 @@ static EditorFlags editor_command_start(const EditorDescription *editor, const g
        EditorData *ed;
        EditorFlags flags = editor->flags;
 
-       if (EDITOR_ERRORS(flags)) return EDITOR_ERRORS(flags);
+       if (EDITOR_ERRORS(flags)) return static_cast<EditorFlags>(EDITOR_ERRORS(flags));
 
        ed = g_new0(EditorData, 1);
        ed->list = filelist_copy(list);
@@ -1291,20 +1312,20 @@ static EditorFlags editor_command_start(const EditorDescription *editor, const g
        ed->working_directory = g_strdup(working_directory);
 
        if ((flags & EDITOR_VERBOSE_MULTI) && list && list->next)
-               flags |= EDITOR_VERBOSE;
+               flags = static_cast<EditorFlags>(flags | EDITOR_VERBOSE);
 
        if (flags & EDITOR_VERBOSE)
                editor_verbose_window(ed, text);
 
        editor_command_next_start(ed);
        /* errors from editor_command_next_start will be handled via callback */
-       return EDITOR_ERRORS(flags);
+       return static_cast<EditorFlags>(EDITOR_ERRORS(flags));
 }
 
 gboolean is_valid_editor_command(const gchar *key)
 {
        if (!key) return FALSE;
-       return g_hash_table_lookup(editors, key) != NULL;
+       return g_hash_table_lookup(editors, key) != nullptr;
 }
 
 EditorFlags start_editor_from_filelist_full(const gchar *key, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data)
@@ -1313,31 +1334,31 @@ EditorFlags start_editor_from_filelist_full(const gchar *key, GList *list, const
        EditorDescription *editor;
        if (!key) return EDITOR_ERROR_EMPTY;
 
-       editor = g_hash_table_lookup(editors, key);
+       editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
 
        if (!editor) return EDITOR_ERROR_EMPTY;
        if (!list && !(editor->flags & EDITOR_NO_PARAM)) return EDITOR_ERROR_NO_FILE;
 
-       error = editor_command_parse(editor, list, TRUE, NULL);
+       error = editor_command_parse(editor, list, TRUE, nullptr);
 
        if (EDITOR_ERRORS(error)) return error;
 
-       error |= editor_command_start(editor, editor->name, list, working_directory, cb, data);
+       error = static_cast<EditorFlags>(error | editor_command_start(editor, editor->name, list, working_directory, cb, data));
 
        if (EDITOR_ERRORS(error))
                {
                gchar *text = g_strdup_printf(_("%s\n\"%s\""), editor_get_error_str(error), editor->file);
 
-               file_util_warning_dialog(_("Invalid editor command"), text, GTK_STOCK_DIALOG_ERROR, NULL);
+               file_util_warning_dialog(_("Invalid editor command"), text, GQ_ICON_DIALOG_ERROR, nullptr);
                g_free(text);
                }
 
-       return EDITOR_ERRORS(error);
+       return static_cast<EditorFlags>(EDITOR_ERRORS(error));
 }
 
 EditorFlags start_editor_from_filelist(const gchar *key, GList *list)
 {
-       return start_editor_from_filelist_full(key, list, NULL, NULL, NULL);
+       return start_editor_from_filelist_full(key, list, nullptr, nullptr, nullptr);
 }
 
 EditorFlags start_editor_from_file_full(const gchar *key, FileData *fd, EditorCallback cb, gpointer data)
@@ -1345,22 +1366,22 @@ EditorFlags start_editor_from_file_full(const gchar *key, FileData *fd, EditorCa
        GList *list;
        EditorFlags error;
 
-       if (!fd) return FALSE;
+       if (!fd) return static_cast<EditorFlags>(FALSE);
 
-       list = g_list_append(NULL, fd);
-       error = start_editor_from_filelist_full(key, list, NULL, cb, data);
+       list = g_list_append(nullptr, fd);
+       error = start_editor_from_filelist_full(key, list, nullptr, cb, data);
        g_list_free(list);
        return error;
 }
 
 EditorFlags start_editor_from_file(const gchar *key, FileData *fd)
 {
-       return start_editor_from_file_full(key, fd, NULL, NULL);
+       return start_editor_from_file_full(key, fd, nullptr, nullptr);
 }
 
 EditorFlags start_editor(const gchar *key, const gchar *working_directory)
 {
-       return start_editor_from_filelist_full(key, NULL, working_directory, NULL, NULL);
+       return start_editor_from_filelist_full(key, nullptr, working_directory, nullptr, nullptr);
 }
 
 gboolean editor_window_flag_set(const gchar *key)
@@ -1368,7 +1389,7 @@ gboolean editor_window_flag_set(const gchar *key)
        EditorDescription *editor;
        if (!key) return TRUE;
 
-       editor = g_hash_table_lookup(editors, key);
+       editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
        if (!editor) return TRUE;
 
        return !!(editor->flags & EDITOR_KEEP_FS);
@@ -1379,7 +1400,7 @@ gboolean editor_is_filter(const gchar *key)
        EditorDescription *editor;
        if (!key) return TRUE;
 
-       editor = g_hash_table_lookup(editors, key);
+       editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
        if (!editor) return TRUE;
 
        return !!(editor->flags & EDITOR_DEST);
@@ -1390,7 +1411,7 @@ gboolean editor_no_param(const gchar *key)
        EditorDescription *editor;
        if (!key) return FALSE;
 
-       editor = g_hash_table_lookup(editors, key);
+       editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
        if (!editor) return FALSE;
 
        return !!(editor->flags & EDITOR_NO_PARAM);
@@ -1401,7 +1422,7 @@ gboolean editor_blocks_file(const gchar *key)
        EditorDescription *editor;
        if (!key) return FALSE;
 
-       editor = g_hash_table_lookup(editors, key);
+       editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
        if (!editor) return FALSE;
 
        /* Decide if the image file should be blocked during editor execution
@@ -1425,12 +1446,16 @@ const gchar *editor_get_error_str(EditorFlags flags)
        return _("Unknown error.");
 }
 
-//const gchar *editor_get_name(const gchar *key)
-//{
-       //EditorDescription *editor = g_hash_table_lookup(editors, key);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+const gchar *editor_get_name_unused(const gchar *key)
+{
+       auto *editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
+
+       if (!editor) return nullptr;
 
-       //if (!editor) return NULL;
+       return editor->name;
+}
+#pragma GCC diagnostic pop
 
-       //return editor->name;
-//}
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */