Fix #1184: Put main menu items into one hamburger menu
[geeqie.git] / src / collect-io.cc
index cc974c3..e0c1933 100644 (file)
@@ -44,21 +44,25 @@ static CollectManagerEntry *collect_manager_get_entry(const gchar *path);
 static void collect_manager_entry_reset(CollectManagerEntry *entry);
 static gint collect_manager_process_action(CollectManagerEntry *entry, gchar **path_ptr);
 
+namespace
+{
 
-static gboolean scan_geometry(gchar *buffer, gint *x, gint *y, gint *w, gint *h)
+gboolean scan_geometry(gchar *buffer, GdkRectangle &window)
 {
        gint nx, ny, nw, nh;
 
        if (sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE;
 
-       *x = nx;
-       *y = ny;
-       *w = nw;
-       *h = nh;
+       window.x = nx;
+       window.y = ny;
+       window.width = nw;
+       window.height = nh;
 
        return TRUE;
 }
 
+}
+
 static gboolean collection_load_private(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
 {
        gchar s_buf[GQ_COLLECTION_READ_BUFSIZE];
@@ -78,7 +82,6 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C
        guint append = !!(flags & COLLECTION_LOAD_APPEND);
        guint only_geometry = !!(flags & COLLECTION_LOAD_GEOMETRY);
        gboolean reading_extended_filename = FALSE;
-       GString *extended_filename_buffer = g_string_new(nullptr);
        gchar *buffer2;
 
        if (!only_geometry)
@@ -115,6 +118,7 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C
                return FALSE;
                }
 
+       GString *extended_filename_buffer = g_string_new(nullptr);
        while (fgets(s_buf, sizeof(s_buf), f))
                {
                gchar *buf;
@@ -141,7 +145,7 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C
                                        limit_failures = FALSE;
                                        }
                                else if (strncmp(p, "#geometry:", 10 ) == 0 &&
-                                        scan_geometry(p + 10, &cd->window_x, &cd->window_y, &cd->window_w, &cd->window_h))
+                                        scan_geometry(p + 10, cd->window))
                                        {
                                        has_geometry_header = TRUE;
                                        cd->window_read = TRUE;
@@ -198,7 +202,7 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C
                                }
                        }
 
-               if (strlen(extended_filename_buffer->str) > 0)
+               if (extended_filename_buffer->len > 0)
                        {
                        buffer2 = g_strdup(extended_filename_buffer->str);
                        g_string_erase(extended_filename_buffer, 0, -1);
@@ -293,7 +297,7 @@ static void collection_load_thumb_do(CollectionData *cd)
        if (cd->info_updated_func) cd->info_updated_func(cd, cd->thumb_info, cd->info_updated_data);
 }
 
-static void collection_load_thumb_error_cb(ThumbLoader *UNUSED(tl), gpointer data)
+static void collection_load_thumb_error_cb(ThumbLoader *, gpointer data)
 {
        auto cd = static_cast<CollectionData *>(data);
 
@@ -301,7 +305,7 @@ static void collection_load_thumb_error_cb(ThumbLoader *UNUSED(tl), gpointer dat
        collection_load_thumb_step(cd);
 }
 
-static void collection_load_thumb_done_cb(ThumbLoader *UNUSED(tl), gpointer data)
+static void collection_load_thumb_done_cb(ThumbLoader *, gpointer data)
 {
        auto cd = static_cast<CollectionData *>(data);
 
@@ -412,7 +416,7 @@ static gboolean collection_save_private(CollectionData *cd, const gchar *path)
        collection_update_geometry(cd);
        if (cd->window_read)
                {
-               secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window_x, cd->window_y, cd->window_w, cd->window_h);
+               secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window.x, cd->window.y, cd->window.width, cd->window.height);
                }
 
        work = cd->list;
@@ -542,19 +546,7 @@ static void collect_manager_action_unref(CollectManagerAction *action)
 
 static void collect_manager_entry_free_data(CollectManagerEntry *entry)
 {
-       GList *work;
-
-       work = entry->add_list;
-       while (work)
-               {
-               CollectManagerAction *action;
-
-               action = static_cast<CollectManagerAction *>(work->data);
-               work = work->next;
-
-               collect_manager_action_unref(action);
-               }
-       g_list_free(entry->add_list);
+       g_list_free_full(entry->add_list, reinterpret_cast<GDestroyNotify>(collect_manager_action_unref));
        if (g_hash_table_size(entry->oldpath_hash) > 0)
                g_hash_table_destroy(entry->oldpath_hash);
        else
@@ -878,7 +870,7 @@ static gboolean collect_manager_process_entry_list()
 
 
 
-static gboolean collect_manager_process_cb(gpointer UNUSED(data))
+static gboolean collect_manager_process_cb(gpointer)
 {
        if (collection_manager_action_list) collect_manager_refresh();
        collect_manager_process_actions(COLLECT_MANAGER_ACTIONS_PER_IDLE);
@@ -890,7 +882,7 @@ static gboolean collect_manager_process_cb(gpointer UNUSED(data))
        return G_SOURCE_REMOVE;
 }
 
-static gboolean collect_manager_timer_cb(gpointer UNUSED(data))
+static gboolean collect_manager_timer_cb(gpointer)
 {
        DEBUG_1("collection manager timer expired");
 
@@ -995,7 +987,7 @@ void collect_manager_flush()
        while (collect_manager_process_cb(nullptr));
 }
 
-void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer UNUSED(data))
+void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer)
 {
        if (!(type & NOTIFY_CHANGE) || !fd->change) return;
 
@@ -1074,7 +1066,7 @@ void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
                                }
                        if (paths != nullptr)
                                {
-                               *paths = g_list_insert_sorted(*paths,fd->path,
+                               *paths = g_list_insert_sorted(*paths, g_strdup(fd->path),
                                                                                        collection_manager_sort_cb);
                                *paths = g_list_first(*paths);
                                }