From 2e017bbfbf3e9554bd54b98d11c5532d55b02f6c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Sep 2011 17:42:16 +0200 Subject: Use enum for opt.image_bg, rename --image-bg default to --image-bg checks --- src/feh.h | 2 ++ src/options.c | 11 ++++++++--- src/options.h | 2 +- src/winwidget.c | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src') 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); -- cgit v1.2.3