summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2012-09-12 20:46:15 +0200
committerDaniel Friesel <derf@finalrewind.org>2012-09-12 20:46:15 +0200
commit290b5964ef857ea52d85edf846edd82392d9a716 (patch)
tree5ca891ffe5e2978d977207ca2f8bf977d39f2f44 /src
parent3e4d9f98c3c154b9c9aa6082b3d498e59dcb1e2e (diff)
print imlib2 error strings when save failed
Diffstat (limited to 'src')
-rw-r--r--src/feh.h1
-rw-r--r--src/imlib.c102
-rw-r--r--src/index.c2
-rw-r--r--src/slideshow.c2
-rw-r--r--src/thumbnail.c2
5 files changed, 58 insertions, 51 deletions
diff --git a/src/feh.h b/src/feh.h
index 2202617..cd730e9 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -157,6 +157,7 @@ void feh_display_status(char stat);
void real_loadables_mode(int loadable);
void feh_reload_image(winwidget w, int resize, int force_new);
void feh_filelist_image_remove(winwidget winwid, char do_delete);
+void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err);
void slideshow_save_image(winwidget win);
void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
Imlib_Load_Error * error_return);
diff --git a/src/imlib.c b/src/imlib.c
index d89a5a4..3ffc538 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -155,6 +155,57 @@ void ungib_imlib_save_image_with_error_return(Imlib_Image im, char *file,
imlib_save_image_with_error_return(file, error_return);
}
+void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err)
+{
+ if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS)
+ eprintf("%s - Out of file descriptors while loading", file);
+ else if (!opt.quiet || w) {
+ switch (err) {
+ case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
+ im_weprintf(w, "%s - File does not exist", file);
+ break;
+ case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
+ im_weprintf(w, "%s - Directory specified for image filename", file);
+ break;
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
+ im_weprintf(w, "%s - No read access", file);
+ break;
+ case IMLIB_LOAD_ERROR_UNKNOWN:
+ case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
+ im_weprintf(w, "%s - No Imlib2 loader for that file format", file);
+ break;
+ case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
+ im_weprintf(w, "%s - Path specified is too long", file);
+ break;
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
+ im_weprintf(w, "%s - Path component does not exist", file);
+ break;
+ case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
+ im_weprintf(w, "%s - Path component is not a directory", file);
+ break;
+ case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
+ im_weprintf(w, "%s - Path points outside address space", file);
+ break;
+ case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
+ im_weprintf(w, "%s - Too many levels of symbolic links", file);
+ break;
+ case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
+ im_weprintf(w, "While loading %s - Out of memory", file);
+ break;
+ case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
+ im_weprintf(w, "%s - Cannot write to directory", file);
+ break;
+ case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
+ im_weprintf(w, "%s - Cannot write - out of disk space", file);
+ break;
+ default:
+ im_weprintf(w, "While loading %s - Unknown error (%d)",
+ file, err);
+ break;
+ }
+ }
+}
+
int feh_load_image(Imlib_Image * im, feh_file * file)
{
Imlib_Load_Error err;
@@ -208,53 +259,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)
fputs("\n", stdout);
reset_output = 1;
}
- if (err == IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS)
- eprintf("%s - Out of file descriptors while loading", file->filename);
- else if (!opt.quiet) {
- switch (err) {
- case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
- weprintf("%s - File does not exist", file->filename);
- break;
- case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
- weprintf("%s - Directory specified for image filename", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
- weprintf("%s - No read access", file->filename);
- break;
- case IMLIB_LOAD_ERROR_UNKNOWN:
- case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
- weprintf("%s - No Imlib2 loader for that file format", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
- weprintf("%s - Path specified is too long", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
- weprintf("%s - Path component does not exist", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
- weprintf("%s - Path component is not a directory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
- weprintf("%s - Path points outside address space", file->filename);
- break;
- case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
- weprintf("%s - Too many levels of symbolic links", file->filename);
- break;
- case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
- weprintf("While loading %s - Out of memory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
- weprintf("%s - Cannot write to directory", file->filename);
- break;
- case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
- weprintf("%s - Cannot write - out of disk space", file->filename);
- break;
- default:
- weprintf("While loading %s - Unknown error (%d)",
- file->filename, err);
- break;
- }
- }
+ feh_imlib_print_load_error(file->filename, NULL, err)
D(("Load *failed*\n"));
return(0);
}
@@ -1024,7 +1029,8 @@ void feh_edit_inplace(winwidget w, int op)
FEH_FILE(w->file->data)->filename, &err);
gib_imlib_free_image(old);
if (err)
- im_weprintf(w, "Failed to save image after operation");
+ feh_imlib_print_load_error(FEH_FILE(w->file->data)->filename,
+ w, err);
feh_reload_image(w, 1, 1);
} else {
im_weprintf(w, "failed to load image from disk to edit it in place");
diff --git a/src/index.c b/src/index.c
index e5a93a4..5d4ed39 100644
--- a/src/index.c
+++ b/src/index.c
@@ -329,7 +329,7 @@ void init_index_mode(void)
ungib_imlib_save_image_with_error_return(im_main, output_buf, &err);
if (err) {
- weprintf("Cannot save image to %s", output_buf);
+ feh_imlib_print_load_error(output_buf, im_main, err);
}
else if (opt.verbose) {
int tw, th;
diff --git a/src/slideshow.c b/src/slideshow.c
index 2e9c417..60bd99c 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -597,7 +597,7 @@ void slideshow_save_image(winwidget win)
ungib_imlib_save_image_with_error_return(win->im, tmpname, &err);
if (err)
- im_weprintf(win, "Can't save image %s:", tmpname);
+ feh_imlib_print_load_error(tmpname, win, err);
free(tmpname);
return;
diff --git a/src/thumbnail.c b/src/thumbnail.c
index c622b07..fbe2ce0 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -384,7 +384,7 @@ void init_thumbnail_mode(void)
strncpy(output_buf, opt.output_file, 1024);
ungib_imlib_save_image_with_error_return(td.im_main, output_buf, &err);
if (err) {
- weprintf("Cannot save image to %s", output_buf);
+ feh_imlib_print_load_error(output_buf, td.im_main, err);
}
else if (opt.verbose) {
int tw, th;