clang-tidy: readability-non-const-parameter
[geeqie.git] / src / layout.cc
index ff675f7..43c6bf5 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 "ui-utildlg.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)
@@ -321,29 +323,37 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
 {
        GtkWidget *box;
        GtkWidget *box_folders;
-       GtkWidget *scd;
+       GtkWidget *box_menu_tabcomp;
+       GtkWidget *menu_bar;
        GtkWidget *menu_tool_bar;
+       GtkWidget *menu_toolbar_box;
+       GtkWidget *open_menu;
+       GtkWidget *scd;
+       GtkWidget *scroll_window;
        GtkWidget *tabcomp;
-       GtkWidget *menu_bar;
        GtkWidget *toolbar;
-       GtkWidget *scroll_window;
 
        box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 
        if (!options->expand_menu_toolbar)
                {
-               menu_bar = layout_actions_menu_bar(lw);
-
-               toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN);
+               menu_toolbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
                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);
+               gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
 
-               gtk_widget_show(scroll_window);
-               gtk_widget_show(menu_bar);
+               if (!options->hamburger_menu)
+                       {
+                       menu_bar = layout_actions_menu_bar(lw);
+                       gq_gtk_box_pack_start(GTK_BOX(menu_toolbar_box), menu_bar, FALSE, FALSE, 0);
+                       }
 
+               toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN);
+
+               gq_gtk_box_pack_start(GTK_BOX(menu_toolbar_box), toolbar, FALSE, FALSE, 0);
+               gq_gtk_container_add(GTK_WIDGET(scroll_window), menu_toolbar_box);
                gq_gtk_box_pack_start(GTK_BOX(box), scroll_window, FALSE, FALSE, 0);
-               gq_gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0);
+
+               gtk_widget_show_all(scroll_window);
                }
        else
                {
@@ -353,18 +363,32 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
                gq_gtk_box_pack_start(GTK_BOX(lw->main_box), lw->menu_tool_bar, FALSE, FALSE, 0);
                }
 
-       tabcomp = tab_completion_new_with_history(&lw->path_entry, nullptr, "path_list", -1,
-                                                 layout_path_entry_cb, lw);
+       tabcomp = tab_completion_new_with_history(&lw->path_entry, nullptr, "path_list", -1, layout_path_entry_cb, lw);
        DEBUG_NAME(tabcomp);
        tab_completion_add_tab_func(lw->path_entry, layout_path_entry_tab_cb, lw);
        tab_completion_add_append_func(lw->path_entry, layout_path_entry_tab_append_cb, lw);
-       gq_gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0);
+
+       if (options->hamburger_menu)
+               {
+               box_menu_tabcomp = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+               gtk_widget_show(box_menu_tabcomp);
+
+               open_menu = layout_actions_menu_bar(lw);
+               gtk_widget_set_tooltip_text(open_menu, "Open application menu");
+               gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), open_menu, FALSE, FALSE, 0);
+               gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), tabcomp, TRUE, TRUE, 0);
+               gq_gtk_box_pack_start(GTK_BOX(box), box_menu_tabcomp, FALSE, FALSE, 0);
+               }
+       else
+               {
+               gq_gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0);
+               }
+
        gtk_widget_show(tabcomp);
        gtk_widget_set_has_tooltip(GTK_WIDGET(tabcomp), TRUE);
        g_signal_connect(G_OBJECT(tabcomp), "query_tooltip", G_CALLBACK(path_entry_tooltip_cb), lw);
 
-       g_signal_connect(G_OBJECT(gtk_widget_get_parent(gtk_widget_get_parent(lw->path_entry))), "changed",
-                        G_CALLBACK(layout_path_entry_changed_cb), lw);
+       g_signal_connect(G_OBJECT(gtk_widget_get_parent(gtk_widget_get_parent(lw->path_entry))), "changed", G_CALLBACK(layout_path_entry_changed_cb), lw);
 
        box_folders = GTK_WIDGET(gtk_paned_new(GTK_ORIENTATION_HORIZONTAL));
        DEBUG_NAME(box_folders);
