changeset 495:c7a2471e5c4e

Introduce macros to display debug messages. if (debug) printf(...) is now replaced by variadic macros: DEBUG_1() And for higher debugging levels: DEBUG_2() DEBUG_3() DEBUG_4()
author zas_
date Wed, 23 Apr 2008 20:47:19 +0000
parents 3bb9a8df6ee9
children a1f13fab6686
files src/bar_info.c src/cache.c src/cache_maint.c src/collect-io.c src/collect-table.c src/collect.c src/color-man.c src/dupe.c src/exif-common.c src/exiv2.cc src/filelist.c src/format_raw.c src/fullscreen.c src/image-load.c src/image.c src/layout.c src/layout_image.c src/main.c src/main.h src/pan-calendar.c src/pan-view.c src/pixbuf-renderer.c src/print.c src/remote.c src/secure_save.c src/thumb.c src/thumb_standard.c src/utilops.c src/view_file_icon.c src/view_file_list.c
diffstat 30 files changed, 154 insertions(+), 167 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_info.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/bar_info.c	Wed Apr 23 20:47:19 2008 +0000
@@ -111,7 +111,7 @@
 		{
 		gchar *comment_pathl;
 
-		if (debug) printf("Saving comment: %s\n", comment_path);
+		DEBUG_1("Saving comment: %s\n", comment_path);
 
 		comment_pathl = path_from_utf8(comment_path);
 
--- a/src/cache.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/cache.c	Wed Apr 23 20:47:19 2008 +0000
@@ -457,7 +457,7 @@
 	if (fread(&buf, sizeof(char), 9, f) != 9 ||
 	    strncmp(buf, "SIMcache", 8) != 0)
 		{
-		if (debug) printf("%s is not a cache file\n", cd->path);
+		DEBUG_1("%s is not a cache file\n", cd->path);
 		success = 0;
 		}
 
@@ -601,7 +601,7 @@
 					}
 				if (!isdir(path))
 					{
-					if (debug) printf("creating sub dir:%s\n", path);
+					DEBUG_1("creating sub dir:%s\n", path);
 					if (!mkdir_utf8(path, mode))
 						{
 						printf("create dir failed: %s\n", path);
@@ -770,7 +770,7 @@
 			if (utime(cachel, &ut) < 0 &&
 			    errno == EPERM)
 				{
-				if (debug) printf("cache permission workaround: %s\n", cachel);
+				DEBUG_1("cache permission workaround: %s\n", cachel);
 				ret = TRUE;
 				}
 			}
--- a/src/cache_maint.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/cache_maint.c	Wed Apr 23 20:47:19 2008 +0000
@@ -155,7 +155,7 @@
 
 	if (!cm->list)
 		{
-		if (debug) printf("purge chk done.\n");
+		DEBUG_1("purge chk done.\n");
 		cm->idle_id = -1;
 		cache_maintain_home_stop(cm);
 		return FALSE;
@@ -163,7 +163,7 @@
 
 	path = cm->list->data;
 
-	if (debug) printf("purge chk (%d) \"%s\"\n", (cm->clear && !cm->metadata), path);
+	DEBUG_1("purge chk (%d) \"%s\"\n", (cm->clear && !cm->metadata), path);
 
 	if (g_list_find(cm->done_list, path) == NULL)
 		{
@@ -357,7 +357,7 @@
 	GList *flist = NULL;
 	gint still_have_a_file = FALSE;
 
-	if (debug) printf("maintainance check: %s\n", dir);
+	DEBUG_1("maintainance check: %s\n", dir);
 
 	base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
 	base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
@@ -373,7 +373,7 @@
 			if (recursive && strlen(path) > base_length &&
 			    !cache_maintain_home_dir(path + base_length, recursive, clear))
 				{
-				if (debug) printf("Deleting thumb dir: %s\n", path);
+				DEBUG_1("Deleting thumb dir: %s\n", path);
 				if (!rmdir_utf8(path))
 					{
 					printf("Unable to delete dir: %s\n", path);
@@ -454,7 +454,7 @@
 				{
 				if (!unlink_file(path))
 					{
-					if (debug) printf("Failed to remove cache file %s\n", path);
+					DEBUG_1("Failed to remove cache file %s\n", path);
 					still_have_a_file = TRUE;
 					}
 				}
@@ -495,7 +495,7 @@
 
 	if (!move_file(src, dest))
 		{
-		if (debug) printf("Failed to move cache file %s\nto %s\n", src, dest);
+		DEBUG_1("Failed to move cache file %s\nto %s\n", src, dest);
 		/* we remove it anyway - it's stale */
 		unlink_file(src);
 		}
@@ -556,7 +556,7 @@
 {
 	if (path && isfile(path) && !unlink_file(path))
 		{
-		if (debug) printf("Failed to remove cache file %s\n", path);
+		DEBUG_1("Failed to remove cache file %s\n", path);
 		}
 }
 
@@ -597,7 +597,7 @@
 		path = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, TRUE, NULL);
 		if (!copy_file(src_cache, path))
 			{
-			if (debug) printf("failed to copy metadata %s to %s\n", src_cache, path);
+			DEBUG_1("failed to copy metadata %s to %s\n", src_cache, path);
 			}
 		g_free(path);
 		}
@@ -928,7 +928,7 @@
 		next_path = cd->list->data;
 		cd->list = g_list_remove(cd->list, next_path);
 
-		if (debug) printf("thumb removed: %s\n", next_path);
+		DEBUG_1("thumb removed: %s\n", next_path);
 
 		unlink_file(next_path);
 		g_free(next_path);
@@ -956,7 +956,7 @@
 		{
 		if (!valid)
 			{
-			if (debug) printf("thumb cleaned: %s\n", path);
+			DEBUG_1("thumb cleaned: %s\n", path);
 			unlink_file(path);
 			}
 
--- a/src/collect-io.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/collect-io.c	Wed Apr 23 20:47:19 2008 +0000
@@ -92,7 +92,7 @@
 
 	if (!path) path = cd->path;
 
-	if (debug) printf("collection load: append=%d flush=%d only_geometry=%d path=%s\n",
+	DEBUG_1("collection load: append=%d flush=%d only_geometry=%d path=%s\n",
 			  append, flush, only_geometry, path);
 
 	/* load it */
@@ -156,7 +156,7 @@
 				changed |= collect_manager_process_action(entry, &buf);
 
 			valid = (buf[0] == '/' && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
-			if (debug && !valid) printf("collection invalid file: %s\n", buf);
+			if (!valid) DEBUG_1("collection invalid file: %s\n", buf);
 			g_free(buf);
 
 			total++;
@@ -175,7 +175,7 @@
 			}
 		}
 
-	if (debug) printf("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d\n",
+	DEBUG_1("collection files: total = %d fail = %d official=%d gqview=%d geometry=%d\n",
 			  total, fail, has_official_header, has_gqview_header, has_geometry_header);
 
 	fclose(f);
@@ -292,7 +292,7 @@
 	if (!thumb_loader_start(cd->thumb_loader, ci->fd->path))
 		{
 		/* error, handle it, do next */
-		if (debug) printf("error loading thumb for %s\n", ci->fd->path);
+		DEBUG_1("error loading thumb for %s\n", ci->fd->path);
 		collection_load_thumb_do(cd);
 		collection_load_thumb_step(cd);
 		}
@@ -721,11 +721,8 @@
 
 static void collect_manager_process_actions(gint max)
 {
-	if (debug && collection_manager_action_list)
-		{
-		printf("collection manager processing actions\n");
-		}
-
+	if (collection_manager_action_list) DEBUG_1("collection manager processing actions\n");
+	
 	while (collection_manager_action_list != NULL && max > 0)
 		{
 		CollectManagerAction *action;
@@ -823,13 +820,13 @@
 
 	if (collect_manager_process_entry_list()) return TRUE;
 
-	if (debug) printf("collection manager is up to date\n");
+	DEBUG_1("collection manager is up to date\n");
 	return FALSE;
 }
 
 static gint collect_manager_timer_cb(gpointer data)
 {
-	if (debug) printf("collection manager timer expired\n");
+	DEBUG_1("collection manager timer expired\n");
 
 	g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, NULL, NULL);
 
@@ -851,7 +848,7 @@
 		{
 		collection_manager_timer_id = g_timeout_add(COLLECT_MANAGER_FLUSH_DELAY,
 							    collect_manager_timer_cb, NULL);
-		if (debug) printf("collection manager timer started\n");
+		DEBUG_1("collection manager timer started\n");
 		}
 }
 
@@ -928,6 +925,6 @@
 {
 	collect_manager_timer_push(TRUE);
 
-	if (debug) printf("collection manager flushing\n");
+	DEBUG_1("collection manager flushing\n");
 	while (collect_manager_process_cb(NULL));
 }
--- a/src/collect-table.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/collect-table.c	Wed Apr 23 20:47:19 2008 +0000
@@ -406,7 +406,7 @@
 		col2 = t;
 		}
 
-	if (debug) printf("table: %d x %d to %d x %d\n", row1, col1, row2, col2);
+	DEBUG_1("table: %d x %d to %d x %d\n", row1, col1, row2, col2);
 
 	for (i = row1; i <= row2; i++)
 		{
@@ -1642,7 +1642,7 @@
 
 	collection_table_populate(ct, TRUE);
 
-	if (debug) printf("col tab pop cols=%d rows=%d\n", ct->columns, ct->rows);
+	DEBUG_1("col tab pop cols=%d rows=%d\n", ct->columns, ct->rows);
 }
 
 static void collection_table_sync(CollectTable *ct)
@@ -2062,7 +2062,7 @@
 	CollectInfo *drop_info;
 	GList *work;
 
-	if (debug) printf("%s\n", selection_data->data);
+	DEBUG_1("%s\n", selection_data->data);
 
 	collection_table_scroll(ct, FALSE);
 	collection_table_insert_marker(ct, NULL, FALSE);
--- a/src/collect.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/collect.c	Wed Apr 23 20:47:19 2008 +0000
@@ -365,7 +365,7 @@
 {
 	if (!cd) return;
 
-	if (debug) printf("collection \"%s\" freed\n", cd->name);
+	DEBUG_1("collection \"%s\" freed\n", cd->name);
 
 	collection_load_stop(cd);
 	collection_list_free(cd->list);
@@ -384,14 +384,14 @@
 {
 	cd->ref++;
 
-	if (debug) printf("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
+	DEBUG_1("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
 }
 
 void collection_unref(CollectionData *cd)
 {
 	cd->ref--;
 
-	if (debug) printf("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
+	DEBUG_1("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
 
 	if (cd->ref < 1)
 		{
@@ -624,7 +624,7 @@
 
 		ci = collection_info_new_if_not_exists(cd, &st, fd);
 		if (!ci) return FALSE;
-		if (debug > 2) printf("add to collection: %s\n", fd->path);
+		DEBUG_3("add to collection: %s\n", fd->path);
 
 		cd->list = collection_list_add(cd->list, ci, sorted ? cd->sort_method : SORT_NONE);
 		cd->changed = TRUE;
@@ -660,7 +660,7 @@
 		ci = collection_info_new_if_not_exists(cd, &st, fd);
 		if (!ci) return FALSE;
 
-		if (debug > 2) printf("insert in collection: %s\n", fd->path);
+		DEBUG_3("insert in collection: %s\n", fd->path);
 
 		cd->list = collection_list_insert(cd->list, ci, insert_ci, sorted ? cd->sort_method : SORT_NONE);
 		cd->changed = TRUE;
--- a/src/color-man.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/color-man.c	Wed Apr 23 20:47:19 2008 +0000
@@ -164,7 +164,7 @@
 
 	if (!cc->profile_in || !cc->profile_out)
 		{
-		if (debug) printf("failed to load color profile for %s: %d %s\n",
+		DEBUG_1("failed to load color profile for %s: %d %s\n",
 				  (!cc->profile_in) ? "input" : "screen",
 				  (!cc->profile_in) ? cc->profile_in_type : cc->profile_out_type,
 				  (!cc->profile_in) ? cc->profile_in_file : cc->profile_out_file);
@@ -181,7 +181,7 @@
 
 	if (!cc->transform)
 		{
-		if (debug) printf("failed to create color profile transform\n");
+		DEBUG_1("failed to create color profile transform\n");
 
 		color_man_cache_unref(cc);
 		return NULL;
--- a/src/dupe.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/dupe.c	Wed Apr 23 20:47:19 2008 +0000
@@ -965,7 +965,7 @@
 		GList *work;
 		gdouble rank;
 
-		if (debug > 1) printf("link found %s to %s [%d]\n", child->fd->name, parent->fd->name, g_list_length(parent->group));
+		DEBUG_2("link found %s to %s [%d]\n", child->fd->name, parent->fd->name, g_list_length(parent->group));
 
 		work = parent->group;
 		while (work)
@@ -994,7 +994,7 @@
 		}
 	else
 		{
-		if (debug > 1) printf("unlinking %s and %s\n", child->fd->name, parent->fd->name);
+		DEBUG_2("unlinking %s and %s\n", child->fd->name, parent->fd->name);
 
 		dupe_match_unlink(child, parent);
 		}
@@ -1097,11 +1097,11 @@
 
 	list = dupe_match_rank_sort(dw->list);
 
-	if (debug > 1) dupe_match_print_list(list);
-
-	if (debug) printf("Similar items: %d\n", g_list_length(list));
+	if (debug >= 2) dupe_match_print_list(list);
+
+	DEBUG_1("Similar items: %d\n", g_list_length(list));
 	list = dupe_match_group_trim(list, dw);
-	if (debug) printf("Unique groups: %d\n", g_list_length(list));
+	DEBUG_1("Unique groups: %d\n", g_list_length(list));
 
 	dupe_match_sort_groups(list);
 
@@ -1185,7 +1185,7 @@
 
 		if (f < m) return FALSE;
 
-		if (debug > 2) printf("similar: %32s %32s = %f\n", a->fd->name, b->fd->name, f);
+		DEBUG_3("similar: %32s %32s = %f\n", a->fd->name, b->fd->name, f);
 		}
 
 	return TRUE;
@@ -1340,7 +1340,7 @@
 	if (!thumb_loader_start(dw->thumb_loader, di->fd->path))
 		{
 		/* error, handle it, do next */
-		if (debug) printf("error loading thumb for %s\n", di->fd->path);
+		DEBUG_1("error loading thumb for %s\n", di->fd->path);
 		dupe_thumb_do(dw);
 		dupe_thumb_step(dw);
 		}
--- a/src/exif-common.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/exif-common.c	Wed Apr 23 20:47:19 2008 +0000
@@ -644,7 +644,7 @@
 				}
 			memcpy(cp_data, data + chunk_offset[i], chunk_length[i]);
 			}
-		if (debug) printf("Found embedded icc profile in jpeg\n");
+		DEBUG_1("Found embedded icc profile in jpeg\n");
 		exif_add_jpeg_color_profile(exif, cp_data, cp_length);
 
 		return TRUE;
--- a/src/exiv2.cc	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/exiv2.cc	Wed Apr 23 20:47:19 2008 +0000
@@ -81,13 +81,13 @@
 		image->readMetadata();
 
 #if EXIV2_TEST_VERSION(0,16,0)
-		if (debug >= 2) printf("xmp count %li\n", image->xmpData().count());
+		DEBUG_2("xmp count %li\n", image->xmpData().count());
 		if (sidecar_path && image->xmpData().empty())
 			{
 			sidecar = Exiv2::ImageFactory::open(sidecar_path);
 			sidecar->readMetadata();
 			have_sidecar = sidecar->good();
-			if (debug >= 2) printf("sidecar xmp count %li\n", sidecar->xmpData().count());
+			DEBUG_2("sidecar xmp count %li\n", sidecar->xmpData().count());
 			}
 
 #endif
@@ -140,7 +140,7 @@
 
 ExifData *exif_read(gchar *path, gchar *sidecar_path)
 {
-	if (debug) printf("exif read %s,  sidecar: %s\n", path, sidecar_path ? sidecar_path : "-");
+	DEBUG_1("exif read %s,  sidecar: %s\n", path, sidecar_path ? sidecar_path : "-");
 	try {
 		return new ExifData(path, sidecar_path);
 	}
@@ -715,7 +715,7 @@
 	TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
 	if (te)
 		{
-		if (debug) printf("(tag: %04x %04x) ", tag, group);
+		DEBUG_1("(tag: %04x %04x) ", tag, group);
 		return te->pValue();
 		}
 	else
@@ -763,9 +763,8 @@
 
 	try {
 		RawFile rf(fd);
-		if (debug) printf("%s: offset ", path);
 		offset = rf.preview_offset();
-		if (debug) printf("%lu\n", offset);
+		DEBUG_1("%s: offset %lu\n", path, offset);
 	}
 	catch (Exiv2::AnyError& e) {
 		std::cout << "Caught Exiv2 exception '" << e << "'\n";
--- a/src/filelist.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/filelist.c	Wed Apr 23 20:47:19 2008 +0000
@@ -199,7 +199,7 @@
 			i++;
 			}
 
-		if (debug) printf("loader reported [%s] [%s] [%s]\n", name, desc, filter->str);
+		DEBUG_1("loader reported [%s] [%s] [%s]\n", name, desc, filter->str);
 
 		filter_add_if_missing(name, desc, filter->str, FORMAT_CLASS_IMAGE, TRUE);
 
@@ -767,7 +767,7 @@
 {
 	FileData *fd;
 
-	if (debug) printf("file_data_new: '%s' %d\n", path_utf8, check_sidecars);
+	DEBUG_1("file_data_new: '%s' %d\n", path_utf8, check_sidecars);
 
 	if (!file_data_pool)
 		file_data_pool = g_hash_table_new (g_str_hash, g_str_equal);
@@ -776,7 +776,7 @@
 	if (fd)
 		{
 		file_data_check_changed_files(fd, st);
-		if (debug) printf("file_data_pool hit: '%s'\n", fd->path);
+		DEBUG_1("file_data_pool hit: '%s'\n", fd->path);
 		return file_data_ref(fd);
 		}
 
@@ -930,7 +930,7 @@
 	g_assert(fd->magick == 0x12345678);
 
 	fd->ref--;
-	if (debug) printf("file_data_unref (%d): '%s'\n", fd->ref, fd->path);
+	DEBUG_1("file_data_unref (%d): '%s'\n", fd->ref, fd->path);
 
 	if (fd->ref == 0)
 		{
@@ -952,7 +952,7 @@
 
 		/* none of parent/children is referenced, we can free everything */
 
-		if (debug) printf("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path);
+		DEBUG_1("file_data_unref: deleting '%s', parent '%s'\n", fd->path, parent->path);
 
 		work = parent->sidecar_files;
 		while (work)
--- a/src/format_raw.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/format_raw.c	Wed Apr 23 20:47:19 2008 +0000
@@ -244,7 +244,7 @@
 
 	if (!entry || !entry->func_parse) return FALSE;
 
-	if (debug) printf("RAW using file parser for %s\n", entry->description);
+	DEBUG_1("RAW using file parser for %s\n", entry->description);
 
 	found = entry->func_parse(data, len, &io, &eo);
 
@@ -334,7 +334,7 @@
 
 		if (!match) return FALSE;
 
-		if (debug) printf("RAW file parser extension match\n");
+		DEBUG_1("RAW file parser extension match\n");
 		}
 
 	/* FIXME:
@@ -427,7 +427,7 @@
 
 	if (!entry || !entry->func_parse) return FALSE;
 
-	if (debug) printf("EXIF using makernote parser for %s\n", entry->description);
+	DEBUG_1("EXIF using makernote parser for %s\n", entry->description);
 
 	return entry->func_parse(exif, tiff, offset, size, bo);
 }
--- a/src/fullscreen.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/fullscreen.c	Wed Apr 23 20:47:19 2008 +0000
@@ -235,7 +235,7 @@
 	fs->stop_func = stop_func;
 	fs->stop_data = stop_data;
 
-	if (debug) printf("full screen requests screen %d\n", options->fullscreen.screen);
+	DEBUG_1("full screen requests screen %d\n", options->fullscreen.screen);
 	fullscreen_prefs_get_geometry(options->fullscreen.screen, window, &x, &y, &w, &h,
 				      &screen, &same);
 
@@ -407,7 +407,7 @@
 			sd->width = rect.width;
 			sd->height = rect.height;
 
-			if (debug) printf("Screen %d %30s %4d,%4d (%4dx%4d)\n",
+			DEBUG_1("Screen %d %30s %4d,%4d (%4dx%4d)\n",
 					  sd->number, sd->description, sd->x, sd->y, sd->width, sd->height);
 
 			list = g_list_append(list, sd);
@@ -567,7 +567,7 @@
 
 	n = (gdk_screen_get_number(screen)+1) * 100 + monitor + 1;
 
-	if (debug || TRUE) printf("Screen appears to be %d\n", n);
+	DEBUG_1("Screen appears to be %d\n", n);
 
 	return n;
 }
--- a/src/image-load.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/image-load.c	Wed Apr 23 20:47:19 2008 +0000
@@ -164,7 +164,7 @@
 {
 	image_loader_stop(il);
 
-	if (debug) printf("pixbuf_loader reported load error for: %s\n", image_loader_path(il));
+	DEBUG_1("pixbuf_loader reported load error for: %s\n", image_loader_path(il));
 
 	if (il->func_error) il->func_error(il, il->data_error);
 }
@@ -221,7 +221,7 @@
 	if (b > 0 &&
 	    format_raw_img_exif_offsets_fd(il->load_fd, image_loader_path(il), il->read_buffer, b, &offset, NULL))
 		{
-		if (debug) printf("Raw file %s contains embedded image\n", image_loader_path(il));
+		DEBUG_1("Raw file %s contains embedded image\n", image_loader_path(il));
 
 		b = read(il->load_fd, il->read_buffer, il->read_buffer_size);
 		}
@@ -332,7 +332,7 @@
 	il->requested_width = 0;
 	il->requested_height = 0;
 	il->shrunk = FALSE;
-	if (debug) printf("new image loader %p, bufsize=%u idle_loop=%u\n", il, il->read_buffer_size, il->idle_read_loop_count);
+	DEBUG_1("new image loader %p, bufsize=%u idle_loop=%u\n", il, il->read_buffer_size, il->idle_read_loop_count);
 	return il;
 }
 
@@ -356,7 +356,7 @@
 	if (il->fd) file_data_unref(il->fd);
 	if (il->path) g_free(il->path);
 	if (il->read_buffer) g_free(il->read_buffer);
-	if (debug) printf("freeing image loader %p bytes_read=%d\n", il, il->bytes_read);
+	DEBUG_1("freeing image loader %p bytes_read=%d\n", il, il->bytes_read);
 	g_free(il);
 }
 
--- a/src/image.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/image.c	Wed Apr 23 20:47:19 2008 +0000
@@ -121,7 +121,7 @@
 {
 	if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return;
 
-	if (debug) printf("%s image load completed \"%s\" (%s)\n", get_exec_time(),
+	DEBUG_1("%s image load completed \"%s\" (%s)\n", get_exec_time(),
 			  (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") :
 				      (imd->image_fd ? imd->image_fd->path : "null"),
 			  (preload) ? "preload" : "current");
@@ -297,7 +297,7 @@
 
 	if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO);
 	layout_image_overlay_update(layout_find_by_image(imd));
-	if (debug) printf("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name);
+	DEBUG_1("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name);
 }
 
 static void image_post_process_alter(ImageWindow *imd, gint clamp)
@@ -322,7 +322,7 @@
 
 	imd->cm = NULL;
 	image_state_set(imd, IMAGE_STATE_COLOR_ADJ);
-	if (debug) printf("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name);
+	DEBUG_1("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name);
 
 	image_post_process_alter(imd, FALSE);
 
@@ -399,7 +399,7 @@
 				input_file = NULL;
 				imd->color_profile_from_image = COLOR_PROFILE_SRGB;
 
-				if (debug) printf("Found EXIF ColorSpace of sRGB\n");
+				DEBUG_1("Found EXIF ColorSpace of sRGB\n");
 				}
 			if (cs == 2 || (interop_index && !strcmp(interop_index, "R03")))
 				{
@@ -407,7 +407,7 @@
 				input_file = NULL;
 				imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB;
 
-				if (debug) printf("Found EXIF ColorSpace of AdobeRGB\n");
+				DEBUG_1("Found EXIF ColorSpace of AdobeRGB\n");
 				}
 
 			g_free(interop_index);
@@ -416,7 +416,7 @@
 
 	if (profile)
 		{
-		if (debug) printf("Found embedded color profile\n");
+		DEBUG_1("Found embedded color profile\n");
 		imd->color_profile_from_image = COLOR_PROFILE_MEM;
 
 		cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL,
@@ -456,7 +456,7 @@
 
 	if (!image_get_pixbuf(imd)) return;
 
-	if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name);
+	DEBUG_1("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name);
 
 	if (options->image.exif_rotate_enable ||
 	    (imd->color_profile_enable && imd->color_profile_use_image) )
@@ -617,7 +617,7 @@
 
 static void image_read_ahead_cancel(ImageWindow *imd)
 {
-	if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null");
+	DEBUG_1("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null");
 
 	image_loader_free(imd->read_ahead_il);
 	imd->read_ahead_il = NULL;
@@ -633,7 +633,7 @@
 {
 	ImageWindow *imd = data;
 
-	if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
+	DEBUG_1("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
 
 	imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il);
 	if (imd->read_ahead_pixbuf)
@@ -664,7 +664,7 @@
 	/* still loading ?, do later */
 	if (imd->il /*|| imd->cm*/) return;
 
-	if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
+	DEBUG_1("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
 
 	imd->read_ahead_il = image_loader_new(imd->read_ahead_fd);
 
@@ -684,7 +684,7 @@
 
 	imd->read_ahead_fd = file_data_ref(fd);
 
-	if (debug) printf("read ahead set to :%s\n", imd->read_ahead_fd->path);
+	DEBUG_1("read ahead set to :%s\n", imd->read_ahead_fd->path);
 
 	image_read_ahead_start(imd);
 }
@@ -715,7 +715,7 @@
 		imd->prev_color_row = -1;
 		}
 
-	if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null");
+	DEBUG_1("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null");
 }
 
 static gint image_post_buffer_get(ImageWindow *imd)
@@ -785,7 +785,7 @@
 {
 	ImageWindow *imd = data;
 
-	if (debug) printf ("%s image done\n", get_exec_time());
+	DEBUG_1 ("%s image done\n", get_exec_time());
 
 	g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
 	image_state_unset(imd, IMAGE_STATE_LOADING);
@@ -807,7 +807,7 @@
 
 static void image_load_error_cb(ImageLoader *il, gpointer data)
 {
-	if (debug) printf ("%s image error\n", get_exec_time());
+	DEBUG_1 ("%s image error\n", get_exec_time());
 
 	/* even on error handle it like it was done,
 	 * since we have a pixbuf with _something_ */
@@ -888,7 +888,7 @@
 
 static gint image_load_begin(ImageWindow *imd, FileData *fd)
 {
-	if (debug) printf ("%s image begin \n", get_exec_time());
+	DEBUG_1 ("%s image begin \n", get_exec_time());
 
 	if (imd->il) return FALSE;
 
@@ -897,13 +897,13 @@
 
 	if (image_post_buffer_get(imd))
 		{
-		if (debug) printf("from post buffer: %s\n", imd->image_fd->path);
+		DEBUG_1("from post buffer: %s\n", imd->image_fd->path);
 		return TRUE;
 		}
 
 	if (image_read_ahead_check(imd))
 		{
-		if (debug) printf("from read ahead buffer: %s\n", imd->image_fd->path);
+		DEBUG_1("from read ahead buffer: %s\n", imd->image_fd->path);
 		return TRUE;
 		}
 
@@ -926,7 +926,7 @@
 
 	if (!image_loader_start(imd->il, image_load_done_cb, imd))
 		{
-		if (debug) printf("image start error\n");
+		DEBUG_1("image start error\n");
 
 		g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
 
@@ -953,7 +953,7 @@
 {
 	/* stops anything currently being done */
 
-	if (debug) printf("%s image reset\n", get_exec_time());
+	DEBUG_1("%s image reset\n", get_exec_time());
 
 	g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
 
--- a/src/layout.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/layout.c	Wed Apr 23 20:47:19 2008 +0000
@@ -1032,7 +1032,7 @@
 {
 	if (!layout_valid(&lw)) return;
 
-	if (debug) printf("layout refresh\n");
+	DEBUG_1("layout refresh\n");
 
 	layout_refresh_lists(lw);
 
@@ -1053,7 +1053,7 @@
 
 		if (new_time > 0 && new_time > lw->last_time)
 			{
-			if (debug) printf("layout path time changed, refreshing...\n");
+			DEBUG_1("layout path time changed, refreshing...\n");
 			layout_refresh_by_time(lw);
 			}
 		}
--- a/src/layout_image.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/layout_image.c	Wed Apr 23 20:47:19 2008 +0000
@@ -845,7 +845,7 @@
 		}
 	if (i < MAX_SPLIT_IMAGES)
 		{
-		if (debug) printf("dnd image activate %d\n", i);
+		DEBUG_1("dnd image activate %d\n", i);
 		layout_image_activate(lw, i);
 		}
 
@@ -925,7 +925,7 @@
 		}
 	if (i < MAX_SPLIT_IMAGES)
 		{
-		if (debug) printf("dnd get from %d\n", i);
+		DEBUG_1("dnd get from %d\n", i);
 		fd = image_get_fd(lw->split_images[i]);
 		}
 	else
@@ -1558,7 +1558,7 @@
 
 	if (i != -1)
 		{
-		if (debug) printf("image activate scroll %d\n", i);
+		DEBUG_1("image activate scroll %d\n", i);
 		layout_image_activate(lw, i);
 		}
 
--- a/src/main.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/main.c	Wed Apr 23 20:47:19 2008 +0000
@@ -220,7 +220,7 @@
 
 	if (!command || !path) return;
 
-	if (debug) printf("Help command pre \"%s\", \"%s\"\n", command, path);
+	DEBUG_1("Help command pre \"%s\", \"%s\"\n", command, path);
 
 	buf = g_strdup(command);
 	begin = strstr(buf, "%s");
@@ -238,7 +238,7 @@
 		}
 	g_free(buf);
 
-	if (debug) printf("Help command post [%s]\n", result);
+	DEBUG_1("Help command post [%s]\n", result);
 
 	system(result);
 
@@ -1162,7 +1162,7 @@
 			}
 		}
 
-	if (debug > 0) printf("debugging output enabled (level %d)\n", debug);
+	DEBUG_1("debugging output enabled (level %d)\n", debug);
 #endif
 }
 
--- a/src/main.h	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/main.h	Wed Apr 23 20:47:19 2008 +0000
@@ -119,6 +119,17 @@
 # define debug 0
 #endif
 
+#ifdef DEBUG
+#define DEBUG_N(n, ...) do { if (debug >= (n)) printf(__VA_ARGS__); } while (0)
+#else
+#define DEBUG_N(n, ...)  do { } while(0)
+#endif
+
+#define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__)
+#define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__)
+#define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__)
+#define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__)
+
 #include "typedefs.h"
 
 /*
--- a/src/pan-calendar.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/pan-calendar.c	Wed Apr 23 20:47:19 2008 +0000
@@ -236,7 +236,7 @@
 			}
 		}
 
-	if (debug) printf("biggest day contains %d images\n", day_max);
+	DEBUG_1("biggest day contains %d images\n", day_max);
 
 	grid = (gint)(sqrt((double)day_max) + 0.5) * (PAN_THUMB_SIZE + PAN_SHADOW_OFFSET * 2 + PAN_THUMB_GAP);
 	day_width = MAX(PAN_CAL_DAY_WIDTH, grid);
--- a/src/pan-view.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/pan-view.c	Wed Apr 23 20:47:19 2008 +0000
@@ -773,7 +773,7 @@
 	row = row * 2 - 1;
 	col = col * 2 - 1;
 
-	if (debug) printf("intersect speedup grid is %dx%d, based on %d average per grid\n", col, row, grid_size);
+	DEBUG_1("intersect speedup grid is %dx%d, based on %d average per grid\n", col, row, grid_size);
 
 	for (j = 0; j < row; j++)
 	    for (i = 0; i < col; i++)
@@ -791,7 +791,7 @@
 
 			pw->list_grid = g_list_prepend(pw->list_grid, pg);
 
-			if (debug) printf("grid section: %d,%d (%dx%d)\n", pg->x, pg->y, pg->w, pg->h);
+			DEBUG_1("grid section: %d,%d (%dx%d)\n", pg->x, pg->y, pg->w, pg->h);
 			}
 		}
 
@@ -961,7 +961,7 @@
 
 	pan_cache_free(pw);
 
-	if (debug) printf("computed %d objects\n", g_list_length(pw->list));
+	DEBUG_1("computed %d objects\n", g_list_length(pw->list));
 }
 
 static GList *pan_layout_intersect_l(GList *list, GList *item_list,
@@ -1117,7 +1117,7 @@
 		{
 		gdouble align;
 
-		if (debug) printf("Canvas size is %d x %d\n", width, height);
+		DEBUG_1("Canvas size is %d x %d\n", width, height);
 
 		pan_grid_build(pw, width, height, 1000);
 
@@ -1499,7 +1499,7 @@
 
 	if (!pi) return;
 
-	if (debug) printf("info set to %s\n", pi->fd->path);
+	DEBUG_1("info set to %s\n", pi->fd->path);
 
 	pbox = pan_item_box_new(pw, NULL, pi->x + pi->width + 4, pi->y, 10, 10,
 				PAN_POPUP_BORDER,
--- a/src/pixbuf-renderer.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/pixbuf-renderer.c	Wed Apr 23 20:47:19 2008 +0000
@@ -2988,7 +2988,7 @@
 #if 0
 	printf("FIXME: send updated signal\n");
 #endif
-	if (debug) printf("%s pixbuf renderer updated - started drawing %p\n", get_exec_time(), pr);
+	DEBUG_1("%s pixbuf renderer updated - started drawing %p\n", get_exec_time(), pr);
 	pr->debug_updated = TRUE;
 }
 
@@ -3016,7 +3016,7 @@
 		}
 	if (pr->debug_updated)
 		{
-		if (debug) printf("%s pixbuf renderer done %p\n", get_exec_time(), pr);
+		DEBUG_1("%s pixbuf renderer done %p\n", get_exec_time(), pr);
 		pr->debug_updated = FALSE;
 		}
 }
--- a/src/print.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/print.c	Wed Apr 23 20:47:19 2008 +0000
@@ -932,7 +932,7 @@
 		while (*end != '\0' && *end != '\n' && *end != ' ' && *end != '\t') end++;
 		*end = '\0';
 		list = g_list_append(list, g_strdup(ptr));
-		if (debug) printf("adding printer: %s\n", ptr);
+		DEBUG_1("adding printer: %s\n", ptr);
 		}
 
 	pclose(p);
--- a/src/remote.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/remote.c	Wed Apr 23 20:47:19 2008 +0000
@@ -97,12 +97,8 @@
 		{
 		rc->clients = g_list_remove(rc->clients, client);
 
-		if (debug)
-			{
-			printf("HUP detected, closing client.\n");
-			printf("client count %d\n", g_list_length(rc->clients));
-			}
-
+		DEBUG_1("HUP detected, closing client.\nclient count %d\n", g_list_length(rc->clients));
+		
 		g_source_remove(client->channel_id);
 		close(client->fd);
 		g_free(client);
@@ -133,7 +129,7 @@
 	g_io_channel_unref(channel);
 
 	rc->clients = g_list_append(rc->clients, client);
-	if (debug) printf("client count %d\n", g_list_length(rc->clients));
+	DEBUG_1("client count %d\n", g_list_length(rc->clients));
 }
 
 static void remote_server_clients_close(RemoteConnection *rc)
@@ -256,7 +252,7 @@
 	strncpy(addr.sun_path, path, sun_path_len);
 	if (connect(fd, &addr, sizeof(addr)) == -1)
 		{
-		if (debug) printf("error connecting to socket: %s\n", strerror(errno));
+		DEBUG_1("error connecting to socket: %s\n", strerror(errno));
 		close(fd);
 		return NULL;
 		}
--- a/src/secure_save.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/secure_save.c	Wed Apr 23 20:47:19 2008 +0000
@@ -287,7 +287,7 @@
 				utime(ssi->tmp_file_name, &tb);
 				}
 			}
-		if (debug > 2) g_printf("rename %s -> %s", ssi->tmp_file_name, ssi->file_name);
+		DEBUG_3("rename %s -> %s\n", ssi->tmp_file_name, ssi->file_name);
 		if (g_rename(ssi->tmp_file_name, ssi->file_name) == -1) {
 			ret = errno;
 			secsave_errno = SS_ERR_RENAME;
--- a/src/thumb.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/thumb.c	Wed Apr 23 20:47:19 2008 +0000
@@ -55,7 +55,7 @@
 		cache_path = g_strconcat(cache_dir, "/", filename_from_path(tl->path),
 					 GQ_CACHE_EXT_THUMB, NULL);
 
-		if (debug) printf("Saving thumb: %s\n", cache_path);
+		DEBUG_1("Saving thumb: %s\n", cache_path);
 
 		pathl = path_from_utf8(cache_path);
 		success = pixbuf_to_file_as_png(tl->pixbuf, pathl);
@@ -72,7 +72,7 @@
 			}
 		else
 			{
-			if (debug) printf("Saving failed: %s\n", pathl);
+			DEBUG_1("Saving failed: %s\n", pathl);
 			}
 
 		g_free(pathl);
@@ -103,7 +103,7 @@
 		cache_path = g_strconcat(cache_dir, "/", filename_from_path(tl->path),
 					 GQ_CACHE_EXT_THUMB, NULL);
 
-		if (debug) printf("marking thumb failure: %s\n", cache_path);
+		DEBUG_1("marking thumb failure: %s\n", cache_path);
 
 		pathl = path_from_utf8(cache_path);
 		f = fopen(pathl, "w");
@@ -146,12 +146,12 @@
 	gint pw, ph;
 	gint save;
 
-	if (debug) printf("thumb done: %s\n", tl->path);
+	DEBUG_1("thumb done: %s\n", tl->path);
 
 	pixbuf = image_loader_get_pixbuf(tl->il);
 	if (!pixbuf)
 		{
-		if (debug) printf("...but no pixbuf: %s\n", tl->path);
+		DEBUG_1("...but no pixbuf: %s\n", tl->path);
 		thumb_loader_error_cb(tl->il, tl);
 		return;
 		}
@@ -162,7 +162,7 @@
 	if (tl->cache_hit && pw != tl->max_w && ph != tl->max_h)
 		{
 		/* requested thumbnail size may have changed, load original */
-		if (debug) printf("thumbnail size mismatch, regenerating: %s\n", tl->path);
+		DEBUG_1("thumbnail size mismatch, regenerating: %s\n", tl->path);
 		tl->cache_hit = FALSE;
 
 		thumb_loader_setup(tl, tl->path);
@@ -172,7 +172,7 @@
 			image_loader_free(tl->il);
 			tl->il = NULL;
 
-			if (debug) printf("regeneration failure: %s\n", tl->path);
+			DEBUG_1("regeneration failure: %s\n", tl->path);
 			thumb_loader_error_cb(tl->il, tl);
 			}
 		return;
@@ -227,7 +227,7 @@
 		return;
 		}
 
-	if (debug) printf("thumb error: %s\n", tl->path);
+	DEBUG_1("thumb error: %s\n", tl->path);
 
 	image_loader_free(tl->il);
 	tl->il = NULL;
@@ -332,16 +332,16 @@
 			{
 			if (cache_time_valid(cache_path, tl->path))
 				{
-				if (debug) printf("Found in cache:%s\n", tl->path);
+				DEBUG_1("Found in cache:%s\n", tl->path);
 
 				if (filesize(cache_path) == 0)
 					{
-					if (debug) printf("Broken image mark found:%s\n", cache_path);
+					DEBUG_1("Broken image mark found:%s\n", cache_path);
 					g_free(cache_path);
 					return FALSE;
 					}
 
-				if (debug) printf("Cache location:%s\n", cache_path);
+				DEBUG_1("Cache location:%s\n", cache_path);
 				}
 			else
 				{
--- a/src/thumb_standard.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/thumb_standard.c	Wed Apr 23 20:47:19 2008 +0000
@@ -235,11 +235,7 @@
 			if (mtime_str && strtol(mtime_str, NULL, 10) == tl->source_mtime)
 				{
 				result = TRUE;
-				if (debug)
-					{
-					printf("thumb fail valid: %s\n", tl->source_path);
-					printf("           thumb: %s\n", fail_path);
-					}
+				DEBUG_1("thumb fail valid: %s\n           thumb: %s\n", tl->source_path, fail_path);
 				}
 
 			g_object_unref(G_OBJECT(pixbuf));
@@ -336,11 +332,7 @@
 		}
 	g_free(base_path);
 
-	if (debug)
-		{
-		printf("thumb saving: %s\n", tl->source_path);
-		printf("       saved: %s\n", tl->thumb_path);
-		}
+	DEBUG_1("thumb saving: %s\n       saved: %s\n", tl->source_path, tl->thumb_path);
 
 	/* save thumb, using a temp file then renaming into place */
 	tmp_path = unique_filename(tl->thumb_path, ".tmp", "_", 2);
@@ -459,7 +451,7 @@
 
 			tl->cache_hit = FALSE;
 
-			if (debug) printf("thumb copied: %s\n", tl->source_path);
+			DEBUG_1("thumb copied: %s\n", tl->source_path);
 
 			thumb_loader_std_save(tl, pixbuf);
 			}
@@ -508,7 +500,7 @@
 		{
 		if (!tl->thumb_path_local && remove_broken)
 			{
-			if (debug) printf("thumb broken, unlinking: %s\n", tl->thumb_path);
+			DEBUG_1("thumb broken, unlinking: %s\n", tl->thumb_path);
 			unlink_file(tl->thumb_path);
 			}
 
@@ -540,16 +532,12 @@
 	ThumbLoaderStd *tl = data;
 	GdkPixbuf *pixbuf;
 
-	if (debug)
-		{
-		printf("thumb image done: %s\n", tl->source_path);
-		printf("            from: %s\n", tl->il->path);
-		}
+	DEBUG_1("thumb image done: %s\n            from: %s\n", tl->source_path, tl->il->path);
 
 	pixbuf = image_loader_get_pixbuf(tl->il);
 	if (!pixbuf)
 		{
-		if (debug) printf("...but no pixbuf\n");
+		DEBUG_1("...but no pixbuf\n");
 		thumb_loader_std_error_cb(il, data);
 		return;
 		}
@@ -579,12 +567,8 @@
 		thumb_loader_std_done_cb(il, data);
 		return;
 		}
-
-	if (debug)
-		{
-		printf("thumb image error: %s\n", tl->source_path);
-		printf("             from: %s\n", tl->il->fd->path);
-		}
+	
+	DEBUG_1("thumb image error: %s\n             from: %s\n", tl->source_path, tl->il->fd->path);
 
 	if (thumb_loader_std_next_source(tl, TRUE)) return;
 
@@ -821,7 +805,7 @@
 				{
 				struct stat st;
 
-				if (debug) printf("thumb uri foreign, doing day check: %s\n", uri);
+				DEBUG_1("thumb uri foreign, doing day check: %s\n", uri);
 
 				if (stat_utf8(tv->path, &st))
 					{
@@ -902,7 +886,7 @@
 					  local, subfolder);
 	if (isfile(thumb_path))
 		{
-		if (debug) printf("thumb removing: %s\n", thumb_path);
+		DEBUG_1("thumb removing: %s\n", thumb_path);
 		unlink_file(thumb_path);
 		}
 	g_free(thumb_path);
@@ -991,12 +975,12 @@
 			tm->tl->thumb_path = NULL;
 			tm->tl->thumb_path_local = FALSE;
 
-			if (debug) printf("thumb move attempting save:\n");
+			DEBUG_1("thumb move attempting save:\n");
 
 			thumb_loader_std_save(tm->tl, pixbuf);
 			}
 
-		if (debug) printf("thumb move unlink: %s\n", tm->thumb_path);
+		DEBUG_1("thumb move unlink: %s\n", tm->thumb_path);
 		unlink_file(tm->thumb_path);
 		}
 
--- a/src/utilops.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/utilops.c	Wed Apr 23 20:47:19 2008 +0000
@@ -1336,7 +1336,7 @@
 		fd = list->data;
 		list = g_list_remove(list, fd);
 
-		if (debug) printf("expunging from trash for space: %s\n", fd->name);
+		DEBUG_1("expunging from trash for space: %s\n", fd->name);
 		if (!unlink_file(fd->path) && !warned)
 			{
 			file_util_warning_dialog(_("Delete failed"),
@@ -1394,7 +1394,7 @@
 
 	if (!isdir(options->file_ops.safe_delete_path))
 		{
-		if (debug) printf("creating trash: %s\n", options->file_ops.safe_delete_path);
+		DEBUG_1("creating trash: %s\n", options->file_ops.safe_delete_path);
 		if (!options->file_ops.safe_delete_path || !mkdir_utf8(options->file_ops.safe_delete_path, 0755))
 			{
 			result = _("Could not create folder");
@@ -1409,7 +1409,7 @@
 		dest = file_util_safe_dest(fd->path);
 		if (dest)
 			{
-			if (debug) printf("safe deleting %s to %s\n", fd->path, dest);
+			DEBUG_1("safe deleting %s to %s\n", fd->path, dest);
 			success = move_file(fd->path, dest);
 			}
 		else
@@ -2067,7 +2067,7 @@
 				}
 			else
 				{
-				if (debug) printf("closed by #%d\n", row);
+				DEBUG_1("closed by #%d\n", row);
 
 				file_dialog_close(rd->fdlg);
 				}
@@ -3149,7 +3149,7 @@
 	GList *work;
 	FileData *fail = NULL;
 
-	if (debug) printf("deltree into: %s\n", fd->path);
+	DEBUG_1("deltree into: %s\n", fd->path);
 
 	level++;
 	if (level > UTILITY_DELETE_MAX_DEPTH)
@@ -3179,7 +3179,7 @@
 		lfd = work->data;
 		work = work->next;
 
-		if (debug) printf("deltree child: %s\n", lfd->path);
+		DEBUG_1("deltree child: %s\n", lfd->path);
 
 		if (real_content && !islink(lfd->path))
 			{
@@ -3199,7 +3199,7 @@
 		fail = file_data_ref(fd);
 		}
 
-	if (debug) printf("deltree done: %s\n", fd->path);
+	DEBUG_1("deltree done: %s\n", fd->path);
 
 	return fail;
 }
@@ -3246,7 +3246,7 @@
 			fd = work->data;
 			work = work->next;
 
-			if (debug) printf("deltree unlink: %s\n", fd->path);
+			DEBUG_1("deltree unlink: %s\n", fd->path);
 
 			if (islink(fd->path))
 				{
--- a/src/view_file_icon.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/view_file_icon.c	Wed Apr 23 20:47:19 2008 +0000
@@ -653,7 +653,7 @@
 	uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN));
 	filelist_free(list);
 
-	if (debug) printf(uri_text);
+	DEBUG_1(uri_text);
 
 	gtk_selection_data_set(selection_data, selection_data->target,
 			       8, (guchar *)uri_text, total);
@@ -900,7 +900,7 @@
 		col2 = t;
 		}
 
-	if (debug) printf("table: %d x %d to %d x %d\n", row1, col1, row2, col2);
+	DEBUG_1("table: %d x %d to %d x %d\n", row1, col1, row2, col2);
 
 	for (i = row1; i <= row2; i++)
 		{
@@ -1734,7 +1734,7 @@
 
 	vficon_populate(vfi, TRUE, TRUE);
 
-	if (debug) printf("col tab pop cols=%d rows=%d\n", vfi->columns, vfi->rows);
+	DEBUG_1("col tab pop cols=%d rows=%d\n", vfi->columns, vfi->rows);
 }
 
 static void vficon_sync(ViewFileIcon *vfi)
@@ -2001,7 +2001,7 @@
 	if (!thumb_loader_start(vfi->thumbs_loader, fd->path))
 		{
 		/* set icon to unknown, continue */
-		if (debug) printf("thumb loader start failed %s\n", vfi->thumbs_loader->path);
+		DEBUG_1("thumb loader start failed %s\n", vfi->thumbs_loader->path);
 		vficon_thumb_do(vfi, vfi->thumbs_loader, fd);
 
 		return TRUE;
@@ -2617,7 +2617,7 @@
 			if (ignore_list)
 				{
 				new_row = vficon_maint_find_closest(vfi, row, n, ignore_list);
-				if (debug) printf("row = %d, closest is %d\n", row, new_row);
+				DEBUG_1("row = %d, closest is %d\n", row, new_row);
 				}
 			else
 				{
--- a/src/view_file_list.c	Wed Apr 23 13:46:18 2008 +0000
+++ b/src/view_file_list.c	Wed Apr 23 20:47:19 2008 +0000
@@ -226,7 +226,7 @@
 	uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN));
 	filelist_free(list);
 
-	if (debug) printf(uri_text);
+	DEBUG_1(uri_text);
 
 	gtk_selection_data_set(selection_data, selection_data->target,
 			       8, (guchar *)uri_text, total);
@@ -1236,7 +1236,7 @@
 	if (!thumb_loader_start(vfl->thumbs_loader, fd->path))
 		{
 		/* set icon to unknown, continue */
-		if (debug) printf("thumb loader start failed %s\n", vfl->thumbs_loader->path);
+		DEBUG_1("thumb loader start failed %s\n", vfl->thumbs_loader->path);
 		vflist_thumb_do(vfl, vfl->thumbs_loader, fd);
 
 		return TRUE;
@@ -2236,7 +2236,7 @@
 		if (ignore_list)
 			{
 			new_row = vflist_maint_find_closest(vfl, row, n, ignore_list);
-			if (debug) printf("row = %d, closest is %d\n", row, new_row);
+			DEBUG_1("row = %d, closest is %d\n", row, new_row);
 			}
 		else
 			{