summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-02-11 09:04:22 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-02-11 09:04:22 +0100
commitff030be3737d1f72be29f9e9f8940079a76c4afd (patch)
tree687a2b5de4c6fb48b1c8e7e6b275941196829350 /src
parent32136757a7201676a7ba7aead76dd962bad3482d (diff)
Finish --draw-actions and add it to documentation
Diffstat (limited to 'src')
-rw-r--r--src/imlib.c56
-rw-r--r--src/options.c1
2 files changed, 35 insertions, 22 deletions
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"