Commit 6d84a1d2 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Code cleanup

parent 58e7ef40
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -347,7 +347,6 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
				winwidget_destroy(winwid);
		} else if (winwid->type == WIN_TYPE_THUMBNAIL) {
			feh_file *thumbfile;
			/* also see events.c:306 */
			thumbfile = feh_thumbnail_get_selected_file();

			if (thumbfile) {
@@ -356,8 +355,6 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
				if (!opt.hold_actions[action])
					feh_thumbnail_mark_removed(thumbfile, 0);
			}
			else
				weprintf("No thumbnail selected");
		}
	}
	return;
+1 −8
Original line number Diff line number Diff line
@@ -743,7 +743,7 @@ static void check_options(void)
	}

	if (opt.full_screen && opt.multiwindow) {
		eprintf("You cannot combine --full-screen with --multiwindow");
		eprintf("You cannot combine --fullscreen with --multiwindow");
	}

	if (opt.list && (opt.multiwindow || opt.index || opt.collage)) {
@@ -760,13 +760,6 @@ static void check_options(void)
		eprintf("You cannot combine --loadable with --unloadable");
	}

	if (opt.thumb_title && (!opt.thumbs)) {
		weprintf("Doesn't make sense to set thumbnail title when not in\n"
				"thumbnail mode.\n");
		free(opt.thumb_title);
		opt.thumb_title = NULL;
	}

	return;
}

+10 −20
Original line number Diff line number Diff line
@@ -475,15 +475,13 @@ void feh_thumbnail_mark_removed(feh_file * file, int deleted)
	if (thumb) {
		w = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL);
		if (w) {
			td.font_main = imlib_load_font(DEFAULT_FONT_TITLE);
			int tw, th;
			if (deleted)
				gib_imlib_image_fill_rectangle(w->im, thumb->x, thumb->y,
						thumb->w, thumb->h, 255, 0, 0, 150);
			else
				gib_imlib_image_fill_rectangle(w->im, thumb->x, thumb->y,
						thumb->w, thumb->h, 0, 0, 255, 150);
			if (td.font_main) {
				int tw, th;

			gib_imlib_get_text_size(td.font_main, "X", NULL, &tw, &th,
					IMLIB_TEXT_TO_RIGHT);
@@ -491,8 +489,6 @@ void feh_thumbnail_mark_removed(feh_file * file, int deleted)
					thumb->x + ((thumb->w - tw) / 2),
					thumb->y + ((thumb->h - th) / 2), "X",
					IMLIB_TEXT_TO_RIGHT, 205, 205, 50, 255);
			} else
				weprintf(DEFAULT_FONT_TITLE);
			winwidget_render_image(w, 0, 1);
		}
		thumb->exists = 0;
@@ -502,12 +498,6 @@ void feh_thumbnail_mark_removed(feh_file * file, int deleted)

