Use flags for collection_load*().
authorLaurent Monin <geeqie@norz.org>
Mon, 14 Apr 2008 22:05:47 +0000 (22:05 +0000)
committerLaurent Monin <geeqie@norz.org>
Mon, 14 Apr 2008 22:05:47 +0000 (22:05 +0000)
src/collect-io.c
src/collect-io.h
src/collect.c
src/img-view.c
src/main.c

index 7e8104f..0417969 100644 (file)
@@ -51,7 +51,7 @@ static gint scan_geometry(gchar *buffer, gint *x, gint *y, gint *w, gint *h)
        return TRUE;
 }
 
-static gint collection_load_private(CollectionData *cd, const gchar *path, gint append, gint flush)
+static gint collection_load_private(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
 {
        gchar s_buf[2048];
        FILE *f;
@@ -62,6 +62,8 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, gint
        guint fail = 0;
        gboolean changed = FALSE;
        CollectManagerEntry *entry = NULL;
+       guint flush = flags & COLLECTION_LOAD_FLUSH;
+       guint append = flags & COLLECTION_LOAD_APPEND;
 
        collection_load_stop(cd);
 
@@ -165,9 +167,9 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, gint
        return success;
 }
 
-gint collection_load(CollectionData *cd, const gchar *path, gint append)
+gint collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
 {
-       if (collection_load_private(cd, path, append, TRUE))
+       if (collection_load_private(cd, path, flags | COLLECTION_LOAD_FLUSH))
                {
                layout_recent_add_path(cd->path);
                return TRUE;
@@ -262,9 +264,9 @@ void collection_load_thumb_idle(CollectionData *cd)
        if (!cd->thumb_loader) collection_load_thumb_step(cd);
 }
 
-gint collection_load_begin(CollectionData *cd, const gchar *path, gint append)
+gint collection_load_begin(CollectionData *cd, const gchar *path, CollectionLoadFlags flags)
 {
-       if (!collection_load(cd, path, append)) return FALSE;
+       if (!collection_load(cd, path, flags)) return FALSE;
 
        collection_load_thumb_idle(cd);
 
@@ -782,7 +784,7 @@ static gint collect_manager_process_entry(CollectManagerEntry *entry)
        if (entry->empty) return FALSE;
 
        cd = collection_new(entry->path);
-       success = collection_load_private(cd, entry->path, FALSE, FALSE);
+       success = collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE);
 
        collection_unref(cd);
 
index bf6c741..7bf66b1 100644 (file)
 #ifndef COLLECT_IO_H
 #define COLLECT_IO_H
 
+typedef enum {
+       COLLECTION_LOAD_NONE    = 0,
+       COLLECTION_LOAD_APPEND  = 1 << 0,
+       COLLECTION_LOAD_FLUSH   = 1 << 1,
+} CollectionLoadFlags;
 
-gint collection_load(CollectionData *cd, const gchar *path, gint append);
+gint collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags);
 
-gint collection_load_begin(CollectionData *cd, const gchar *path, gint append);
+gint collection_load_begin(CollectionData *cd, const gchar *path, CollectionLoadFlags flags);
 void collection_load_stop(CollectionData *cd);
 
 void collection_load_thumb_idle(CollectionData *cd);
index de2588e..cc3fe0d 100644 (file)
@@ -1251,7 +1251,7 @@ CollectWindow *collection_window_new(const gchar *path)
 
        collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
 
-       if (path && *path == '/') collection_load_begin(cw->cd, NULL, FALSE);
+       if (path && *path == '/') collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
 
        return cw;
 }
index afc7b45..c93dfb0 100644 (file)
@@ -950,7 +950,7 @@ void view_window_new(FileData *fd)
                CollectInfo *info;
 
                cd = collection_new(fd->path);
-               if (collection_load(cd, fd->path, FALSE))
+               if (collection_load(cd, fd->path, COLLECTION_LOAD_NONE))
                        {
                        info = collection_get_first(cd);
                        }
index 21d3e30..e8b4601 100644 (file)
@@ -1447,7 +1447,7 @@ int main (int argc, char *argv[])
                work = collection_list;
                while (work)
                        {
-                       collection_load(cd, (gchar *)work->data, TRUE);
+                       collection_load(cd, (gchar *)work->data, COLLECTION_LOAD_APPEND);
                        work = work->next;
                        }