comparison src/image-load.c @ 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 48c8e49b571c
children 01fe7ca55c69
comparison
equal deleted inserted replaced
494:3bb9a8df6ee9 495:c7a2471e5c4e
162 162
163 static void image_loader_error(ImageLoader *il) 163 static void image_loader_error(ImageLoader *il)
164 { 164 {
165 image_loader_stop(il); 165 image_loader_stop(il);
166 166
167 if (debug) printf("pixbuf_loader reported load error for: %s\n", image_loader_path(il)); 167 DEBUG_1("pixbuf_loader reported load error for: %s\n", image_loader_path(il));
168 168
169 if (il->func_error) il->func_error(il, il->data_error); 169 if (il->func_error) il->func_error(il, il->data_error);
170 } 170 }
171 171
172 static gint image_loader_idle_cb(gpointer data) 172 static gint image_loader_idle_cb(gpointer data)
219 b = read(il->load_fd, il->read_buffer, il->read_buffer_size); 219 b = read(il->load_fd, il->read_buffer, il->read_buffer_size);
220 220
221 if (b > 0 && 221 if (b > 0 &&
222 format_raw_img_exif_offsets_fd(il->load_fd, image_loader_path(il), il->read_buffer, b, &offset, NULL)) 222 format_raw_img_exif_offsets_fd(il->load_fd, image_loader_path(il), il->read_buffer, b, &offset, NULL))
223 { 223 {
224 if (debug) printf("Raw file %s contains embedded image\n", image_loader_path(il)); 224 DEBUG_1("Raw file %s contains embedded image\n", image_loader_path(il));
225 225
226 b = read(il->load_fd, il->read_buffer, il->read_buffer_size); 226 b = read(il->load_fd, il->read_buffer, il->read_buffer_size);
227 } 227 }
228 228
229 if (b < 1) 229 if (b < 1)
330 il->read_buffer = g_new(guchar, il->read_buffer_size); 330 il->read_buffer = g_new(guchar, il->read_buffer_size);
331 331
332 il->requested_width = 0; 332 il->requested_width = 0;
333 il->requested_height = 0; 333 il->requested_height = 0;
334 il->shrunk = FALSE; 334 il->shrunk = FALSE;
335 if (debug) printf("new image loader %p, bufsize=%u idle_loop=%u\n", il, il->read_buffer_size, il->idle_read_loop_count); 335 DEBUG_1("new image loader %p, bufsize=%u idle_loop=%u\n", il, il->read_buffer_size, il->idle_read_loop_count);
336 return il; 336 return il;
337 } 337 }
338 338
339 ImageLoader *image_loader_new(FileData *fd) 339 ImageLoader *image_loader_new(FileData *fd)
340 { 340 {
354 if (il->idle_done_id != -1) g_source_remove(il->idle_done_id); 354 if (il->idle_done_id != -1) g_source_remove(il->idle_done_id);
355 if (il->pixbuf) gdk_pixbuf_unref(il->pixbuf); 355 if (il->pixbuf) gdk_pixbuf_unref(il->pixbuf);
356 if (il->fd) file_data_unref(il->fd); 356 if (il->fd) file_data_unref(il->fd);
357 if (il->path) g_free(il->path); 357 if (il->path) g_free(il->path);
358 if (il->read_buffer) g_free(il->read_buffer); 358 if (il->read_buffer) g_free(il->read_buffer);
359 if (debug) printf("freeing image loader %p bytes_read=%d\n", il, il->bytes_read); 359 DEBUG_1("freeing image loader %p bytes_read=%d\n", il, il->bytes_read);
360 g_free(il); 360 g_free(il);
361 } 361 }
362 362
363 /* don't forget to gdk_pixbuf_ref() it if you want to use it after image_loader_free() */ 363 /* don't forget to gdk_pixbuf_ref() it if you want to use it after image_loader_free() */
364 GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il) 364 GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il)