summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-05-02 19:22:30 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-05-02 19:22:30 +0200
commit85fba735f87bb9aae2894f658d4b6c470fbe672a (patch)
tree99d1a17a9107ceba487f78c233f032a615f49bd5
parent873aecef62bfca4ab25a9471b4bf4f98844c846c (diff)
Use next/prev/render keys to select images in thumbnail mode (closes #26)
-rw-r--r--ChangeLog3
-rw-r--r--src/events.c2
-rw-r--r--src/keyevents.c13
-rw-r--r--src/thumbnail.c40
-rw-r--r--src/thumbnail.h5
5 files changed, 59 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 234b343..91f0d68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@ git HEAD
* Since the manual is way better structured and more detailed than the
--help output, it now simply refers to the manual. To include the old
help text, build feh with 'help=1'
+ * You can now use the next/prev/jump keys to navigate thumbnails. Use the
+ render key to open the currently selected thumbnail.
+ <http://github.com/derf/feh/issues/26>
Sat, 23 Apr 2011 22:00:27 +0200 Daniel Friesel <derf@finalrewind.org>
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);