Sort headers using clang-tidy
[geeqie.git] / src / pan-view / pan-view.cc
index 15d7237..8db42c2 100644 (file)
 
 #include "pan-view.h"
 
+#include <config.h>
+
 #include "bar-exif.h"
+#include "compat.h"
+#include "debug.h"
 #include "dnd.h"
 #include "editors.h"
 #include "exif.h"
 #include "fullscreen.h"
 #include "image.h"
 #include "img-view.h"
+#include "intl.h"
 #include "layout-util.h"
+#include "main-defines.h"
+#include "main.h"
 #include "menu.h"
 #include "metadata.h"
+#include "misc.h"
 #include "pan-calendar.h"
 #include "pan-folder.h"
 #include "pan-grid.h"
+#include "pan-item.h"
 #include "pan-timeline.h"
 #include "pan-util.h"
 #include "pan-view-filter.h"
 #include "pan-view-search.h"
+#include "pixbuf-renderer.h"
 #include "pixbuf-util.h"
 #include "thumb.h"
 #include "ui-fileops.h"
 #include <cmath>
 
 
-#define PAN_WINDOW_DEFAULT_WIDTH 720
-#define PAN_WINDOW_DEFAULT_HEIGHT 500
+enum {
+       PAN_WINDOW_DEFAULT_WIDTH = 720,
+       PAN_WINDOW_DEFAULT_HEIGHT = 500
+};
 
-#define PAN_TILE_SIZE 512
+enum {
+       PAN_TILE_SIZE = 512
+};
 
 #define ZOOM_INCREMENT 1.0
-#define ZOOM_LABEL_WIDTH 64
+enum {
+       ZOOM_LABEL_WIDTH = 64
+};
 
 
 #define PAN_PREF_GROUP         "pan_view_options"
