changeset 359:96fb24f948b7

Merge collection_load_only_geometry() into collection_load().
author zas_
date Mon, 14 Apr 2008 22:28:29 +0000
parents 384eed18df04
children 822040a51249
files src/collect-io.c src/collect-io.h
diffstat 2 files changed, 22 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/collect-io.c	Mon Apr 14 22:05:47 2008 +0000
+++ b/src/collect-io.c	Mon Apr 14 22:28:29 2008 +0000
@@ -64,18 +64,22 @@
 	CollectManagerEntry *entry = NULL;
 	guint flush = flags & COLLECTION_LOAD_FLUSH;
 	guint append = flags & COLLECTION_LOAD_APPEND;
+	guint only_geometry = flags & COLLECTION_LOAD_GEOMETRY;
 
-	collection_load_stop(cd);
+	if (!only_geometry)
+		{
+		collection_load_stop(cd);
 
-	if (flush) 
-		collect_manager_flush();
-	else
-		entry = collect_manager_get_entry(path);
+		if (flush)
+			collect_manager_flush();
+		else
+			entry = collect_manager_get_entry(path);
 
-	if (!append)
-		{
-		collection_list_free(cd->list);
-		cd->list = NULL;
+		if (!append)
+			{
+			collection_list_free(cd->list);
+			cd->list = NULL;
+			}
 		}
 
 	if (!path && !cd->path) return FALSE;
@@ -110,6 +114,11 @@
 			    scan_geometry(s_buf + 10, &cd->window_x, &cd->window_y, &cd->window_w, &cd->window_h) )
 				{
 				cd->window_read = TRUE;
+				if (only_geometry)
+					{
+					fclose(f);
+					return TRUE;
+					}
 				}
 			continue;
 			}
@@ -142,7 +151,8 @@
 		}
 
 	fclose(f);
-	
+	if (only_geometry) return FALSE;
+
 	if (!flush)
 		{
 		gchar *buf = NULL;
@@ -369,33 +379,7 @@
 
 gint collection_load_only_geometry(CollectionData *cd, const gchar *path)
 {
-	gchar s_buf[2048];
-	FILE *f;
-	gchar *pathl;
-
-	if (!path && !cd->path) return FALSE;
-
-	if (!path) path = cd->path;
-
-	/* load it */
-	pathl = path_from_utf8(path);
-	f = fopen(pathl, "r");
-	g_free(pathl);
-	if (!f) return FALSE;
-
-	while (fgets(s_buf, sizeof(s_buf), f))
-		{
-		if (s_buf[0]=='#' &&
-		    strncmp(s_buf, "#geometry:", 10 ) == 0 &&
-		    scan_geometry(s_buf + 10, &cd->window_x, &cd->window_y, &cd->window_w, &cd->window_h) )
-			{
-			cd->window_read = TRUE;
-			fclose(f);
-			return TRUE;
-			}
-		}
-	fclose(f);
-	return FALSE;
+	return collection_load(cd, path, COLLECTION_LOAD_GEOMETRY);
 }
 
 
--- a/src/collect-io.h	Mon Apr 14 22:05:47 2008 +0000
+++ b/src/collect-io.h	Mon Apr 14 22:28:29 2008 +0000
@@ -17,6 +17,7 @@
 	COLLECTION_LOAD_NONE	= 0,
 	COLLECTION_LOAD_APPEND	= 1 << 0,
 	COLLECTION_LOAD_FLUSH	= 1 << 1,
+	COLLECTION_LOAD_GEOMETRY= 1 << 2,
 } CollectionLoadFlags;
 
 gint collection_load(CollectionData *cd, const gchar *path, CollectionLoadFlags flags);