Fix #1204: Geeqie crashes if double-clicked on empty space in file lis
[geeqie.git] / src / layout.cc
index ff675f7..37ed8e2 100644 (file)
@@ -22,6 +22,8 @@
 #include "main.h"
 #include "layout.h"
 
+#include "bar.h"
+#include "bar-sort.h"
 #include "filedata.h"
 #include "histogram.h"
 #include "history-list.h"
 #include "layout-util.h"
 #include "logwindow.h"
 #include "menu.h"
+#include "metadata.h"
+#include "misc.h"
 #include "pixbuf-util.h"
-#include "utilops.h"
-#include "view-dir.h"
-#include "view-file.h"
+#include "preferences.h"
+#include "rcfile.h"
+#include "shortcuts.h"
 #include "ui-fileops.h"
 #include "ui-menu.h"
 #include "ui-misc.h"
 #include "ui-tabcomp.h"
+#include "utilops.h"
+#include "view-dir.h"
+#include "view-file.h"
 #include "window.h"
-#include "metadata.h"
-#include "rcfile.h"
-#include "bar.h"
-#include "bar-sort.h"
-#include "preferences.h"
-#include "shortcuts.h"
+
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
 #endif
@@ -222,7 +224,7 @@ static void layout_path_entry_changed_cb(GtkWidget *widget, gpointer data)
 
        if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return;
 
-       buf = g_strdup(gtk_entry_get_text(GTK_ENTRY(lw->path_entry)));
+       buf = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(lw->path_entry)));
        if (!lw->dir_fd || strcmp(buf, lw->dir_fd->path) != 0)
                {
                layout_set_path(lw, buf);
@@ -248,7 +250,7 @@ static void layout_path_entry_tab_cb(const gchar *path, gpointer data)
                        /* put the G_DIR_SEPARATOR back, if we are in tab completion for a dir and result was path change */
                        gtk_editable_insert_text(GTK_EDITABLE(lw->path_entry), G_DIR_SEPARATOR_S, -1, &pos);
                        gtk_editable_set_position(GTK_EDITABLE(lw->path_entry),
-                                                 strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry))));
+                                                 strlen(gq_gtk_entry_get_text(GTK_ENTRY(lw->path_entry))));
                        }
                }
        else if (lw->dir_fd)
@@ -337,7 +339,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
                toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN);
                scroll_window = gq_gtk_scrolled_window_new(nullptr, nullptr);
                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_AUTOMATIC,GTK_POLICY_NEVER);
-               gtk_container_add(GTK_CONTAINER(scroll_window), menu_bar);
+               gq_gtk_container_add(GTK_WIDGET(scroll_window), menu_bar);
 
                gtk_widget_show(scroll_window);
                gtk_widget_show(menu_bar);
@@ -487,7 +489,8 @@ static GtkWidget *layout_sort_button(LayoutWindow *lw, GtkWidget *box)
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_RIGHT);
 
-       gtk_container_add(GTK_CONTAINER(frame), button);
+       gq_gtk_container_add(GTK_WIDGET(frame), button);
+
        gtk_widget_show(button);
 
        return button;
@@ -585,7 +588,7 @@ static GtkWidget *layout_zoom_button(LayoutWindow *lw, GtkWidget *box, gint size
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_RIGHT);
 
-       gtk_container_add(GTK_CONTAINER(frame), button);
+       gq_gtk_container_add(GTK_WIDGET(frame), button);
        gtk_widget_show(button);
 
        return button;
@@ -812,7 +815,7 @@ static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean star
 
        label = gtk_label_new(text ? text : "");
        gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
-       gtk_container_add(GTK_CONTAINER(frame), label);
+       gq_gtk_container_add(GTK_WIDGET(frame), label);
        gtk_widget_show(label);
 
        return label;
@@ -883,7 +886,7 @@ static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small
        toolbar_frame = gtk_frame_new(nullptr);
        DEBUG_NAME(toolbar_frame);
        gq_gtk_frame_set_shadow_type(GTK_FRAME(toolbar_frame), GTK_SHADOW_IN);
