summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/feh.h2
-rw-r--r--src/imlib.c84
-rw-r--r--src/slideshow.c6
-rw-r--r--src/utils.c8
-rw-r--r--src/winwidget.c3
-rw-r--r--src/winwidget.h1
7 files changed, 90 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 572e51f..ee31553 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@ git HEAD
* read directory contents sorted by filename instead of 'randomly'
(as returned by readdir) by default. Thanks talisein!
<https://github.com/derf/feh/pull/20>
+ * Show certain warnings in the image window as well as on the commandline
+ <http://github.com/derf/feh/issues/43>
Sat, 23 Apr 2011 22:00:27 +0200 Daniel Friesel <derf@finalrewind.org>
diff --git a/src/feh.h b/src/feh.h
index 01006b2..63aeef6 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -125,6 +125,7 @@ void init_keyevents(void);
void feh_event_handle_keypress(XEvent * ev);
void feh_action_run(feh_file * file, char *action);
char *feh_printf(char *str, feh_file * file);
+void im_weprintf(winwidget w, char *fmt, ...);
void feh_draw_zoom(winwidget w);
void feh_draw_checks(winwidget win);
void cb_slide_timer(void *data);
@@ -135,6 +136,7 @@ void feh_draw_filename(winwidget w);
void feh_draw_actions(winwidget w);
void feh_draw_caption(winwidget w);
void feh_draw_info(winwidget w);
+void feh_draw_errstr(winwidget w);
void feh_display_status(char stat);
void real_loadables_mode(int loadable);
void feh_reload_image(winwidget w, int resize, int force_new);
diff --git a/src/imlib.c b/src/imlib.c
index 5f5d14f..f9a764d 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -364,6 +364,70 @@ void feh_draw_zoom(winwidget w)
return;
}
+void im_weprintf(winwidget w, char *fmt, ...)
+{
+ va_list args;
+ char *errstr = emalloc(1024);
+
+ fflush(stdout);
+ fputs(PACKAGE " WARNING: ", stderr);
+
+ va_start(args, fmt);
+ vsnprintf(errstr, 1024, fmt, args);
+ va_end(args);
+
+ if (w)
+ w->errstr = errstr;
+
+ fputs(errstr, stderr);
+ if (fmt[0] != '\0' && fmt[strlen(fmt) - 1] == ':')
+ fprintf(stderr, " %s", strerror(errno));
+ fputs("\n", stderr);
+}
+
+
+void feh_draw_errstr(winwidget w)
+{
+ static Imlib_Font fn = NULL;
+ int tw = 0, th = 0;
+ Imlib_Image im = NULL;
+ static DATA8 atab[256];
+
+ if (!w->im)
+ return;
+
+ if (opt.font)
+ fn = gib_imlib_load_font(opt.font);
+
+ if (!fn)
+ fn = gib_imlib_load_font(DEFAULT_FONT);
+
+ if (!fn)
+ eprintf("Unable to draw error message. Dying to be safe.");
+
+ memset(atab, 0, sizeof(atab));
+
+ /* Work out how high the font is */
+ gib_imlib_get_text_size(fn, w->errstr, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
+
+ tw += 3;
+ th += 3;
+ im = imlib_create_image(tw, th);
+ if (!im)
+ eprintf("Couldn't create errstr image. Out of memory?");
+
+ gib_imlib_image_set_has_alpha(im, 1);
+ gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
+ gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
+
+ gib_imlib_text_draw(im, fn, NULL, 2, 2, w->errstr, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
+ gib_imlib_text_draw(im, fn, NULL, 1, 1, w->errstr, IMLIB_TEXT_TO_RIGHT, 255, 0, 0, 255);
+ free(w->errstr);
+ w->errstr = NULL;
+ gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, w->h - th, 1, 1, 0);
+ gib_imlib_free_image_and_decache(im);
+}
+
void feh_draw_filename(winwidget w)
{
static Imlib_Font fn = NULL;
@@ -388,7 +452,7 @@ void feh_draw_filename(winwidget w)
}
if (!fn) {
- weprintf("Couldn't load font for filename printing");
+ eprintf("Couldn't load font for filename printing");
return;
}
@@ -457,7 +521,7 @@ void feh_draw_info(winwidget w)
}
if (!fn) {
- weprintf("Couldn't load font for filename printing");
+ eprintf("Couldn't load font for filename printing");
return;
}
@@ -602,7 +666,7 @@ void feh_draw_caption(winwidget w)
}
if (!fn) {
- weprintf("Couldn't load font for caption printing");
+ eprintf("Couldn't load font for caption printing");
return;
}
@@ -731,7 +795,7 @@ void feh_edit_inplace_orient(winwidget w, int orientation)
gib_imlib_free_image(old);
feh_reload_image(w, 1, 1);
} else {
- weprintf("failed to load image from disk to edit it in place\n");
+ weprintf("failed to load image from disk to edit it in place");
}
return;
@@ -855,14 +919,16 @@ void feh_edit_inplace_lossless_rotate(winwidget w, int orientation)
execlp("jpegtran", "jpegtran", "-copy", "all", "-rotate",
rotate_str, "-outfile", file_str, file_str, NULL);
- eprintf("lossless rotate: Is 'jpegtran' installed? Failed to exec:");
+ weprintf("lossless rotate: Is 'jpegtran' installed? Failed to exec:");
+ return;
} else {
waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- weprintf("lossless rotate: Got exitcode %d from jpegtran."
- " Commandline was:\n"
- "jpegtran -copy all -rotate %s -outfile %s %s\n",
+ im_weprintf(w,
+ "lossless rotate: Got exitcode %d from jpegtran."
+ " Commandline was: "
+ "jpegtran -copy all -rotate %s -outfile %s %s",
status >> 8, rotate_str, file_str, file_str);
return;
}
@@ -911,7 +977,7 @@ void feh_draw_actions(winwidget w)
}
if (!fn) {
- weprintf("Couldn't load font for actions printing");
+ eprintf("Couldn't load font for actions printing");
return;
}
diff --git a/src/slideshow.c b/src/slideshow.c
index 79b931f..6d39d2c 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -104,7 +104,7 @@ void feh_reload_image(winwidget w, int resize, int force_new)
int old_w, old_h;
if (!w->file) {
- weprintf("couldn't reload, this image has no file associated with it.");
+ im_weprintf(w, "couldn't reload, this image has no file associated with it.");
return;
}
@@ -130,7 +130,7 @@ void feh_reload_image(winwidget w, int resize, int force_new)
if (force_new) {
eprintf("failed to reload image\n");
} else {
- weprintf("Couldn't reload image. Is it still there?");
+ im_weprintf(w, "Couldn't reload image. Is it still there?");
}
winwidget_rename(w, title);
free(title);
@@ -474,7 +474,7 @@ void slideshow_save_image(winwidget win)
gib_imlib_save_image_with_error_return(win->im, tmpname, &err);
if (err)
- weprintf("Can't save image %s:", tmpname);
+ im_weprintf(win, "Can't save image %s:", tmpname);
free(tmpname);
return;
diff --git a/src/utils.c b/src/utils.c
index 5259af8..e7ffa45 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -36,7 +36,7 @@ void eprintf(char *fmt, ...)
va_list args;
fflush(stdout);
- fprintf(stderr, "%s ERROR: ", PACKAGE);
+ fputs(PACKAGE " ERROR: ", stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
@@ -44,7 +44,7 @@ void eprintf(char *fmt, ...)
if (fmt[0] != '\0' && fmt[strlen(fmt) - 1] == ':')
fprintf(stderr, " %s", strerror(errno));
- fprintf(stderr, "\n");
+ fputs("\n", stderr);
exit(2);
}
@@ -54,7 +54,7 @@ void weprintf(char *fmt, ...)
va_list args;
fflush(stdout);
- fprintf(stderr, "%s WARNING: ", PACKAGE);
+ fputs(PACKAGE " WARNING: ", stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
@@ -62,7 +62,7 @@ void weprintf(char *fmt, ...)
if (fmt[0] != '\0' && fmt[strlen(fmt) - 1] == ':')
fprintf(stderr, " %s", strerror(errno));
- fprintf(stderr, "\n");
+ fputs("\n", stderr);
}
/* estrdup: duplicate a string, report if error */
diff --git a/src/winwidget.c b/src/winwidget.c
index 047deb7..4481c94 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -55,6 +55,7 @@ static winwidget winwidget_allocate(void)
ret->im = NULL;
ret->name = NULL;
ret->file = NULL;
+ ret->errstr = NULL;
ret->type = WIN_TYPE_UNSET;
ret->visible = 0;
ret->caption_entry = 0;
@@ -552,6 +553,8 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
feh_draw_actions(winwid);
if (opt.info_cmd)
feh_draw_info(winwid);
+ if (winwid->errstr)
+ feh_draw_errstr(winwid);
} else if ((opt.mode == MODE_ZOOM) && !antialias)
feh_draw_zoom(winwid);
diff --git a/src/winwidget.h b/src/winwidget.h
index 3af997a..33ad945 100644
--- a/src/winwidget.h
+++ b/src/winwidget.h
@@ -92,6 +92,7 @@ struct __winwidget {
char *name;
gib_list *file;
unsigned char visible;
+ char *errstr;
/* panning, zooming, etc. */
unsigned char mode;