@@ -333,7 +349,10 @@ static gboolean pan_window_request_tile_cb(PixbufRenderer *pr, gint x, gint y,
 
        for (i = (x / PAN_GRID_SIZE) * PAN_GRID_SIZE; i < x + width; i += PAN_GRID_SIZE)
                {
-               gint rx, ry, rw, rh;
+               gint rx;
+               gint ry;
+               gint rw;
+               gint rh;
 
                if (util_clip_region(x, y, width, height,
                                     i, y, 1, height,
@@ -346,7 +365,10 @@ static gboolean pan_window_request_tile_cb(PixbufRenderer *pr, gint x, gint y,
                }
        for (i = (y / PAN_GRID_SIZE) * PAN_GRID_SIZE; i < y + height; i += PAN_GRID_SIZE)
                {
-               gint rx, ry, rw, rh;
+               gint rx;
+               gint ry;
+               gint rw;
+               gint rh;
 
                if (util_clip_region(x, y, width, height,
                                     x, i, width, 1,
@@ -561,9 +583,9 @@ static gint pan_cache_sort_file_cb(gpointer a, gpointer b)
        auto pcb = static_cast<PanCacheData *>(b);
        return filelist_sort_compare_filedata(pca->fd, pcb->fd);
 }
-GList *pan_cache_sort(GList *list, SortType method, gboolean ascend)
+GList *pan_cache_sort(GList *list, SortType method, gboolean ascend, gboolean case_sensitive)
 {
-       return filelist_sort_full(list, method, ascend, reinterpret_cast<GCompareFunc>(pan_cache_sort_file_cb));
+       return filelist_sort_full(list, method, ascend, case_sensitive, reinterpret_cast<GCompareFunc>(pan_cache_sort_file_cb));
 }
 
 
@@ -595,7 +617,7 @@ static void pan_cache_fill(PanWindow *pw, FileData *dir_fd)
 
        pan_cache_free(pw);
 
-       list = pan_list_tree(dir_fd, SORT_NAME, TRUE, pw->ignore_symlinks);
+       list = pan_list_tree(dir_fd, SORT_NAME, TRUE, TRUE, pw->ignore_symlinks);
        pw->cache_todo = g_list_reverse(list);
 
        pw->cache_total = g_list_length(pw->cache_todo);
@@ -717,10 +739,13 @@ static void pan_grid_clear(PanWindow *pw)
 static void pan_grid_build(PanWindow *pw, gint width, gint height, gint grid_size)
 {
        GList *work;
-       gint col, row;
-       gint cw, ch;
+       gint col;
+       gint row;
+       gint cw;
+       gint ch;
        gint l;
-       gint i, j;
+       gint i;
+       gint j;
 
        pan_grid_clear(pw);
 
@@ -774,7 +799,10 @@ static void pan_grid_build(PanWindow *pw, gint width, gint height, gint grid_siz
                while (grid)
                        {
                        PanGrid *pg;
-                       gint rx, ry, rw, rh;
+                       gint rx;
+                       gint ry;
+                       gint rw;
+                       gint rh;
 
                        pg = static_cast<PanGrid *>(grid->data);
                        grid = grid->next;
@@ -928,7 +956,10 @@ static GList *pan_layout_intersect_l(GList *list, GList *item_list,
        while (work)
                {
                PanItem *pi;
-               gint rx, ry, rw, rh;
+               gint rx;
+               gint ry;
+               gint rw;
+               gint rh;
 
                pi = static_cast<PanItem *>(work->data);
                work = work->next;
@@ -1386,8 +1417,16 @@ void pan_info_update(PanWindow *pw, PanItem *pi)
        PanItem *pbox;
        PanItem *p;
        gchar *buf;
-       gint x1, y1, x2, y2, x3, y3;
-       gint x, y, w, h;
+       gint x1;
+       gint y1;
+       gint x2;
+       gint y2;
+       gint x3;
+       gint y3;
+       gint x;
+       gint y;
+       gint w;
+       gint h;
 
        if (pw->click_pi == pi) return;
        if (pi && !pi->fd) pi = nullptr;
@@ -1457,7 +1496,8 @@ void pan_info_update(PanWindow *pw, PanItem *pi)
 
        if (pw->info_image_size > PAN_IMAGE_SIZE_THUMB_NONE)
                {
-               gint iw, ih;
+               gint iw;
+               gint ih;
                if (image_load_dimensions(pi->fd, &iw, &ih))
                        {
                        gint scale = 25;
@@ -1515,7 +1555,8 @@ static void button_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data)
        auto pw = static_cast<PanWindow *>(data);
        PanItem *pi = nullptr;
        GtkWidget *menu;
-       gint rx, ry;
+       gint rx;
+       gint ry;
 
        rx = ry = 0;
        if (pr->scale)
@@ -1559,7 +1600,8 @@ static void button_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data)
 
 static void scroll_cb(PixbufRenderer *pr, GdkEventScroll *event, gpointer)
 {
-       gint w, h;
+       gint w;
+       gint h;
 
        w = pr->vis_width;
        h = pr->vis_height;
@@ -1658,7 +1700,8 @@ static void pan_window_image_scroll_notify_cb(PixbufRenderer *pr, gpointer data)
        auto pw = static_cast<PanWindow *>(data);
        GtkAdjustment *adj;
        GdkRectangle rect;
-       gint width, height;
+       gint width;
+       gint height;
 
        if (pr->scale == 0.0) return;
 
@@ -1776,7 +1819,7 @@ static void pan_window_close(PanWindow *pw)
        pan_fullscreen_toggle(pw, TRUE);
        pan_search_ui_destroy(&pw->search_ui);
        pan_filter_ui_destroy(&pw->filter_ui);
-       gtk_widget_destroy(pw->window);
+       gq_gtk_widget_destroy(pw->window);
 
        pan_window_items_free(pw);
        pan_cache_free(pw);
@@ -1830,7 +1873,7 @@ static void pan_window_new_real(FileData *dir_fd)
 
        pw->idle_id = 0;
 
-       pw->window = window_new(GTK_WINDOW_TOPLEVEL, "panview", nullptr, nullptr, _("Pan View"));
+       pw->window = window_new("panview", nullptr, nullptr, _("Pan View"));
        DEBUG_NAME(pw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
@@ -1851,7 +1894,7 @@ static void pan_window_new_real(FileData *dir_fd)
        pref_label_new(box, _("Location:"));
        combo = tab_completion_new_with_history(&pw->path_entry, dir_fd->path, "pan_view_path", -1,
                                                pan_window_entry_activate_cb, pw);
-       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 = gtk_combo_box_text_new();
@@ -1864,7 +1907,7 @@ static void pan_window_new_real(FileData *dir_fd)
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), pw->layout);
        g_signal_connect(G_OBJECT(combo), "changed",
                         G_CALLBACK(pan_window_layout_change_cb), pw);
-       gtk_box_pack_start(GTK_BOX(box), combo, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(box), combo, FALSE, FALSE, 0);
        gtk_widget_show(combo);
 
        combo = gtk_combo_box_text_new();
@@ -1882,13 +1925,14 @@ static void pan_window_new_real(FileData *dir_fd)
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), pw->size);
        g_signal_connect(G_OBJECT(combo), "changed",
                         G_CALLBACK(pan_window_layout_size_cb), pw);
-       gtk_box_pack_start(GTK_BOX(box), combo, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(box), combo, FALSE, FALSE, 0);
        gtk_widget_show(combo);
 
        table = pref_table_new(vbox, 2, 2, FALSE, TRUE);
-       gtk_table_set_row_spacings(GTK_TABLE(table), 2);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 2);
+       gtk_grid_set_row_spacing(GTK_GRID(table), 2);
+       gtk_grid_set_column_spacing(GTK_GRID(table), 2);
 
+       pw->imd = image_new(TRUE);
        pw->imd_normal = pw->imd;
 
        g_signal_connect(G_OBJECT(pw->imd->pr), "zoom",
@@ -1896,8 +1940,7 @@ static void pan_window_new_real(FileData *dir_fd)
        g_signal_connect(G_OBJECT(pw->imd->pr), "scroll_notify",
                         G_CALLBACK(pan_window_image_scroll_notify_cb), pw);
 
-       gtk_table_attach(GTK_TABLE(table), pw->imd->widget, 0, 1, 0, 1,
-                        static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), 0, 0);
+       gq_gtk_grid_attach(GTK_GRID(table), pw->imd->widget, 0, 1, 0, 1, static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), 0, 0);
        gtk_widget_show(GTK_WIDGET(pw->imd->widget));
 
        pan_window_dnd_init(pw);
@@ -1907,25 +1950,23 @@ static void pan_window_new_real(FileData *dir_fd)
        pw->scrollbar_h = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, nullptr);
        g_signal_connect(G_OBJECT(pw->scrollbar_h), "value_changed",
                         G_CALLBACK(pan_window_scrollbar_h_value_cb), pw);
-       gtk_table_attach(GTK_TABLE(table), pw->scrollbar_h, 0, 1, 1, 2,
-                        static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), static_cast<GtkAttachOptions>(0), 0, 0);
+       gq_gtk_grid_attach(GTK_GRID(table), pw->scrollbar_h, 0, 1, 1, 2,  static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), static_cast<GtkAttachOptions>(0), 0, 0);
        gtk_widget_show(pw->scrollbar_h);
 
        pw->scrollbar_v = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, nullptr);
        g_signal_connect(G_OBJECT(pw->scrollbar_v), "value_changed",
                         G_CALLBACK(pan_window_scrollbar_v_value_cb), pw);
-       gtk_table_attach(GTK_TABLE(table), pw->scrollbar_v, 1, 2, 0, 1,
-                        static_cast<GtkAttachOptions>(0), static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), 0, 0);
+       gq_gtk_grid_attach(GTK_GRID(table), pw->scrollbar_v, 1, 2, 0, 1,  static_cast<GtkAttachOptions>(0), static_cast<GtkAttachOptions>(GTK_FILL | GTK_EXPAND), 0, 0);
        gtk_widget_show(pw->scrollbar_v);
 
        /* find bar */
 
        pw->search_ui = pan_search_ui_new(pw);
-       gtk_box_pack_start(GTK_BOX(vbox), pw->search_ui->search_box, FALSE, FALSE, 2);
+       gq_gtk_box_pack_start(GTK_BOX(vbox), pw->search_ui->search_box, FALSE, FALSE, 2);
 
     /* filter bar */
     pw->filter_ui = pan_filter_ui_new(pw);
-    gtk_box_pack_start(GTK_BOX(vbox), pw->filter_ui->filter_box, FALSE, FALSE, 2);
+    gq_gtk_box_pack_start(GTK_BOX(vbox), pw->filter_ui->filter_box, FALSE, FALSE, 2);
 
        /* status bar */
 
@@ -1933,9 +1974,9 @@ static void pan_window_new_real(FileData *dir_fd)
 
        frame = gtk_frame_new(nullptr);
        DEBUG_NAME(frame);
-       gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+       gq_gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
        gtk_widget_set_size_request(frame, ZOOM_LABEL_WIDTH, -1);
-       gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
        gtk_widget_show(frame);
 
        hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
@@ -1947,9 +1988,9 @@ static void pan_window_new_real(FileData *dir_fd)
 
        frame = gtk_frame_new(nullptr);
        DEBUG_NAME(frame);
-       gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+       gq_gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
        gtk_widget_set_size_request(frame, ZOOM_LABEL_WIDTH, -1);
-       gtk_box_pack_end(GTK_BOX(box), frame, FALSE, FALSE, 0);
+       gq_gtk_box_pack_end(GTK_BOX(box), frame, FALSE, FALSE, 0);
        gtk_widget_show(frame);
 
        pw->label_zoom = gtk_label_new("");
@@ -1957,11 +1998,11 @@ static void pan_window_new_real(FileData *dir_fd)
        gtk_widget_show(pw->label_zoom);
 
        // Add the "Find" button to the status bar area.
-       gtk_box_pack_end(GTK_BOX(box), pw->search_ui->search_button, FALSE, FALSE, 0);
+       gq_gtk_box_pack_end(GTK_BOX(box), pw->search_ui->search_button, FALSE, FALSE, 0);
        gtk_widget_show(pw->search_ui->search_button);
 
        // Add the "Filter" button to the status bar area.
-       gtk_box_pack_end(GTK_BOX(box), pw->filter_ui->filter_button, FALSE, FALSE, 0);
+       gq_gtk_box_pack_end(GTK_BOX(box), pw->filter_ui->filter_button, FALSE, FALSE, 0);
        gtk_widget_show(pw->filter_ui->filter_button);
 
        g_signal_connect(G_OBJECT(pw->window), "delete_event",
@@ -2008,7 +2049,7 @@ static gboolean pan_warning(FileData *dir_fd)
        GenericDialog *gd;
        GtkWidget *box;
        GtkWidget *group;
-       GtkWidget *button;
+       GtkWidget *checkbox;
        GtkWidget *ct_button;
        gboolean hide_dlg;
 
@@ -2040,9 +2081,9 @@ static gboolean pan_warning(FileData *dir_fd)
 
        ct_button = pref_checkbox_new_int(group, _("Cache thumbnails"),
                                          options->thumbnails.enable_caching, &options->thumbnails.enable_caching);
-       button = pref_checkbox_new_int(group, _("Use shared thumbnail cache"),
+       checkbox = pref_checkbox_new_int(group, _("Use shared thumbnail cache"),
                                       options->thumbnails.spec_standard, &options->thumbnails.spec_standard);
-       pref_checkbox_link_sensitivity(ct_button, button);
+       pref_checkbox_link_sensitivity(ct_button, checkbox);
 
        pref_line(box, 0);
 
@@ -2304,7 +2345,8 @@ static GtkWidget *pan_popup_menu(PanWindow *pw)
        GtkWidget *menu;
        GtkWidget *submenu;
        GtkWidget *item;
-       gboolean active, video;
+       gboolean active;
+       gboolean video;
        GList *editmenu_fd_list;
        GtkAccelGroup *accel_group;