clang-tidy: readability-misleading-indentation
[geeqie.git] / src / image-load-collection.cc
index 34d7550..ad1af91 100644 (file)
 #include "image-load-collection.h"
 
 #include "cache.h"
+#include "filedata.h"
 #include "misc.h"
 #include "ui-fileops.h"
 
-typedef struct _ImageLoaderCOLLECTION ImageLoaderCOLLECTION;
-struct _ImageLoaderCOLLECTION {
+struct ImageLoaderCOLLECTION {
        ImageLoaderBackendCbAreaUpdated area_updated_cb;
        ImageLoaderBackendCbSize size_cb;
        ImageLoaderBackendCbAreaPrepared area_prepared_cb;
@@ -38,7 +38,7 @@ struct _ImageLoaderCOLLECTION {
        gboolean abort;
 };
 
-static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUSED(buf), gsize UNUSED(count), GError **UNUSED(error))
+static gboolean image_loader_collection_load(gpointer loader, const guchar *, gsize, GError **)
 {
        auto ld = static_cast<ImageLoaderCOLLECTION *>(loader);
        auto il = static_cast<ImageLoader *>(ld->data);
@@ -48,11 +48,11 @@ static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUS
        gboolean ret = FALSE;
        gchar *randname;
        gchar *cmd_line;
-       FILE *fp = NULL;
+       FILE *fp = nullptr;
        gint line_count = 0;
-       GString *file_names = g_string_new(NULL);
+       GString *file_names = g_string_new(nullptr);
        gchar line[LINE_LENGTH];
-       gchar **split_line = NULL;
+       gchar **split_line = nullptr;
        gchar *cache_found;
        gchar *pathl;
 
@@ -71,7 +71,7 @@ static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUS
                                        cache_found = cache_find_location(CACHE_TYPE_THUMB, split_line[1]);
                                        if (cache_found)
                                                {
-                                               file_names = g_string_append(file_names, g_strconcat("\"", cache_found,"\" ", NULL));
+                                               g_string_append_printf(file_names, "\"%s\" ", cache_found);
                                                line_count++;
                                                }
                                        g_free(cache_found);
@@ -80,7 +80,7 @@ static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUS
                                                {
                                                g_strfreev(split_line);
                                                }
-                                       split_line = NULL;
+                                       split_line = nullptr;
                                }
                        fclose(fp);
 
@@ -92,7 +92,7 @@ static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUS
                                cmd_line = g_strdup_printf("montage %s -geometry %dx%d+1+1 %s >/dev/null 2>&1", file_names->str, options->thumbnails.max_width, options->thumbnails.max_height, randname);
 
                                runcmd(cmd_line);
-                               ld->pixbuf = gdk_pixbuf_new_from_file(randname, NULL);
+                               ld->pixbuf = gdk_pixbuf_new_from_file(randname, nullptr);
                                if (ld->pixbuf)
                                        {
                                        ld->area_updated_cb(loader, 0, 0, gdk_pixbuf_get_width(ld->pixbuf), gdk_pixbuf_get_height(ld->pixbuf), ld->data);
@@ -100,15 +100,12 @@ static gboolean image_loader_collection_load(gpointer loader, const guchar *UNUS
 
                                unlink(randname);
                                g_free(randname);
-                               g_string_free(file_names, TRUE);
                                g_free(cmd_line);
 
                                ret = TRUE;
                                }
-                       else
-                               {
-                               g_string_free(file_names, TRUE);
-                               }
+
+                       g_string_free(file_names, TRUE);
                        }
                }
        return ret;
@@ -137,17 +134,17 @@ static GdkPixbuf* image_loader_collection_get_pixbuf(gpointer loader)
        return ld->pixbuf;
 }
 
-static gchar* image_loader_collection_get_format_name(gpointer UNUSED(loader))
+static gchar* image_loader_collection_get_format_name(gpointer)
 {
        return g_strdup("collection");
 }
-static gchar** image_loader_collection_get_format_mime_types(gpointer UNUSED(loader))
+static gchar** image_loader_collection_get_format_mime_types(gpointer)
 {
-       static const gchar *mime[] = {"image/png", NULL};
+       static const gchar *mime[] = {"image/png", nullptr};
        return g_strdupv(const_cast<gchar **>(mime));
 }
 
-static gboolean image_loader_collection_close(gpointer UNUSED(loader), GError **UNUSED(error))
+static gboolean image_loader_collection_close(gpointer, GError **)
 {
        return TRUE;
 }
@@ -170,7 +167,7 @@ void image_loader_backend_set_collection(ImageLoaderBackend *funcs)
        funcs->loader_new = image_loader_collection_new;
        funcs->set_size = image_loader_collection_set_size;
        funcs->load = image_loader_collection_load;
-       funcs->write = NULL;
+       funcs->write = nullptr;
        funcs->get_pixbuf = image_loader_collection_get_pixbuf;
        funcs->close = image_loader_collection_close;
        funcs->abort = image_loader_collection_abort;