From 918edfaa6254fcd7d328ced434f361b19a636576 Mon Sep 17 00:00:00 2001 From: reiseb <48870100+reiseb@users.noreply.github.com> Date: Sun, 12 Jan 2020 15:48:57 +0100 Subject: add option 'a' to show play/paused information in slideshow mode --- src/help.raw | 1 + src/keyevents.c | 2 ++ src/slideshow.c | 8 ++++++++ 3 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/help.raw b/src/help.raw index 8d30544..0a87b70 100644 --- a/src/help.raw +++ b/src/help.raw @@ -124,6 +124,7 @@ INDEX MODE OPTIONS font is specified, a title will not be printed FORMAT SPECIFIERS + %a information about slideshow state (play/pause) %f image path/filename %F image path/filename (shell-escaped) %g window dimensions (\"width,height\") in pixels diff --git a/src/keyevents.c b/src/keyevents.c index 0da07d3..761ec3c 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -710,6 +710,8 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy } else if (feh_is_kp(EVENT_toggle_pause, state, keysym, button)) { slideshow_pause_toggle(winwid); + /* We need to reload the image to update the info string immediately. */ + feh_reload_image(winwid, 0, 0); } else if (feh_is_kp(EVENT_save_image, state, keysym, button)) { slideshow_save_image(winwid); diff --git a/src/slideshow.c b/src/slideshow.c index 00425d1..2cc8c4f 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -397,6 +397,14 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid) if ((*c == '%') && (*(c+1) != '\0')) { c++; switch (*c) { + case 'a': + if (opt.paused == 1) { + strncat(ret, "pause", sizeof(ret) - strlen(ret) - 1); + } + else { + strncat(ret, "play", sizeof(ret) - strlen(ret) - 1); + } + break; case 'f': if (file) strncat(ret, file->filename, sizeof(ret) - strlen(ret) - 1); -- cgit v1.2.3 From b393f3758ab5ead64cf027f09ab3471f4f8e2cc1 Mon Sep 17 00:00:00 2001 From: reiseb <48870100+reiseb@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:20:47 +0200 Subject: fix indentation (all tabs) --- src/slideshow.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/slideshow.c b/src/slideshow.c index 2cc8c4f..d9f33de 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -397,14 +397,14 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid) if ((*c == '%') && (*(c+1) != '\0')) { c++; switch (*c) { - case 'a': - if (opt.paused == 1) { - strncat(ret, "pause", sizeof(ret) - strlen(ret) - 1); - } - else { - strncat(ret, "play", sizeof(ret) - strlen(ret) - 1); - } - break; + case 'a': + if (opt.paused == 1) { + strncat(ret, "pause", sizeof(ret) - strlen(ret) - 1); + } + else { + strncat(ret, "play", sizeof(ret) - strlen(ret) - 1); + } + break; case 'f': if (file) strncat(ret, file->filename, sizeof(ret) - strlen(ret) - 1); -- cgit v1.2.3 From 5dc616eadfd3e66cb89e9fc22c714c2edd2a77f2 Mon Sep 17 00:00:00 2001 From: reiseb <48870100+reiseb@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:21:03 +0200 Subject: change play/pause to playing/paused to improve UX --- man/feh.pre | 2 +- src/help.raw | 2 +- src/slideshow.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/man/feh.pre b/man/feh.pre index b70d948..faedce1 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -1206,7 +1206,7 @@ file . .It %a . -Information about slideshow state (play/pause) +Information about slideshow state (playing/paused) . .It %f . diff --git a/src/help.raw b/src/help.raw index 0a87b70..e0fb62a 100644 --- a/src/help.raw +++ b/src/help.raw @@ -124,7 +124,7 @@ INDEX MODE OPTIONS font is specified, a title will not be printed FORMAT SPECIFIERS - %a information about slideshow state (play/pause) + %a information about slideshow state (playing/paused) %f image path/filename %F image path/filename (shell-escaped) %g window dimensions (\"width,height\") in pixels diff --git a/src/slideshow.c b/src/slideshow.c index d9f33de..03e8e06 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -399,10 +399,10 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid) switch (*c) { case 'a': if (opt.paused == 1) { - strncat(ret, "pause", sizeof(ret) - strlen(ret) - 1); + strncat(ret, "paused", sizeof(ret) - strlen(ret) - 1); } else { - strncat(ret, "play", sizeof(ret) - strlen(ret) - 1); + strncat(ret, "playing", sizeof(ret) - strlen(ret) - 1); } break; case 'f': -- cgit v1.2.3 From f0361c5ea6fcdc181863286dbe4de36003eccb9d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 17 Jun 2020 19:10:36 +0200 Subject: toggle_pause: Re-render the image instead of reloading When the slideshow state is toggled, the info line needs to be redrawn as it may use the %a format specifier (which shows whether the slideshow is running or paused). feh_reload_image does this, but also resets all pan and zoom options and reloads the image from disk. winwidget_render_image only redraws info, caption and similar lines in this case, which is more efficient and does not incur unwanted side-effects. --- src/keyevents.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/keyevents.c b/src/keyevents.c index 761ec3c..a5526a2 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -710,8 +710,8 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy } else if (feh_is_kp(EVENT_toggle_pause, state, keysym, button)) { slideshow_pause_toggle(winwid); - /* We need to reload the image to update the info string immediately. */ - feh_reload_image(winwid, 0, 0); + /* We need to re-render the image to update the info string immediately. */ + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(EVENT_save_image, state, keysym, button)) { slideshow_save_image(winwid); -- cgit v1.2.3