From ff030be3737d1f72be29f9e9f8940079a76c4afd Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 11 Feb 2010 09:04:22 +0100 Subject: Finish --draw-actions and add it to documentation --- TODO | 3 --- feh.1 | 5 ++++- src/imlib.c | 56 ++++++++++++++++++++++++++++++++++---------------------- src/options.c | 1 + 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index 1fffb9d..4e80c9e 100644 --- a/TODO +++ b/TODO @@ -9,9 +9,6 @@ overlay reminder showing what each one does :p key/option/signal/timeout to totally reload filelist (rescan directories etc) ---draw-actions doesn't work too fine. It conflicts with --draw-filename and -misses some actions if there are non-defined actions in between - The "No more slides left in show" bug was fixed, but now there's a rare condition (viewing a few images, removing them externally while viewing, then resizing the window) causing imlib2 warnings. diff --git a/feh.1 b/feh.1 index 00f8daf..e5a82c2 100644 --- a/feh.1 +++ b/feh.1 @@ -157,7 +157,7 @@ files in slideshow mode, multiple windows will be opened, one per file. Create borderless windows .TP 5 .B -d, --draw-filename -Draw the filename at the top-left of the image +Draw the filename at the top\-left of the image .TP 5 .B -D, --slideshow-delay NUM For slideshow mode, specifies time delay (seconds, can be a decimal) between automatically @@ -238,6 +238,9 @@ in multiwindow mode, the window will be closed. Extra actions which can be set and triggered using the appropriate number key. .TP 5 +.B --draw-actions +Draw the defined actions and what they do at the top\-left of the image. +.TP 5 .B -m, --montage Enable montage mode. Montage mode creates a new image consisting of a grid of thumbnails of the images in the filelist. When montage mode is selected, diff --git a/src/imlib.c b/src/imlib.c index ca999bf..6abd88a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1211,12 +1211,21 @@ feh_draw_actions(winwidget w) static DATA8 atab[256]; int i = 0; int num_actions = 0; + int cur_action = 0; + char index[1]; + char *line; D_ENTER(4); -// count the number of defined actions (this method sucks) - for (num_actions=0;opt.actions[num_actions];num_actions++) - ; + /* Count number of defined actions. This method sucks a bit since it needs + * to be changed if the number of actions changes, but at least it doesn't + * miss actions 2 to 9 if action1 isn't defined + */ + for (i = 0; i < 10; i++) { + if (opt.actions[i]) + num_actions++; + } + if (num_actions == 0) return; @@ -1244,11 +1253,13 @@ feh_draw_actions(winwidget w) // Check for the widest line max_tw = tw; - for (i = 0; opt.actions[i]; i++) { - gib_imlib_get_text_size(fn, opt.actions[i], NULL, &tw, &th, - IMLIB_TEXT_TO_RIGHT); - if (tw > max_tw) - max_tw = tw; + for (i = 0; i < 10; i++) { + if (opt.actions[i]) { + gib_imlib_get_text_size(fn, opt.actions[i], NULL, &tw, &th, + IMLIB_TEXT_TO_RIGHT); + if (tw > max_tw) + max_tw = tw; + } } tw = max_tw; @@ -1279,20 +1290,21 @@ feh_draw_actions(winwidget w) gib_imlib_text_draw(im, fn, NULL, 1, 1, "defined actions:", IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); - for(i = 0; i < num_actions; i++) - { - char index[1]; - char *line = emalloc(strlen(opt.actions[i])+5); - sprintf(index, "%d", i); - strcpy(line, index); - strcat(line, ": "); - strcat(line, opt.actions[i]); - - gib_imlib_text_draw(im, fn, NULL, 2, ((i+1)*line_th)+2, line, - IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); - gib_imlib_text_draw(im, fn, NULL, 1, ((i+1)*line_th)+1, line, - IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); - free(line); + for (i = 0; i < 10; i++) { + if (opt.actions[i]) { + cur_action++; + line = emalloc(strlen(opt.actions[i])+5); + sprintf(index, "%d", i); + strcpy(line, index); + strcat(line, ": "); + strcat(line, opt.actions[i]); + + gib_imlib_text_draw(im, fn, NULL, 2, (cur_action*line_th)+2, line, + IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); + gib_imlib_text_draw(im, fn, NULL, 1, (cur_action*line_th)+1, line, + IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); + free(line); + } } gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, 0 + th_offset, 1, 1, 0); diff --git a/src/options.c b/src/options.c index 763e1e8..44fa3bf 100644 --- a/src/options.c +++ b/src/options.c @@ -969,6 +969,7 @@ show_usage(void) " --action2 ACTION multiple additional actions which can be invoked\n" " ... using the appropriate number key 1-9\n" " --action9 ACTION\n" +" --draw-actions Show the defined actions and what they do\n" " -m, --montage Enable montage mode. Montage mode creates a new\n" " image consisting of a grid of thumbnails of the\n" " images specified using FILE... When montage mode\n" -- cgit v1.2.3