comparison src/image-load.c @ 60:9c0c402b0ef3

Mon Jun 13 17:31:46 2005 John Ellis <johne@verizon.net> * editors.[ch]: Add "%w" macro to disable full screen deactivation when running an editor command. * img-view.c, layout_image.c, pan-view.c: Honor %w editor flag to prevent exit of full screen. * image-load.c (image_load_begin): Fix to not treat short reads as end of file condition. * README, doc/10_5_editor_commands.html: Document %w macro for editor commands. * po/it.po: Update Italian translation, submitted by Kostantino <inverness1ATvirgilio.it>.
author gqview
date Mon, 13 Jun 2005 21:39:13 +0000
parents b58cac75ad12
children 71e1ebee420e
comparison
equal deleted inserted replaced
59:57f6da2510d9 60:9c0c402b0ef3
215 215
216 if (!il->loader || il->pixbuf) return FALSE; 216 if (!il->loader || il->pixbuf) return FALSE;
217 217
218 b = read(il->load_fd, &buf, sizeof(buf)); 218 b = read(il->load_fd, &buf, sizeof(buf));
219 219
220 if (b > 1 && 220 if (b > 0 &&
221 format_raw_img_exif_offsets_fd(il->load_fd, il->path, buf, b, &offset, NULL)) 221 format_raw_img_exif_offsets_fd(il->load_fd, il->path, buf, b, &offset, NULL))
222 { 222 {
223 if (debug) printf("Raw file %s contains embedded image\n", il->path); 223 if (debug) printf("Raw file %s contains embedded image\n", il->path);
224 224
225 b = read(il->load_fd, &buf, sizeof(buf)); 225 b = read(il->load_fd, &buf, sizeof(buf));
229 { 229 {
230 image_loader_stop(il); 230 image_loader_stop(il);
231 return FALSE; 231 return FALSE;
232 } 232 }
233 233
234 if (gdk_pixbuf_loader_write(il->loader, buf, b, NULL)) 234 if (!gdk_pixbuf_loader_write(il->loader, buf, b, NULL))
235 {
236 il->bytes_read += b + offset;
237
238 if (b < sizeof(buf))
239 {
240 /* end of file already */
241
242 image_loader_stop(il);
243
244 if (!il->pixbuf) return FALSE;
245
246 image_loader_done_delay(il);
247 return TRUE;
248 }
249 else
250 {
251 /* larger file */
252
253 /* read until size is known */
254 while(il->loader && !gdk_pixbuf_loader_get_pixbuf(il->loader) && b > 0)
255 {
256 b = read(il->load_fd, &buf, sizeof(buf));
257 if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, buf, b, NULL)))
258 {
259 image_loader_stop(il);
260 return FALSE;
261 }
262 il->bytes_read += b;
263 }
264 if (!il->pixbuf) image_loader_sync_pixbuf(il);
265
266 if (il->bytes_read == il->bytes_total || b < sizeof(buf))
267 {
268 /* done, handle (broken) loaders that do not have pixbuf till close */
269 image_loader_stop(il);
270
271 if (!il->pixbuf) return FALSE;
272
273 image_loader_done_delay(il);
274 return TRUE;
275 }
276
277 if (!il->pixbuf)
278 {
279 image_loader_stop(il);
280 return FALSE;
281 }
282
283 /* finally, progressive loading :) */
284 il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
285 return TRUE;
286 }
287 }
288 else
289 { 235 {
290 image_loader_stop(il); 236 image_loader_stop(il);
291 return FALSE; 237 return FALSE;
292 } 238 }
239
240 il->bytes_read += b + offset;
241
242 /* read until size is known */
243 while (il->loader && !gdk_pixbuf_loader_get_pixbuf(il->loader) && b > 0)
244 {
245 b = read(il->load_fd, &buf, sizeof(buf));
246 if (b < 0 || (b > 0 && !gdk_pixbuf_loader_write(il->loader, buf, b, NULL)))
247 {
248 image_loader_stop(il);
249 return FALSE;
250 }
251 il->bytes_read += b;
252 }
253 if (!il->pixbuf) image_loader_sync_pixbuf(il);
254
255 if (il->bytes_read == il->bytes_total || b < 1)
256 {
257 /* done, handle (broken) loaders that do not have pixbuf till close */
258 image_loader_stop(il);
259
260 if (!il->pixbuf) return FALSE;
261
262 image_loader_done_delay(il);
263 return TRUE;
264 }
265
266 if (!il->pixbuf)
267 {
268 image_loader_stop(il);
269 return FALSE;
270 }
271
272 /* finally, progressive loading :) */
273 il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
293 274
294 return TRUE; 275 return TRUE;
295 } 276 }
296 277
297 static gint image_loader_setup(ImageLoader *il) 278 static gint image_loader_setup(ImageLoader *il)