diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/events.c | 2 | ||||
-rw-r--r-- | src/keyevents.c | 13 | ||||
-rw-r--r-- | src/thumbnail.c | 40 | ||||
-rw-r--r-- | src/thumbnail.h | 5 |
4 files changed, 56 insertions, 4 deletions
diff --git a/src/events.c b/src/events.c index 5fa44c1..30b6b1a 100644 --- a/src/events.c +++ b/src/events.c @@ -498,7 +498,7 @@ static void feh_event_handle_MotionNotify(XEvent * ev) x = (ev->xbutton.x - winwid->im_x) / winwid->zoom; y = (ev->xbutton.y - winwid->im_y) / winwid->zoom; thumbnail = feh_thumbnail_get_thumbnail_from_coords(x, y); - feh_thumbnail_mark_selected(winwid, thumbnail); + feh_thumbnail_select(winwid, thumbnail); } } return; diff --git a/src/keyevents.c b/src/keyevents.c index b68a394..381be50 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -421,10 +421,14 @@ void feh_event_handle_keypress(XEvent * ev) if (feh_is_kp(&keys.next_img, keysym, state)) { if (opt.slideshow) slideshow_change_image(winwid, SLIDE_NEXT); + else if (opt.thumbs) + feh_thumbnail_select_next(winwid, 1); } else if (feh_is_kp(&keys.prev_img, keysym, state)) { if (opt.slideshow) slideshow_change_image(winwid, SLIDE_PREV); + else if (opt.thumbs) + feh_thumbnail_select_prev(winwid, 1); } else if (feh_is_kp(&keys.scroll_right, keysym, state)) { winwid->im_x -= 20; @@ -445,10 +449,14 @@ void feh_event_handle_keypress(XEvent * ev) else if (feh_is_kp(&keys.jump_back, keysym, state)) { if (opt.slideshow) slideshow_change_image(winwid, SLIDE_JUMP_BACK); + else if (opt.thumbs) + feh_thumbnail_select_prev(winwid, 10); } else if (feh_is_kp(&keys.jump_fwd, keysym, state)) { if (opt.slideshow) slideshow_change_image(winwid, SLIDE_JUMP_FWD); + else if (opt.thumbs) + feh_thumbnail_select_next(winwid, 10); } else if (feh_is_kp(&keys.quit, keysym, state)) { winwidget_destroy_all(); @@ -533,7 +541,10 @@ void feh_event_handle_keypress(XEvent * ev) winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.render, keysym, state)) { - winwidget_render_image(winwid, 0, 0); + if (opt.thumbs) + feh_thumbnail_show_selected(); + else + winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.toggle_actions, keysym, state)) { opt.draw_actions = !opt.draw_actions; diff --git a/src/thumbnail.c b/src/thumbnail.c index e997364..ee8b101 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -926,7 +926,7 @@ void feh_thumbnail_show_fullsize(feh_file *thumbfile) } } -void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail) +void feh_thumbnail_select(winwidget winwid, feh_thumbnail *thumbnail) { Imlib_Image origwin; @@ -959,7 +959,45 @@ void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail) td.selected = thumbnail; } +void feh_thumbnail_select_next(winwidget winwid, int jump) +{ + gib_list *l, *tmp; + int i; + + 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; + } + + 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; + + 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; + feh_thumbnail_select(winwid, FEH_THUMB(l->data)); + return; + } + } + feh_thumbnail_select(winwid, FEH_THUMB(thumbnails->data)); +} + +inline void feh_thumbnail_show_selected() +{ + if (td.selected && td.selected->file) + feh_thumbnail_show_fullsize(td.selected->file); +} int feh_thumbnail_setup_thumbnail_dir(void) { diff --git a/src/thumbnail.h b/src/thumbnail.h index 5bc2864..a70b603 100644 --- a/src/thumbnail.h +++ b/src/thumbnail.h @@ -82,7 +82,10 @@ char *feh_thumbnail_get_name(char *uri); char *feh_thumbnail_get_name_uri(char *name); char *feh_thumbnail_get_name_md5(char *uri); void feh_thumbnail_show_fullsize(feh_file *thumbfile); -void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail); +void feh_thumbnail_select(winwidget winwid, feh_thumbnail *thumbnail); +void feh_thumbnail_select_next(winwidget winwid, int jump); +void feh_thumbnail_select_prev(winwidget winwid, int jump); +void feh_thumbnail_show_selected(); int feh_thumbnail_setup_thumbnail_dir(void); |