void feh_thumbnail_calculate_geometry(void)
{
	gib_list *l;
	feh_file *file;

	int x = 0, y = 0;
	int fw, fh;

	if (!opt.limit_w && !opt.limit_h) {
		if (td.im_bg) {
			opt.limit_w = td.bg_w;
@@ -843,13 +833,13 @@ int feh_thumbnail_setup_thumbnail_dir(void)

			if (stat(dir_thumbnails, &sb) != 0) {
				if (mkdir(dir_thumbnails, 0700) == -1)
					weprintf("unable to create %s directory", dir_thumbnails);
					weprintf("unable to create directory %s", dir_thumbnails);
			}

			free(dir_thumbnails);

			if (mkdir(dir, 0700) == -1)
				weprintf("unable to create %s directory", dir);
				weprintf("unable to create directory %s", dir);
			else
				status = 1;
		}
+26 −18
Original line number Diff line number Diff line
@@ -99,11 +99,13 @@ static void feh_wm_set_bg_scaled(Pixmap pmap, Imlib_Image im, int use_filelist,
static void feh_wm_set_bg_centered(Pixmap pmap, Imlib_Image im, int use_filelist,
		int x, int y, int w, int h)
{
	int offset_x, offset_y;

	if (use_filelist)
		feh_wm_load_next(&im);

	int offset_x = (w - gib_imlib_image_get_width(im)) >> 1;
	int offset_y = (h - gib_imlib_image_get_height(im)) >> 1;
	offset_x = (w - gib_imlib_image_get_width(im)) >> 1;
	offset_y = (h - gib_imlib_image_get_height(im)) >> 1;

	gib_imlib_render_image_part_on_drawable_at_size(pmap, im,
		((offset_x < 0) ? -offset_x : 0),
@@ -125,19 +127,22 @@ static void feh_wm_set_bg_centered(Pixmap pmap, Imlib_Image im, int use_filelist
static void feh_wm_set_bg_filled(Pixmap pmap, Imlib_Image im, int use_filelist,
		int x, int y, int w, int h)
{
	int img_w, img_h, cut_x;
	int render_w, render_h, render_x, render_y;

	if (use_filelist)
		feh_wm_load_next(&im);

	int img_w = gib_imlib_image_get_width(im);
	int img_h = gib_imlib_image_get_height(im);
	img_w = gib_imlib_image_get_width(im);
	img_h = gib_imlib_image_get_height(im);

	int cut_x = (((img_w * h) > (img_h * w)) ? 1 : 0);
	cut_x = (((img_w * h) > (img_h * w)) ? 1 : 0);

	int render_w = (  cut_x ? ((img_h * w) / h) : img_w);
	int render_h = ( !cut_x ? ((img_w * h) / w) : img_h);
	render_w = (  cut_x ? ((img_h * w) / h) : img_w);
	render_h = ( !cut_x ? ((img_w * h) / w) : img_h);

	int render_x = (  cut_x ? ((img_w - render_w) >> 1) : 0);
	int render_y = ( !cut_x ? ((img_h - render_h) >> 1) : 0);
	render_x = (  cut_x ? ((img_w - render_w) >> 1) : 0);
	render_y = ( !cut_x ? ((img_h - render_h) >> 1) : 0);

	gib_imlib_render_image_part_on_drawable_at_size(pmap, im,
		render_x, render_y,
@@ -154,19 +159,22 @@ static void feh_wm_set_bg_filled(Pixmap pmap, Imlib_Image im, int use_filelist,
static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist,
		int x, int y, int w, int h)
{
	int img_w, img_h, border_x;
	int render_w, render_h, render_x, render_y;

	if (use_filelist)
		feh_wm_load_next(&im);

	int img_w = gib_imlib_image_get_width(im);
	int img_h = gib_imlib_image_get_height(im);
	img_w = gib_imlib_image_get_width(im);
	img_h = gib_imlib_image_get_height(im);

	int border_x = (((img_w * h) > (img_h * w)) ? 0 : 1);
	border_x = (((img_w * h) > (img_h * w)) ? 0 : 1);

	int render_w = (  border_x ? ((img_w * h) / img_h) : w);
	int render_h = ( !border_x ? ((img_h * w) / img_w) : h);
	render_w = (  border_x ? ((img_w * h) / img_h) : w);
	render_h = ( !border_x ? ((img_h * w) / img_w) : h);

	int render_x = x + (  border_x ? ((w - render_w) >> 1) : 0);
	int render_y = y + ( !border_x ? ((h - render_h) >> 1) : 0);
	render_x = x + (  border_x ? ((w - render_w) >> 1) : 0);
	render_y = y + ( !border_x ? ((h - render_h) >> 1) : 0);

	gib_imlib_render_image_on_drawable_at_size(pmap, im,
		render_x, render_y,
@@ -394,7 +402,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
				char *path;
				path = estrjoin("/", home, ".fehbg", NULL);
				if ((fp = fopen(path, "w")) == NULL) {
					weprintf("Can't open %s for write", path);
					weprintf("Can't write to %s", path);
				} else {
					fprintf(fp, "%s\n", fehbg);
					fclose(fp);
@@ -445,7 +453,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
		prop_esetroot = XInternAtom(disp2, "ESETROOT_PMAP_ID", False);

		if (prop_root == None || prop_esetroot == None)
			weprintf("creation of pixmap property failed.");
			eprintf("creation of pixmap property failed.");

		XChangeProperty(disp2, root2, prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pmap_d2, 1);
		XChangeProperty(disp2, root2, prop_esetroot, XA_PIXMAP, 32,