clang-tidy: readability-isolate-declaration
[geeqie.git] / src / collect.cc
index 8d68bcd..0138d29 100644 (file)
 #include "utilops.h"
 #include "window.h"
 
-#define COLLECT_DEF_WIDTH 440
-#define COLLECT_DEF_HEIGHT 450
+enum {
+       COLLECT_DEF_WIDTH = 440,
+       COLLECT_DEF_HEIGHT = 450
+};
 
 /**
  *  list of paths to collections */
@@ -180,8 +182,8 @@ static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
 
        if (options->file_sort.case_sensitive)
                return strcmp(cia->fd->collate_key_name, cib->fd->collate_key_name);
-       else
-               return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
+
+       return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
 }
 
 GList *collection_list_sort(GList *list, SortType method)
@@ -195,9 +197,12 @@ GList *collection_list_sort(GList *list, SortType method)
 
 GList *collection_list_randomize(GList *list)
 {
-       guint random, length, i;
+       guint random;
+       guint length;
+       guint i;
        gpointer tmp;
-       GList *nlist, *olist;
+       GList *nlist;
+       GList *olist;
 
        length = g_list_length(list);
        if (!length) return nullptr;
@@ -396,7 +401,7 @@ void collection_contents(const gchar *name, GString **contents)
                        {
                        ci = static_cast<CollectInfo *>(work->data);
                        fd = ci->fd;
-                       *contents = g_string_append(*contents, g_strdup(fd->path));
+                       *contents = g_string_append(*contents, fd->path);
                        *contents = g_string_append(*contents, "\n");
 
                        work = work->next;
@@ -455,8 +460,8 @@ CollectionData *collection_new(const gchar *path)
 
        cd->ref = 1;    /* starts with a ref of 1 */
        cd->sort_method = SORT_NONE;
-       cd->window_w = COLLECT_DEF_WIDTH;
-       cd->window_h = COLLECT_DEF_HEIGHT;
+       cd->window.width = COLLECT_DEF_WIDTH;
+       cd->window.height = COLLECT_DEF_HEIGHT;
        cd->existence = g_hash_table_new(nullptr, nullptr);
 
        if (path)
@@ -575,8 +580,8 @@ CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList
                while (*ptr != '\n' && *ptr != '\0') ptr++;
                if (*ptr == '\0')
                        break;
-               else
-                       while (*ptr == '\n') ptr++;
+
+               while (*ptr == '\n') ptr++;
 
                info = static_cast<CollectInfo *>(g_list_nth_data(cd->list, item_number));
                if (!info) continue;
@@ -1088,9 +1093,9 @@ static void collection_window_get_geometry(CollectWindow *cw)
 
        cd = cw->cd;
        window = gtk_widget_get_window(cw->window);
-       gdk_window_get_position(window, &cd->window_x, &cd->window_y);
-       cd->window_w = gdk_window_get_width(window);
-       cd->window_h = gdk_window_get_height(window);
+       gdk_window_get_position(window, &cd->window.x, &cd->window.y);
+       cd->window.width = gdk_window_get_width(window);
+       cd->window.height = gdk_window_get_height(window);
        cd->window_read = TRUE;
 }
 
@@ -1171,7 +1176,7 @@ static void collection_window_close_final(CollectWindow *cw)
        collection_window_list = g_list_remove(collection_window_list, cw);
        collection_window_get_geometry(cw);
 
-       gtk_widget_destroy(cw->window);
+       gq_gtk_widget_destroy(cw->window);
 
        collection_set_update_info_func(cw->cd, nullptr, nullptr);
        collection_unref(cw->cd);
@@ -1191,7 +1196,8 @@ static void collection_close_save_cb(GenericDialog *gd, gpointer data)
                collection_dialog_save_close(cw->cd);
                return;
                }
-       else if (!collection_save(cw->cd, cw->cd->path))
+
+       if (!collection_save(cw->cd, cw->cd->path))
                {
                gchar *buf;
                buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
@@ -1330,7 +1336,7 @@ CollectWindow *collection_window_new(const gchar *path)
 
        cw->cd = collection_new(path);
 
-       cw->window = window_new(GTK_WINDOW_TOPLEVEL, "collection", PIXBUF_INLINE_ICON_BOOK, nullptr, nullptr);
+       cw->window = window_new("collection", PIXBUF_INLINE_ICON_BOOK, nullptr, nullptr);
        DEBUG_NAME(cw->window);
 
        geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
@@ -1342,13 +1348,13 @@ CollectWindow *collection_window_new(const gchar *path)
 
        if (options->collections_on_top)
                {
-               gtk_window_set_keep_above(GTK_WINDOW(cw->window), TRUE);
+               gq_gtk_window_set_keep_above(GTK_WINDOW(cw->window), TRUE);
                }
 
        if (options->save_window_positions && path && collection_load_only_geometry(cw->cd, path))
                {
-               gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window_w, cw->cd->window_h);
-               gtk_window_move(GTK_WINDOW(cw->window), cw->cd->window_x, cw->cd->window_y);
+               gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window.width, cw->cd->window.height);
+               gq_gtk_window_move(GTK_WINDOW(cw->window), cw->cd->window.x, cw->cd->window.y);
                }
        else
                {
@@ -1366,25 +1372,25 @@ CollectWindow *collection_window_new(const gchar *path)
                         G_CALLBACK(collection_window_keypress), cw);
 
        vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-       gtk_container_add(GTK_CONTAINER(cw->window), vbox);
+       gq_gtk_container_add(GTK_WIDGET(cw->window), vbox);
        gtk_widget_show(vbox);
 
        cw->table = collection_table_new(cw->cd);
-       gtk_box_pack_start(GTK_BOX(vbox), cw->table->scrolled, TRUE, TRUE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(vbox), cw->table->scrolled, TRUE, TRUE, 0);
        gtk_widget_show(cw->table->scrolled);
 
        cw->status_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-       gtk_box_pack_start(GTK_BOX(vbox), cw->status_box, FALSE, FALSE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(vbox), cw->status_box, FALSE, FALSE, 0);
        gtk_widget_show(cw->status_box);
 
        frame = gtk_frame_new(nullptr);
        DEBUG_NAME(frame);
-       gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
-       gtk_box_pack_start(GTK_BOX(cw->status_box), frame, TRUE, TRUE, 0);
+       gq_gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+       gq_gtk_box_pack_start(GTK_BOX(cw->status_box), frame, TRUE, TRUE, 0);
        gtk_widget_show(frame);
 
        status_label = gtk_label_new("");
-       gtk_container_add(GTK_CONTAINER(frame), status_label);
+       gq_gtk_container_add(GTK_WIDGET(frame), status_label);
        gtk_widget_show(status_label);
 
        extra_label = gtk_progress_bar_new();
@@ -1392,7 +1398,7 @@ CollectWindow *collection_window_new(const gchar *path)
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(extra_label), "");
        gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(extra_label), TRUE);
 
-       gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
+       gq_gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
        gtk_widget_show(extra_label);
 
        collection_table_set_labels(cw->table, status_label, extra_label);