-       gtk_container_add(GTK_CONTAINER(toolbar_frame), toolbar);
+       gq_gtk_container_add(GTK_WIDGET(toolbar_frame), toolbar);
        gtk_widget_show(toolbar_frame);
        gtk_widget_show(toolbar);
        gq_gtk_box_pack_end(GTK_BOX(hbox), toolbar_frame, FALSE, FALSE, 0);
@@ -1127,7 +1130,7 @@ static void layout_sync_path(LayoutWindow *lw)
 {
        if (!lw->dir_fd) return;
 
-       if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
+       if (lw->path_entry) gq_gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
 
        if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd);
        if (lw->vf) vf_set_fd(lw->vf, lw->dir_fd);
@@ -1608,7 +1611,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
                GdkGeometry geometry;
                GdkWindowHints hints;
 
-               lw->tools = window_new(GTK_WINDOW_TOPLEVEL, "tools", PIXBUF_INLINE_ICON_TOOLS, nullptr, _("Tools"));
+               lw->tools = window_new("tools", PIXBUF_INLINE_ICON_TOOLS, nullptr, _("Tools"));
                DEBUG_NAME(lw->tools);
                g_signal_connect(G_OBJECT(lw->tools), "delete_event",
                                 G_CALLBACK(layout_tools_delete_cb), lw);
@@ -1648,7 +1651,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
 
        vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
        DEBUG_NAME(vbox);
-       gtk_container_add(GTK_CONTAINER(lw->tools), vbox);
+       gq_gtk_container_add(GTK_WIDGET(lw->tools), vbox);
        if (options->expand_menu_toolbar) gq_gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(lw->menu_tool_bar), FALSE, FALSE, 0);
        gtk_widget_show(vbox);
 
@@ -1670,7 +1673,7 @@ static void layout_tools_setup(LayoutWindow *lw, GtkWidget *tools, GtkWidget *fi
                if (options->save_window_positions)
                        {
                        gtk_window_set_default_size(GTK_WINDOW(lw->tools), lw->options.float_window.w, lw->options.float_window.h);
-                       gtk_window_move(GTK_WINDOW(lw->tools), lw->options.float_window.x, lw->options.float_window.y);
+                       gq_gtk_window_move(GTK_WINDOW(lw->tools), lw->options.float_window.x, lw->options.float_window.y);
                        }
                else
                        {
@@ -2258,7 +2261,7 @@ static void layout_config_ok_cb(GtkWidget *widget, gpointer data)
 static void home_path_set_current_cb(GtkWidget *, gpointer data)
 {
        auto lc = static_cast<LayoutConfig *>(data);
-       gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw));
+       gq_gtk_entry_set_text(GTK_ENTRY(lc->home_path_entry), layout_get_path(lc->lw));
 }
 
 static void startup_path_set_current_cb(GtkWidget *widget, gpointer data)
@@ -2317,7 +2320,7 @@ void layout_show_config_window(LayoutWindow *lw)
        layout_sync_options_with_current_state(lw);
        copy_layout_options(&lc->options, &lw->options);
 
