summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-13 17:42:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-13 17:42:16 +0200
commit2e017bbfbf3e9554bd54b98d11c5532d55b02f6c (patch)
tree46ad0f48dfcc71d01163f4361449f55fa4e60642 /src
parentaf2a44237a7b5cebbf0d03375ed742809da15a59 (diff)
Use enum for opt.image_bg, rename --image-bg default to --image-bg checks
Diffstat (limited to 'src')
-rw-r--r--src/feh.h2
-rw-r--r--src/options.c11
-rw-r--r--src/options.h2
-rw-r--r--src/winwidget.c6
4 files changed, 14 insertions, 7 deletions
diff --git a/src/feh.h b/src/feh.h
index 6604f66..4de4632 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -102,6 +102,8 @@ enum slide_change { SLIDE_NEXT, SLIDE_PREV, SLIDE_RAND, SLIDE_FIRST, SLIDE_LAST,
SLIDE_JUMP_BACK
};
+enum image_bg { IMAGE_BG_CHECKS = 0, IMAGE_BG_BLACK, IMAGE_BG_WHITE };
+
#define INPLACE_EDIT_FLIP -1
#define INPLACE_EDIT_MIRROR -2
diff --git a/src/options.c b/src/options.c
index fe0cf87..cf32bb0 100644
--- a/src/options.c
+++ b/src/options.c
@@ -58,7 +58,6 @@ void init_parse_options(int argc, char **argv)
opt.thumb_redraw = 10;
opt.menu_font = estrdup(DEFAULT_MENU_FONT);
opt.font = NULL;
- opt.image_bg = estrdup("default");
opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png");
opt.menu_style = estrdup(PREFIX "/share/feh/fonts/menu.style");
@@ -606,8 +605,14 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
weprintf("The --menu-bg option is deprecated and will be removed by 2012");
break;
case 'B':
- free(opt.image_bg);
- opt.image_bg = estrdup(optarg);
+ if (!strcmp(optarg, "checks"))
+ opt.image_bg = IMAGE_BG_CHECKS;
+ else if (!strcmp(optarg, "white"))
+ opt.image_bg = IMAGE_BG_WHITE;
+ else if (!strcmp(optarg, "black"))
+ opt.image_bg = IMAGE_BG_BLACK;
+ else
+ weprintf("Unknown argument to --image-bg: %s", optarg);
break;
case 'D':
opt.slideshow_delay = atof(optarg);
diff --git a/src/options.h b/src/options.h
index 2ca655e..ae3a707 100644
--- a/src/options.h
+++ b/src/options.h
@@ -70,6 +70,7 @@ struct __fehoptions {
unsigned char cycle_once;
unsigned char hold_actions[10];
unsigned char text_bg;
+ unsigned char image_bg;
char *output_file;
char *output_dir;
@@ -84,7 +85,6 @@ struct __fehoptions {
char *menu_font;
char *customlist;
char *menu_bg;
- char *image_bg;
char *menu_style;
char *caption_path;
char *start_list_at;
diff --git a/src/winwidget.c b/src/winwidget.c
index 8851f90..bc530ee 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -350,7 +350,7 @@ void winwidget_setup_pixmaps(winwidget winwid)
if (winwid->gc == None) {
XGCValues gcval;
- if (!strcmp(opt.image_bg, "white"))
+ if (opt.image_bg == IMAGE_BG_WHITE)
gcval.foreground = WhitePixel(disp, DefaultScreen(disp));
else
gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
@@ -626,9 +626,9 @@ Pixmap feh_create_checks(void)
if (!checks)
eprintf("Unable to create a teeny weeny imlib image. I detect problems");
- if (strncmp(opt.image_bg, "white", 5) == 0)
+ if (opt.image_bg == IMAGE_BG_WHITE)
gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 255, 255, 255, 255);
- else if (strncmp(opt.image_bg, "black", 5) == 0)
+ else if (opt.image_bg == IMAGE_BG_BLACK)
gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 0, 0, 0, 255);
else {
gib_imlib_image_fill_rectangle(checks, 0, 0, 16, 16, 144, 144, 144, 255);