Fix some GTK deprecation warnings
[geeqie.git] / src / ui-tabcomp.cc
index 920e081..1716e2a 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <string.h>
-#include <sys/types.h>
+#include "ui-tabcomp.h"
+
 #include <dirent.h>
 
-#include "main.h"
-#include "ui-tabcomp.h"
+#include <cstring>
 
+#include <gdk/gdk.h>
+#include <glib-object.h>
+
+#include "compat.h"
+#include "debug.h"
 #include "history-list.h"
+#include "intl.h"
+#include "main-defines.h"
 #include "misc.h"      /* expand_tilde() */
+#include "options.h"
 #include "ui-fileops.h"
-#include "ui-spinner.h"
 #include "ui-utildlg.h"
 
 /* define this to enable a pop-up menu that shows possible matches
  * ----------------------------------------------------------------
  * Tab completion routines, can be connected to any gtkentry widget
  * using the tab_completion_add_to_entry() function.
- * 
+ *
  * Use remove_trailing_slash() to strip the trailing G_DIR_SEPARATOR.
- * 
+ *
  * ----------------------------------------------------------------
  */
 
-typedef struct _TabCompData TabCompData;
-struct _TabCompData
+struct TabCompData
 {
        GtkWidget *entry;
        gchar *dir_path;
@@ -89,28 +94,18 @@ static gint tab_completion_do(TabCompData *td);
 
 static void tab_completion_free_list(TabCompData *td)
 {
-       GList *list;
-
        g_free(td->dir_path);
-       td->dir_path = NULL;
-
-       list = td->file_list;
+       td->dir_path = nullptr;
 
-       while (list)
-               {
-               g_free(list->data);
-               list = list->next;
-               }
-
-       g_list_free(td->file_list);
-       td->file_list = NULL;
+       g_list_free_full(td->file_list, g_free);
+       td->file_list = nullptr;
 }
 
 static void tab_completion_read_dir(TabCompData *td, const gchar *path)
 {
        DIR *dp;
        struct dirent *dir;
-       GList *list = NULL;
+       GList *list = nullptr;
        gchar *pathl;
 
        tab_completion_free_list(td);
@@ -123,7 +118,7 @@ static void tab_completion_read_dir(TabCompData *td, const gchar *path)
                g_free(pathl);
                return;
                }
-       while ((dir = readdir(dp)) != NULL)
+       while ((dir = readdir(dp)) != nullptr)
                {
                gchar *name = dir->d_name;
                if (strcmp(name, ".") != 0 && strcmp(name, "..") != 0 &&
@@ -151,9 +146,9 @@ static void tab_completion_read_dir(TabCompData *td, const gchar *path)
        g_free(pathl);
 }
 
-static void tab_completion_destroy(GtkWidget *UNUSED(widget), gpointer data)
+static void tab_completion_destroy(GtkWidget *, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
 
        tab_completion_free_list(td);
        g_free(td->history_key);
@@ -171,7 +166,7 @@ static gchar *tab_completion_get_text(TabCompData *td)
 {
        gchar *text;
 
-       text = g_strdup(gtk_entry_get_text(GTK_ENTRY(td->entry)));
+       text = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(td->entry)));
 
        if (text[0] == '~')
                {
@@ -208,7 +203,7 @@ static void tab_completion_emit_tab_signal(TabCompData *td)
 #ifdef TAB_COMPLETION_ENABLE_POPUP_MENU
 void tab_completion_iter_menu_items(GtkWidget *widget, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
        GtkWidget *child;
 
        if (!gtk_widget_get_visible(widget)) return;
@@ -216,11 +211,11 @@ void tab_completion_iter_menu_items(GtkWidget *widget, gpointer data)
        child = gtk_bin_get_child(GTK_BIN(widget));
        if (GTK_IS_LABEL(child)) {
                const gchar *text = gtk_label_get_text(GTK_LABEL(child));
-               const gchar *entry_text = gtk_entry_get_text(GTK_ENTRY(td->entry));
+               const gchar *entry_text = gq_gtk_entry_get_text(GTK_ENTRY(td->entry));
                const gchar *prefix = filename_from_path(entry_text);
                guint prefix_len = strlen(prefix);
 
-               if (strlen(text) < prefix_len || strncmp(text, prefix, prefix_len))
+               if (strlen(text) < prefix_len || strncmp(text, prefix, prefix_len) != 0)
                        {
                        /* Hide menu items not matching */
                        gtk_widget_hide(widget);
@@ -235,7 +230,7 @@ void tab_completion_iter_menu_items(GtkWidget *widget, gpointer data)
 
 static gboolean tab_completion_popup_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
 
        if (event->keyval == GDK_KEY_Tab ||
            event->keyval == GDK_KEY_BackSpace ||
@@ -253,7 +248,7 @@ static gboolean tab_completion_popup_key_press(GtkWidget *widget, GdkEventKey *e
 
                        /* Reduce the number of entries in the menu */
                        td->choices = 0;
-                       gtk_container_foreach(GTK_CONTAINER(widget), tab_completion_iter_menu_items, (gpointer) td);
+                       gtk_container_foreach(GTK_CONTAINER(widget), tab_completion_iter_menu_items, td);
                        if (td->choices > 1) return TRUE; /* multiple choices */
                        if (td->choices > 0) tab_completion_do(td); /* one choice */
                        }
@@ -270,15 +265,15 @@ static gboolean tab_completion_popup_key_press(GtkWidget *widget, GdkEventKey *e
 
 static void tab_completion_popup_cb(GtkWidget *widget, gpointer data)
 {
-       gchar *name = data;
+       auto name = static_cast<gchar *>(data);
        TabCompData *td;
        gchar *buf;
 
-       td = g_object_get_data(G_OBJECT(widget), "tab_completion_data");
+       td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(widget), "tab_completion_data"));
        if (!td) return;
 
        buf = g_build_filename(td->dir_path, name, NULL);
-       gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+       gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
        gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
        g_free(buf);
 
@@ -307,7 +302,7 @@ static void tab_completion_popup_list(TabCompData *td, GList *list)
        work = list;
        while (work && count < TAB_COMP_POPUP_MAX)
                {
-               gchar *name = work->data;
+               auto name = static_cast<gchar *>(work->data);
                GtkWidget *item;
 
                item = menu_item_add_simple(menu, name, G_CALLBACK(tab_completion_popup_cb), name);
@@ -320,7 +315,7 @@ static void tab_completion_popup_list(TabCompData *td, GList *list)
        g_signal_connect(G_OBJECT(menu), "key_press_event",
                         G_CALLBACK(tab_completion_popup_key_press), td);
 
-       gtk_menu_popup_at_widget(GTK_MENU(menu), td->entry, GDK_GRAVITY_NORTH_EAST, GDK_GRAVITY_NORTH, NULL);
+       gtk_menu_popup_at_widget(GTK_MENU(menu), td->entry, GDK_GRAVITY_NORTH_EAST, GDK_GRAVITY_NORTH, nullptr);
 }
 
 #ifndef CASE_SORT
@@ -336,7 +331,7 @@ static gint simple_sort(gconstpointer a, gconstpointer b)
 
 static gboolean tab_completion_do(TabCompData *td)
 {
-       const gchar *entry_text = gtk_entry_get_text(GTK_ENTRY(td->entry));
+       const gchar *entry_text = gq_gtk_entry_get_text(GTK_ENTRY(td->entry));
        const gchar *entry_file;
        gchar *entry_dir;
        gchar *ptr;
@@ -345,7 +340,7 @@ static gboolean tab_completion_do(TabCompData *td)
        if (entry_text[0] == '\0')
                {
                entry_dir = g_strdup(G_DIR_SEPARATOR_S); /** @FIXME root directory win32 */
-               gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
+               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
                gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(entry_dir));
                g_free(entry_dir);
                return FALSE;
@@ -366,7 +361,7 @@ static gboolean tab_completion_do(TabCompData *td)
                {
                if (home_exp)
                        {
-                       gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
+                       gq_gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
                        gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(entry_dir));
                        }
                g_free(entry_dir);
@@ -382,7 +377,7 @@ static gboolean tab_completion_do(TabCompData *td)
                        {
                        if (home_exp)
                                {
-                               gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
+                               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
                                gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(entry_dir));
                                }
 
@@ -393,7 +388,7 @@ static gboolean tab_completion_do(TabCompData *td)
                                gchar *buf;
                                const gchar *file;
 
-                               file = td->file_list->data;
+                               file = static_cast<const gchar *>(td->file_list->data);
                                buf = g_build_filename(entry_dir, file, NULL);
                                if (isdir(buf))
                                        {
@@ -401,7 +396,7 @@ static gboolean tab_completion_do(TabCompData *td)
                                        g_free(buf);
                                        buf = tmp;
                                        }
-                               gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+                               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
                                gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
                                g_free(buf);
                                }
@@ -417,18 +412,16 @@ static gboolean tab_completion_do(TabCompData *td)
                        g_free(entry_dir);
                        return home_exp;
                        }
-               else
-                       {
-                       gchar *buf = g_strconcat(entry_dir, G_DIR_SEPARATOR_S, NULL);
-                       gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
-                       gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
-                       g_free(buf);
-                       g_free(entry_dir);
-                       return TRUE;
-                       }
+
+               gchar *buf = g_strconcat(entry_dir, G_DIR_SEPARATOR_S, NULL);
+               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+               gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
+               g_free(buf);
+               g_free(entry_dir);
+               return TRUE;
                }
 
-       ptr = (gchar *)filename_from_path(entry_dir);
+       ptr = const_cast<gchar *>(filename_from_path(entry_dir));
        if (ptr > entry_dir) ptr--;
        ptr[0] = '\0';
 
@@ -441,7 +434,7 @@ static gboolean tab_completion_do(TabCompData *td)
        if (isdir(entry_dir))
                {
                GList *list;
-               GList *poss = NULL;
+               GList *poss = nullptr;
                gint l = strlen(entry_file);
 
                if (!td->dir_path || !td->file_list || strcmp(td->dir_path, entry_dir) != 0)
@@ -452,7 +445,7 @@ static gboolean tab_completion_do(TabCompData *td)
                list = td->file_list;
                while (list)
                        {
-                       gchar *file = list->data;
+                       auto file = static_cast<gchar *>(list->data);
                        if (strncmp(entry_file, file, l) == 0)
                                {
                                poss = g_list_prepend(poss, file);
@@ -464,63 +457,62 @@ static gboolean tab_completion_do(TabCompData *td)
                        {
                        if (!poss->next)
                                {
-                               gchar *file = poss->data;
+                               auto file = static_cast<gchar *>(poss->data);
                                gchar *buf;
 
                                buf = g_build_filename(entry_dir, file, NULL);
-                               gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+                               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
                                gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
                                g_free(buf);
                                g_list_free(poss);
                                g_free(entry_dir);
                                return TRUE;
                                }
-                       else
-                               {
-                               gsize c = strlen(entry_file);
-                               gboolean done = FALSE;
-                               gchar *test_file = poss->data;
 
-                               while (!done)
+                       gsize c = strlen(entry_file);
+                       gboolean done = FALSE;
+                       auto test_file = static_cast<gchar *>(poss->data);
+
+                       while (!done)
+                               {
+                               list = poss;
+                               if (!list) done = TRUE;
+                               while (list && !done)
                                        {
-                                       list = poss;
-                                       if (!list) done = TRUE;
-                                       while (list && !done)
+                                       auto file = static_cast<gchar *>(list->data);
+                                       if (strlen(file) < c || strncmp(test_file, file, c) != 0)
                                                {
-                                               gchar *file = list->data;
-                                               if (strlen(file) < c || strncmp(test_file, file, c) != 0)
-                                                       {
-                                                       done = TRUE;
-                                                       }
-                                               list = list->next;
+                                               done = TRUE;
                                                }
-                                       c++;
+                                       list = list->next;
                                        }
-                               c -= 2;
-                               if (c > 0)
-                                       {
-                                       gchar *file;
-                                       gchar *buf;
-                                       file = g_strdup(test_file);
-                                       file[c] = '\0';
-                                       buf = g_build_filename(entry_dir, file, NULL);
-                                       gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
-                                       gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
+                               c++;
+                               }
+                       c -= 2;
+                       if (c > 0)
+                               {
+                               gchar *file;
+                               gchar *buf;
+                               file = g_strdup(test_file);
+                               file[c] = '\0';
+                               buf = g_build_filename(entry_dir, file, NULL);
+                               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+                               gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
 
 #ifdef TAB_COMPLETION_ENABLE_POPUP_MENU
 
-                                       poss = g_list_sort(poss, simple_sort);
-                                       tab_completion_popup_list(td, poss);
+                               poss = g_list_sort(poss, simple_sort);
+                               tab_completion_popup_list(td, poss);
 
 #endif
 
-                                       g_free(file);
-                                       g_free(buf);
-                                       g_list_free(poss);
-                                       g_free(entry_dir);
-                                       return TRUE;
-                                       }
+                               g_free(file);
+                               g_free(buf);
+                               g_list_free(poss);
+                               g_free(entry_dir);
+                               return TRUE;
                                }
+
                        g_list_free(poss);
                        }
                }
@@ -532,7 +524,7 @@ static gboolean tab_completion_do(TabCompData *td)
 
 static gboolean tab_completion_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
        gboolean stop_signal = FALSE;
 
        switch (event->keyval)
@@ -568,12 +560,12 @@ static gboolean tab_completion_key_pressed(GtkWidget *widget, GdkEventKey *event
        return (stop_signal);
 }
 
-static void tab_completion_button_pressed(GtkWidget *UNUSED(widget), gpointer data)
+static void tab_completion_button_pressed(GtkWidget *, gpointer data)
 {
        TabCompData *td;
-       GtkWidget *entry = data;
+       auto entry = static_cast<GtkWidget *>(data);
 
-       td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
 
        if (!td) return;
 
@@ -590,7 +582,7 @@ static void tab_completion_button_pressed(GtkWidget *UNUSED(widget), gpointer da
 
 static void tab_completion_button_size_allocate(GtkWidget *button, GtkAllocation *allocation, gpointer data)
 {
-       GtkWidget *parent = data;
+       auto parent = static_cast<GtkWidget *>(data);
        GtkAllocation parent_allocation;
        gtk_widget_get_allocation(parent, &parent_allocation);
 
@@ -600,8 +592,7 @@ static void tab_completion_button_size_allocate(GtkWidget *button, GtkAllocation
 
                gtk_widget_get_allocation(button, &button_allocation);
                button_allocation.height = parent_allocation.height;
-               button_allocation.y = parent_allocation.y +
-                       (parent_allocation.height - parent_allocation.height) / 2;
+               button_allocation.y = parent_allocation.y;
                gtk_widget_size_allocate(button, &button_allocation);
                }
 }
@@ -609,23 +600,14 @@ static void tab_completion_button_size_allocate(GtkWidget *button, GtkAllocation
 static GtkWidget *tab_completion_create_complete_button(GtkWidget *entry, GtkWidget *parent)
 {
        GtkWidget *button;
-       GtkWidget *icon;
-       GdkPixbuf *pixbuf;
 
-       button = gtk_button_new();
+       button = gtk_button_new_from_icon_name(GQ_ICON_GO_LAST, GTK_ICON_SIZE_BUTTON);
        gtk_widget_set_can_focus(button, FALSE);
        g_signal_connect(G_OBJECT(button), "size_allocate",
                         G_CALLBACK(tab_completion_button_size_allocate), parent);
        g_signal_connect(G_OBJECT(button), "clicked",
                         G_CALLBACK(tab_completion_button_pressed), entry);
 
-       pixbuf = gdk_pixbuf_new_from_inline(-1, icon_tabcomp, FALSE, NULL);
-       icon = gtk_image_new_from_pixbuf(pixbuf);
-       g_object_unref(pixbuf);
-
-       gtk_container_add(GTK_CONTAINER(button), icon);
-       gtk_widget_show(icon);
-
        return button;
 }
 
@@ -650,19 +632,19 @@ GtkWidget *tab_completion_new_with_history(GtkWidget **entry, const gchar *text,
        box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
 
        combo = gtk_combo_box_text_new_with_entry();
-       gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
        gtk_widget_show(combo);
 
        combo_entry = gtk_bin_get_child(GTK_BIN(combo));
 
        button = tab_completion_create_complete_button(combo_entry, combo);
-       gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
        gtk_widget_show(button);
 
-       tab_completion_add_to_entry(combo_entry, enter_func, NULL, NULL, data);
+       tab_completion_add_to_entry(combo_entry, enter_func, nullptr, nullptr, data);
 
-       td = g_object_get_data(G_OBJECT(combo_entry), "tab_completion_data");
-       if (!td) return NULL; /* this should never happen! */
+       td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(combo_entry), "tab_completion_data"));
+       if (!td) return nullptr; /* this should never happen! */
 
        td->combo = combo;
        td->has_history = TRUE;
@@ -674,14 +656,14 @@ GtkWidget *tab_completion_new_with_history(GtkWidget **entry, const gchar *text,
        work = history_list_get_by_key(history_key);
        while (work)
                {
-               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), (gchar *)work->data);
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), static_cast<gchar *>(work->data));
                work = work->next;
                n++;
                }
 
        if (text)
                {
-               gtk_entry_set_text(GTK_ENTRY(combo_entry), text);
+               gq_gtk_entry_set_text(GTK_ENTRY(combo_entry), text);
                }
        else if (n > 0)
                {
@@ -694,15 +676,15 @@ GtkWidget *tab_completion_new_with_history(GtkWidget **entry, const gchar *text,
 
 const gchar *tab_completion_set_to_last_history(GtkWidget *entry)
 {
-       TabCompData *td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       auto td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
        const gchar *buf;
 
-       if (!td || !td->has_history) return NULL;
+       if (!td || !td->has_history) return nullptr;
 
        buf = history_list_find_last_path_by_key(td->history_key);
        if (buf)
                {
-               gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
+               gq_gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
                }
 
        return buf;
@@ -715,7 +697,7 @@ void tab_completion_append_to_history(GtkWidget *entry, const gchar *path)
        GList *work;
        gint n = 0;
 
-       td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
 
        if (!path) return;
 
@@ -731,7 +713,7 @@ void tab_completion_append_to_history(GtkWidget *entry, const gchar *path)
        work = history_list_get_by_key(td->history_key);
        while (work)
                {
-               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(td->combo), (gchar *)work->data);
+               gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(td->combo), static_cast<gchar *>(work->data));
                work = work->next;
                n++;
                }
@@ -751,12 +733,12 @@ GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text,
        hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
 
        newentry = gtk_entry_new();
-       if (text) gtk_entry_set_text(GTK_ENTRY(newentry), text);
-       gtk_box_pack_start(GTK_BOX(hbox), newentry, TRUE, TRUE, 0);
+       if (text) gq_gtk_entry_set_text(GTK_ENTRY(newentry), text);
+       gq_gtk_box_pack_start(GTK_BOX(hbox), newentry, TRUE, TRUE, 0);
        gtk_widget_show(newentry);
 
        button = tab_completion_create_complete_button(newentry, newentry);
-       gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
        gtk_widget_show(button);
 
        tab_completion_add_to_entry(newentry, enter_func, filter, filter_desc, data);
@@ -791,7 +773,7 @@ void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gcha
 
 void tab_completion_add_tab_func(GtkWidget *entry, void (*tab_func)(const gchar *, gpointer), gpointer data)
 {
-       TabCompData *td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       auto td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
 
        if (!td) return;
 
@@ -802,7 +784,7 @@ void tab_completion_add_tab_func(GtkWidget *entry, void (*tab_func)(const gchar
 /* Add a callback function called when a new entry is appended to the list */
 void tab_completion_add_append_func(GtkWidget *entry, void (*tab_append_func)(const gchar *, gpointer, gint), gpointer data)
 {
-       TabCompData *td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       auto td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
 
        if (!td) return;
 
@@ -814,7 +796,7 @@ gchar *remove_trailing_slash(const gchar *path)
 {
        gint l;
 
-       if (!path) return NULL;
+       if (!path) return nullptr;
 
        l = strlen(path);
        while (l > 1 && path[l - 1] == G_DIR_SEPARATOR) l--;
@@ -824,17 +806,17 @@ gchar *remove_trailing_slash(const gchar *path)
 
 static void tab_completion_select_cancel_cb(FileDialog *fd, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
 
-       td->fd = NULL;
+       td->fd = nullptr;
        file_dialog_close(fd);
 }
 
 static void tab_completion_select_ok_cb(FileDialog *fd, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
 
-       gtk_entry_set_text(GTK_ENTRY(td->entry), gtk_entry_get_text(GTK_ENTRY(fd->entry)));
+       gq_gtk_entry_set_text(GTK_ENTRY(td->entry), gq_gtk_entry_get_text(GTK_ENTRY(fd->entry)));
 
        tab_completion_select_cancel_cb(fd, data);
 
@@ -845,8 +827,8 @@ static void tab_completion_select_show(TabCompData *td)
 {
        const gchar *title;
        const gchar *path;
-       gchar *filter = NULL;
-       gchar *filter_desc = NULL;
+       const gchar *filter = nullptr;
+       gchar *filter_desc = nullptr;
 
        if (td->fd)
                {
@@ -857,10 +839,10 @@ static void tab_completion_select_show(TabCompData *td)
        title = (td->fd_title) ? td->fd_title : _("Select path");
        td->fd = file_dialog_new(title, "select_path", td->entry,
                                 tab_completion_select_cancel_cb, td);
-       file_dialog_add_button(td->fd, GTK_STOCK_OK, NULL,
+       file_dialog_add_button(td->fd, GQ_ICON_OK, "OK",
                                 tab_completion_select_ok_cb, TRUE);
 
-       generic_dialog_add_message(GENERIC_DIALOG(td->fd), NULL, title, NULL, FALSE);
+       generic_dialog_add_message(GENERIC_DIALOG(td->fd), nullptr, title, nullptr, FALSE);
 
        if (td->filter)
                {
@@ -879,23 +861,23 @@ static void tab_completion_select_show(TabCompData *td)
                filter_desc = _("All files");
                }
 
-       path = gtk_entry_get_text(GTK_ENTRY(td->entry));
-       if (strlen(path) == 0) path = NULL;
+       path = gq_gtk_entry_get_text(GTK_ENTRY(td->entry));
+       if (strlen(path) == 0) path = nullptr;
        if (td->fd_folders_only)
                {
-               file_dialog_add_path_widgets(td->fd, NULL, path, td->history_key, NULL, NULL);
+               file_dialog_add_path_widgets(td->fd, nullptr, path, td->history_key, nullptr, nullptr);
                }
        else
                {
-               file_dialog_add_path_widgets(td->fd, NULL, path, td->history_key, filter, filter_desc);
+               file_dialog_add_path_widgets(td->fd, nullptr, path, td->history_key, filter, filter_desc);
                }
 
        gtk_widget_show(GENERIC_DIALOG(td->fd)->dialog);
 }
 
-static void tab_completion_select_pressed(GtkWidget *UNUSED(widget), gpointer data)
+static void tab_completion_select_pressed(GtkWidget *, gpointer data)
 {
-       TabCompData *td = data;
+       auto td = static_cast<TabCompData *>(data);
 
        tab_completion_select_show(td);
 }
@@ -906,7 +888,7 @@ void tab_completion_add_select_button(GtkWidget *entry, const gchar *title, gboo
        GtkWidget *parent;
        GtkWidget *hbox;
 
-       td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+       td = static_cast<TabCompData *>(g_object_get_data(G_OBJECT(entry), "tab_completion_data"));
 
        if (!td) return;
 
@@ -927,7 +909,7 @@ void tab_completion_add_select_button(GtkWidget *entry, const gchar *title, gboo
        g_signal_connect(G_OBJECT(td->fd_button), "clicked",
                         G_CALLBACK(tab_completion_select_pressed), td);
 
-       gtk_box_pack_start(GTK_BOX(hbox), td->fd_button, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(hbox), td->fd_button, FALSE, FALSE, 0);
 
        gtk_widget_show(td->fd_button);
 }