summaryrefslogtreecommitdiff
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
parentaf2a44237a7b5cebbf0d03375ed742809da15a59 (diff)
downloadfeh-2e017bbfbf3e9554bd54b98d11c5532d55b02f6c.zip
Use enum for opt.image_bg, rename --image-bg default to --image-bg checks
-rw-r--r--ChangeLog1
-rw-r--r--src/feh.h2
-rw-r--r--src/options.c11
-rw-r--r--src/options.h2
-rw-r--r--src/winwidget.c6
-rwxr-xr-xtest/feh-scr.i2
6 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ca87970..d955e8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ git HEAD
* Fix useless memory use when using feh --reload on HTTP URLs
(fun fact: strictly speaking, this was not a memory leak)
<https://github.com/derf/feh/issues/62>
+ * "--image-bg default" was renamed to "--image-bg checks"
Sun, 11 Sep 2011 12:46:50 +0200 Daniel Friesel <derf@finalrewind.org>
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);
diff --git a/test/feh-scr.i b/test/feh-scr.i
index 037f42c..c677088 100755
--- a/test/feh-scr.i
+++ b/test/feh-scr.i
@@ -312,7 +312,7 @@ feh_start(q{}, 'test/bg/transparency');
test_scr('feh_ibg_default');
feh_stop();
-feh_start('--image-bg default', 'test/bg/transparency');
+feh_start('--image-bg checks', 'test/bg/transparency');
test_scr('feh_ibg_default');
feh_stop();