@@ -386,8 +410,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw)
 
        gtk_widget_show(box_folders);
 
-       g_signal_connect(G_OBJECT(box_folders), "notify::position",
-                        G_CALLBACK(layout_box_folders_changed_cb), lw);
+       g_signal_connect(G_OBJECT(box_folders), "notify::position", G_CALLBACK(layout_box_folders_changed_cb), lw);
 
        gtk_widget_show(box);
 
@@ -487,7 +510,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 +609,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;
@@ -791,7 +815,7 @@ void layout_status_update_all(LayoutWindow *lw)
        layout_util_status_update_write(lw);
 }
 
-static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand)
+static GtkWidget *layout_status_label(const gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand)
 {
        GtkWidget *label;
        GtkWidget *frame;
@@ -812,7 +836,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 +907,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 +1151,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);
@@ -1531,8 +1555,7 @@ gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w,
        return TRUE;
 }
 
-gboolean layout_geometry_get_log_window(LayoutWindow *lw, gint *x, gint *y,
-                                                                                                               gint *w, gint *h)
+static gboolean layout_geometry_get_log_window(LayoutWindow *lw, GdkRectangle &log_window)
 {
        GdkWindow *window;
 
@@ -1544,9 +1567,9 @@ gboolean layout_geometry_get_log_window(LayoutWindow *lw, gint *x, gint *y,
                }
 
        window = gtk_widget_get_window(lw->log_window);
-       gdk_window_get_root_origin(window, x, y);
-       *w = gdk_window_get_width(window);
-       *h = gdk_window_get_height(window);
+       gdk_window_get_root_origin(window, &log_window.x, &log_window.y);
+       log_window.width = gdk_window_get_width(window);
+       log_window.height = gdk_window_get_height(window);
 
        return TRUE;
 }
@@ -1608,7 +1631,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 +1671,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 +1693,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
                        {
@@ -1837,7 +1860,8 @@ static void layout_grid_setup(LayoutWindow *lw)
 
                return;
                }
-       else if (lw->tools)
+
+       if (lw->tools)
                {
                layout_tools_geometry_sync(lw);
                gq_gtk_widget_destroy(lw->tools);
@@ -2258,7 +2282,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 +2341,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 +2354,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 +2365,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 +2374,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 +2406,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);
 
 
@@ -2461,8 +2485,7 @@ void layout_sync_options_with_current_state(LayoutWindow *lw)
        g_free(lw->options.last_path);
        lw->options.last_path = g_strdup(layout_get_path(lw));
 
-       layout_geometry_get_log_window(lw, &lw->options.log_window.x, &lw->options.log_window.y,
-                                        &lw->options.log_window.w, &lw->options.log_window.h);
+       layout_geometry_get_log_window(lw, lw->options.log_window);
 
 #ifdef GDK_WINDOWING_X11
        GdkDisplay *display;
@@ -2640,7 +2663,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 +2687,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 +2708,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);
@@ -2805,8 +2828,8 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
 
        WRITE_NL(); WRITE_INT(*layout, log_window.x);
        WRITE_NL(); WRITE_INT(*layout, log_window.y);
-       WRITE_NL(); WRITE_INT(*layout, log_window.w);
-       WRITE_NL(); WRITE_INT(*layout, log_window.h);
+       WRITE_NL(); WRITE_INT(*layout, log_window.width);
+       WRITE_NL(); WRITE_INT(*layout, log_window.height);
 
        WRITE_NL(); WRITE_INT(*layout, preferences_window.x);
        WRITE_NL(); WRITE_INT(*layout, preferences_window.y);
@@ -2922,8 +2945,8 @@ void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names
 
                if (READ_INT(*layout, log_window.x)) continue;
                if (READ_INT(*layout, log_window.y)) continue;
-               if (READ_INT(*layout, log_window.w)) continue;
-               if (READ_INT(*layout, log_window.h)) continue;
+               if (READ_INT(*layout, log_window.width)) continue;
+               if (READ_INT(*layout, log_window.height)) continue;
 
                if (READ_INT(*layout, preferences_window.x)) continue;
                if (READ_INT(*layout, preferences_window.y)) continue;