summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-11 20:30:06 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-11 20:34:58 +0200
commit64e9c952f0bbd5c23fd775620f3df1c261799ed6 (patch)
tree9bbd40e8ed8af7f17664269f59ce10c27a1215bd
parent03e54647e9ffd21a47cd608f662b5e2cb9a0f7c5 (diff)
Show correct file number after deleting image
In the image_remove function, slideshow_change_image needs to be called before removing the image from the filelist. Because of this, the "x of y" displayed by --draw-filename is wrong (y is 1 too high). This commit introduces a new 'render' argument to slideshow_chingae_image. The image_remove function calls it with render=0, edits the filelist and then runs by winwidget_render_image itself. Patch by Yu-Jie Lin.
-rw-r--r--ChangeLog2
-rw-r--r--src/events.c6
-rw-r--r--src/feh.h2
-rw-r--r--src/keyevents.c16
-rw-r--r--src/menu.c8
-rw-r--r--src/signals.c4
-rw-r--r--src/slideshow.c10
7 files changed, 26 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 5dabcd7..cf50fd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ git HEAD
<https://github.com/derf/feh/issues/53>
* Fix save_image key for *.JPG and similar filenames
<https://github.com/derf/feh/issues/51>
+ * Show correct file number after deleting image
+ <https://github.com/derf/feh/issues/46>
Mon, 04 Jul 2011 14:46:36 +0200 Daniel Friesel <derf@finalrewind.org>
diff --git a/src/events.c b/src/events.c
index 30b6b1a..f76de9f 100644
--- a/src/events.c
+++ b/src/events.c
@@ -130,12 +130,12 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
D(("Prev Button Press event\n"));
if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_SLIDESHOW))
- slideshow_change_image(winwid, SLIDE_PREV);
+ slideshow_change_image(winwid, SLIDE_PREV, 1);
} else if (ev->xbutton.button == opt.next_button) {
D(("Next Button Press event\n"));
if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_SLIDESHOW))
- slideshow_change_image(winwid, SLIDE_NEXT);
+ slideshow_change_image(winwid, SLIDE_NEXT, 1);
} else {
D(("Received other ButtonPress event\n"));
}
@@ -191,7 +191,7 @@ static void feh_event_handle_ButtonRelease(XEvent * ev)
winwid->mode = MODE_NORMAL;
if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_SLIDESHOW)) {
- slideshow_change_image(winwid, SLIDE_NEXT);
+ slideshow_change_image(winwid, SLIDE_NEXT, 1);
} else if ((winwid != NULL)
&& (winwid->type == WIN_TYPE_THUMBNAIL)) {
feh_file *thumbfile;
diff --git a/src/feh.h b/src/feh.h
index 7b46a25..6af425c 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -121,7 +121,7 @@ void init_unloadables_mode(void);
void feh_clean_exit(void);
int feh_load_image(Imlib_Image * im, feh_file * file);
void show_mini_usage(void);
-void slideshow_change_image(winwidget winwid, int change);
+void slideshow_change_image(winwidget winwid, int change, int render);
void slideshow_pause_toggle(winwidget w);
char *slideshow_create_name(feh_file * file);
void init_keyevents(void);
diff --git a/src/keyevents.c b/src/keyevents.c
index 0d68f02..7299fa8 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -334,7 +334,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
winwidget_update_caption(winwid);
if (! opt.hold_actions[action])
- slideshow_change_image(winwid, SLIDE_NEXT);
+ slideshow_change_image(winwid, SLIDE_NEXT, 1);
} else if ((winwid->type == WIN_TYPE_SINGLE)
|| (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
@@ -448,13 +448,13 @@ 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);
+ slideshow_change_image(winwid, SLIDE_NEXT, 1);
else if (winwid->type == WIN_TYPE_THUMBNAIL)
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);
+ slideshow_change_image(winwid, SLIDE_PREV, 1);
else if (winwid->type == WIN_TYPE_THUMBNAIL)
feh_thumbnail_select_prev(winwid, 1);
}
@@ -492,13 +492,13 @@ 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);
+ slideshow_change_image(winwid, SLIDE_JUMP_BACK, 1);
else if (winwid->type == WIN_TYPE_THUMBNAIL)
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);
+ slideshow_change_image(winwid, SLIDE_JUMP_FWD, 1);
else if (winwid->type == WIN_TYPE_THUMBNAIL)
feh_thumbnail_select_next(winwid, 10);
}
@@ -517,11 +517,11 @@ void feh_event_handle_keypress(XEvent * ev)
}
else if (feh_is_kp(&keys.jump_first, keysym, state)) {
if (opt.slideshow)
- slideshow_change_image(winwid, SLIDE_FIRST);
+ slideshow_change_image(winwid, SLIDE_FIRST, 1);
}
else if (feh_is_kp(&keys.jump_last, keysym, state)) {
if (opt.slideshow)
- slideshow_change_image(winwid, SLIDE_LAST);
+ slideshow_change_image(winwid, SLIDE_LAST, 1);
}
else if (feh_is_kp(&keys.action_0, keysym, state)) {
feh_event_invoke_action(winwid, 0);
@@ -617,7 +617,7 @@ 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);
+ 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/menu.c b/src/menu.c
index 7a70368..16e1c77 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1321,25 +1321,25 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, void *data)
case CB_SORT_FILENAME:
filelist = gib_list_sort(filelist, feh_cmp_filename);
if (opt.jump_on_resort) {
- slideshow_change_image(m->fehwin, SLIDE_FIRST);
+ slideshow_change_image(m->fehwin, SLIDE_FIRST, 1);
}
break;
case CB_SORT_IMAGENAME:
filelist = gib_list_sort(filelist, feh_cmp_name);
if (opt.jump_on_resort) {
- slideshow_change_image(m->fehwin, SLIDE_FIRST);
+ slideshow_change_image(m->fehwin, SLIDE_FIRST, 1);
}
break;
case CB_SORT_FILESIZE:
filelist = gib_list_sort(filelist, feh_cmp_size);
if (opt.jump_on_resort) {
- slideshow_change_image(m->fehwin, SLIDE_FIRST);
+ slideshow_change_image(m->fehwin, SLIDE_FIRST, 1);
}
break;
case CB_SORT_RANDOMIZE:
filelist = gib_list_randomize(filelist);
if (opt.jump_on_resort) {
- slideshow_change_image(m->fehwin, SLIDE_FIRST);
+ slideshow_change_image(m->fehwin, SLIDE_FIRST, 1);
}
break;
case CB_FIT:
diff --git a/src/signals.c b/src/signals.c
index 956c861..d5a6899 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -65,9 +65,9 @@ void feh_handle_signal(int signo)
if (winwid) {
if (signo == SIGUSR1)
- slideshow_change_image(winwid, SLIDE_NEXT);
+ slideshow_change_image(winwid, SLIDE_NEXT, 1);
else if (signo == SIGUSR2)
- slideshow_change_image(winwid, SLIDE_PREV);
+ slideshow_change_image(winwid, SLIDE_PREV, 1);
} else if (opt.multiwindow) {
for (i = window_num - 1; i >= 0; i--)
feh_reload_image(windows[i], 0, 0);
diff --git a/src/slideshow.c b/src/slideshow.c
index 25fca03..f33ae9e 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -83,7 +83,7 @@ void init_slideshow_mode(void)
void cb_slide_timer(void *data)
{
- slideshow_change_image((winwidget) data, SLIDE_NEXT);
+ slideshow_change_image((winwidget) data, SLIDE_NEXT, 1);
return;
}
@@ -170,7 +170,7 @@ void feh_reload_image(winwidget w, int resize, int force_new)
return;
}
-void slideshow_change_image(winwidget winwid, int change)
+void slideshow_change_image(winwidget winwid, int change, int render)
{
gib_list *last = NULL;
int i = 0;
@@ -260,7 +260,8 @@ void slideshow_change_image(winwidget winwid, int change)
winwidget_reset_image(winwid);
winwid->im_w = gib_imlib_image_get_width(winwid->im);
winwid->im_h = gib_imlib_image_get_height(winwid->im);
- winwidget_render_image(winwid, 1, 0);
+ if (render)
+ winwidget_render_image(winwid, 1, 0);
s = slideshow_create_name(FEH_FILE(current_file->data));
winwidget_rename(winwid, s);
@@ -428,7 +429,7 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)
gib_list *doomed;
doomed = current_file;
- slideshow_change_image(winwid, SLIDE_NEXT);
+ slideshow_change_image(winwid, SLIDE_NEXT, 0);
if (do_delete)
filelist = feh_file_rm_and_free(filelist, doomed);
else
@@ -441,6 +442,7 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)
s = slideshow_create_name(FEH_FILE(winwid->file->data));
winwidget_rename(winwid, s);
free(s);
+ winwidget_render_image(winwid, 1, 0);
} else if ((winwid->type == WIN_TYPE_SINGLE)
|| (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
if (do_delete)