-       lc->configwindow = window_new(GTK_WINDOW_TOPLEVEL, "Layout", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Window options and layout"));
+       lc->configwindow = window_new("Layout", PIXBUF_INLINE_ICON_CONFIG, nullptr, _("Window options and layout"));
        DEBUG_NAME(lc->configwindow);
        gtk_window_set_type_hint(GTK_WINDOW(lc->configwindow), GDK_WINDOW_TYPE_HINT_DIALOG);
 
@@ -2330,7 +2333,7 @@ void layout_show_config_window(LayoutWindow *lw)
 
        win_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
        DEBUG_NAME(win_vbox);
-       gtk_container_add(GTK_CONTAINER(lc->configwindow), win_vbox);
+       gq_gtk_container_add(GTK_WIDGET(lc->configwindow), win_vbox);
        gtk_widget_show(win_vbox);
 
        hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
@@ -2341,7 +2344,7 @@ void layout_show_config_window(LayoutWindow *lw)
 
        button = pref_button_new(nullptr, GQ_ICON_OK, "OK",
                                 G_CALLBACK(layout_config_ok_cb), lc);
-       gtk_container_add(GTK_CONTAINER(hbox), button);
+       gq_gtk_container_add(GTK_WIDGET(hbox), button);
        gtk_widget_set_can_default(button, TRUE);
        gtk_widget_grab_default(button);
        gtk_widget_show(button);
@@ -2350,25 +2353,25 @@ void layout_show_config_window(LayoutWindow *lw)
 /*
        button = pref_button_new(NULL, GQ_ICON_SAVE, _("Save"), FALSE,
                                 G_CALLBACK(layout_config_save_cb), NULL);
-       gtk_container_add(GTK_CONTAINER(hbox), button);
+       gq_gtk_container_add(GTK_WIDGET(hbox), button);
        GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
        gtk_widget_show(button);
 */
        button = pref_button_new(nullptr, GQ_ICON_HELP, _("Help"),
                                 G_CALLBACK(layout_config_help_cb), lc);
-       gtk_container_add(GTK_CONTAINER(hbox), button);
+       gq_gtk_container_add(GTK_WIDGET(hbox), button);
        gtk_widget_set_can_default(button, TRUE);
        gtk_widget_show(button);
 
        button = pref_button_new(nullptr, GQ_ICON_APPLY, _("Apply"),
                                 G_CALLBACK(layout_config_apply_cb), lc);
-       gtk_container_add(GTK_CONTAINER(hbox), button);
+       gq_gtk_container_add(GTK_WIDGET(hbox), button);
        gtk_widget_set_can_default(button, TRUE);
        gtk_widget_show(button);
 
        button = pref_button_new(nullptr, GQ_ICON_CANCEL, _("Cancel"),
                                 G_CALLBACK(layout_config_close_cb), lc);
-       gtk_container_add(GTK_CONTAINER(hbox), button);
+       gq_gtk_container_add(GTK_WIDGET(hbox), button);
        gtk_widget_set_can_default(button, TRUE);
        gtk_widget_show(button);
 
@@ -2382,7 +2385,7 @@ void layout_show_config_window(LayoutWindow *lw)
 
        vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
        DEBUG_NAME(vbox);
-       gtk_container_add(GTK_CONTAINER(frame), vbox);
+       gq_gtk_container_add(GTK_WIDGET(frame), vbox);
        gtk_widget_show(vbox);
 
 
@@ -2640,7 +2643,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
 
        /* window */
 
-       lw->window = window_new(GTK_WINDOW_TOPLEVEL, GQ_APPNAME_LC, nullptr, nullptr, nullptr);
+       lw->window = window_new(GQ_APPNAME_LC, nullptr, nullptr, nullptr);
        DEBUG_NAME(lw->window);
        gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE);
        gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0);
@@ -2664,7 +2667,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
        if (options->save_window_positions || isfile(default_path))
                {
                gtk_window_set_default_size(GTK_WINDOW(lw->window), lw->options.main_window.w, lw->options.main_window.h);
-               gtk_window_move(GTK_WINDOW(lw->window), lw->options.main_window.x, lw->options.main_window.y);
+               gq_gtk_window_move(GTK_WINDOW(lw->window), lw->options.main_window.x, lw->options.main_window.y);
                if (lw->options.main_window.maximized) gtk_window_maximize(GTK_WINDOW(lw->window));
 
                g_idle_add(move_window_to_workspace_cb, lw);
@@ -2685,7 +2688,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
 
        lw->main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
        DEBUG_NAME(lw->main_box);
-       gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box);
+       gq_gtk_container_add(GTK_WIDGET(lw->window), lw->main_box);
        gtk_widget_show(lw->main_box);
 
        layout_grid_setup(lw);