clang-tidy: readability-non-const-parameter
[geeqie.git] / src / layout.cc
index 0065de5..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);
-               gq_gtk_container_add(GTK_WIDGET(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);
 
@@ -792,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;
@@ -1128,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);
@@ -1532,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;
 
@@ -1545,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;
 }
@@ -1671,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
                        {
@@ -1838,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);
@@ -2259,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)
@@ -2462,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;
@@ -2665,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);
@@ -2806,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);
@@ -2923,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;