summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2012-12-24 14:28:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2012-12-24 14:28:03 +0100
commit2acfecee31b8b4102210b79796604dc33bee864a (patch)
tree81c55ba18ebbb434c3160f8daf8b7cd3bd6151d8
parent88979e43155a838b4298bfaa4b6e43813a75a54b (diff)
Fix list_jump in thumbnail mode + thumbnail mode selection rollover (closes #115)
-rw-r--r--ChangeLog2
-rw-r--r--src/keyevents.c5
-rw-r--r--src/thumbnail.c41
3 files changed, 32 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 03a7ffe..bb42732 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@ git HEAD
<https://github.com/derf/feh/issues/113>
* Respect --start-at in thumbnail mode
<https://github.com/derf/feh/issues/116>
+ * Make 'z' (jump_random) work in thumbnail mode as well, fix thumbnail
+ selection roll-over <https://github.com/derf/feh/issues/115>
Tue, 16 Oct 2012 06:29:58 +0200 Daniel Friesel <derf+feh@finalrewind.org>
diff --git a/src/keyevents.c b/src/keyevents.c
index 18853ed..470d624 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -658,7 +658,10 @@ void feh_event_handle_keypress(XEvent * ev)
opt.hide_pointer = !opt.hide_pointer;
}
else if (feh_is_kp(&keys.jump_random, keysym, state)) {
- slideshow_change_image(winwid, SLIDE_RAND, 1);
+ if (winwid->type == WIN_TYPE_THUMBNAIL)
+ feh_thumbnail_select_next(winwid, rand() % (filelist_len - 1));
+ else
+ slideshow_change_image(winwid, SLIDE_RAND, 1);
}
else if (feh_is_kp(&keys.toggle_caption, keysym, state)) {
if (opt.caption_path) {
diff --git a/src/thumbnail.c b/src/thumbnail.c
index da14760..a77152a 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -786,36 +786,47 @@ void feh_thumbnail_select(winwidget winwid, feh_thumbnail *thumbnail)
void feh_thumbnail_select_next(winwidget winwid, int jump)
{
- gib_list *l, *tmp;
- int i;
+ gib_list *l;
+ feh_thumbnail *thumb;
+ int len = 0, cur = 0, target = 0;
- for (l = thumbnails; l && l->next; l = l->next) {
- tmp = l;
- for (i = jump; (i > 0) && tmp->next; i--)
- tmp = tmp->next;
- if (tmp->data == td.selected)
- break;
+ for (l = thumbnails; l; l = l->next) {
+ thumb = FEH_THUMB(l->data);
+ if (thumb == td.selected)
+ cur = len;
+ len++;
}
- feh_thumbnail_select(winwid, FEH_THUMB(l->data));
+ target = (cur + len - jump) % len;
+
+ for (l = thumbnails; l; l = l->next) {
+ if (target-- == 0) {
+ feh_thumbnail_select(winwid, FEH_THUMB(l->data));
+ }
+ }
}
void feh_thumbnail_select_prev(winwidget winwid, int jump)
{
gib_list *l;
feh_thumbnail *thumb;
- int i;
+ int len = 0, cur = 0, target = 0;
for (l = thumbnails; l; l = l->next) {
thumb = FEH_THUMB(l->data);
- if ((thumb == td.selected) && l->next) {
- for (i = jump; (i > 0) && l->next; i--)
- l = l->next;
+ if (thumb == td.selected)
+ cur = len;
+ len++;
+ }
+
+ target = (cur + jump) % len;
+
+ for (l = thumbnails; l; l = l->next) {
+ if (target-- == 0) {
feh_thumbnail_select(winwid, FEH_THUMB(l->data));
- return;
+ break;
}
}
- feh_thumbnail_select(winwid, FEH_THUMB(thumbnails->data));
}
inline void feh_thumbnail_show_selected()