当前位置: 首页>>代码示例>>C++>>正文


C++ FEH_FILE函数代码示例

本文整理汇总了C++中FEH_FILE函数的典型用法代码示例。如果您正苦于以下问题:C++ FEH_FILE函数的具体用法?C++ FEH_FILE怎么用?C++ FEH_FILE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FEH_FILE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: feh_draw_filename

void feh_draw_filename(winwidget w)
{
	static Imlib_Font fn = NULL;
	int tw = 0, th = 0, nw = 0;
	Imlib_Image im = NULL;
	char *s = NULL;
	int len = 0;

	if ((!w->file) || (!FEH_FILE(w->file->data))
			|| (!FEH_FILE(w->file->data)->filename))
		return;

	fn = feh_load_font(w);

	/* Work out how high the font is */
	gib_imlib_get_text_size(fn, FEH_FILE(w->file->data)->filename, NULL, &tw,
			&th, IMLIB_TEXT_TO_RIGHT);

	if (gib_list_length(filelist) > 1) {
		len = snprintf(NULL, 0, "%d of %d",  gib_list_length(filelist),
				gib_list_length(filelist)) + 1;
		s = emalloc(len);
		if (w->file)
			snprintf(s, len, "%d of %d", gib_list_num(filelist, w->file) +
					1, gib_list_length(filelist));
		else
			snprintf(s, len, "%d of %d", gib_list_num(filelist, current_file) +
					1, gib_list_length(filelist));

		gib_imlib_get_text_size(fn, s, NULL, &nw, NULL, IMLIB_TEXT_TO_RIGHT);

		if (nw > tw)
			tw = nw;
	}

	tw += 3;
	th += 3;
	im = imlib_create_image(tw, 2 * th);
	if (!im)
		eprintf("Couldn't create image. Out of memory?");

	feh_imlib_image_fill_text_bg(im, tw, 2 * th);

	gib_imlib_text_draw(im, fn, NULL, 2, 2, FEH_FILE(w->file->data)->filename,
			IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
	gib_imlib_text_draw(im, fn, NULL, 1, 1, FEH_FILE(w->file->data)->filename,
			IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);

	if (s) {
		gib_imlib_text_draw(im, fn, NULL, 2, th + 1, s, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
		gib_imlib_text_draw(im, fn, NULL, 1, th, s, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);
		free(s);
	}

	gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, 0, 1, 1, 0);

	gib_imlib_free_image_and_decache(im);
	return;
}
开发者ID:Caellian,项目名称:feh,代码行数:59,代码来源:imlib.c

示例2: cb_reload_timer

void cb_reload_timer(void *data)
{
	gib_list *l;
	char *current_filename;

	winwidget w = (winwidget) data;

	/* save the current filename for refinding it in new list */
	current_filename = estrdup(FEH_FILE(current_file->data)->filename);

	for (l = filelist; l; l = l->next) {
		feh_file_free(l->data);
		l->data = NULL;
	}
	gib_list_free_and_data(filelist);
	filelist = NULL;
	filelist_len = 0;
	current_file = NULL;

	/* rebuild filelist from original_file_items */
	if (gib_list_length(original_file_items) > 0)
		for (l = gib_list_last(original_file_items); l; l = l->prev)
			add_file_to_filelist_recursively(l->data, FILELIST_FIRST);
	else if (!opt.filelistfile && !opt.bgmode)
		add_file_to_filelist_recursively(".", FILELIST_FIRST);
	
	if (!(filelist_len = gib_list_length(filelist))) {
		eprintf("No files found to reload.");
	}

	/* find the previously current file */
	for (l = filelist; l; l = l->next)
		if (strcmp(FEH_FILE(l->data)->filename, current_filename) == 0) {
			current_file = l;
			break;
		}

	free(current_filename);

	filelist = gib_list_first(gib_list_reverse(filelist));

	if (!current_file)
		current_file = filelist;
	w->file = current_file;

	/* reset window name in case of current file order,
	 * filename, or filelist_length has changed.
	 */
	current_filename = slideshow_create_name(FEH_FILE(current_file->data), w);
	winwidget_rename(w, current_filename);
	free(current_filename);

	feh_reload_image(w, 1, 0);
	if (opt.reload)
		feh_add_unique_timer(cb_reload_timer, w, opt.reload);
	return;
}
开发者ID:mscalora,项目名称:feh,代码行数:57,代码来源:slideshow.c

示例3: feh_filelist_image_remove

void feh_filelist_image_remove(winwidget winwid, char do_delete)
{
	if (winwid->type == WIN_TYPE_SLIDESHOW) {
		char *s;
		gib_list *doomed;

		doomed = current_file;
		slideshow_change_image(winwid, SLIDE_NEXT, 0);
		if (do_delete)
			filelist = feh_file_rm_and_free(filelist, doomed);
		else
			filelist = feh_file_remove_from_list(filelist, doomed);
		if (!filelist) {
			/* No more images. Game over ;-) */
			winwidget_destroy(winwid);
			return;
		}
		s = slideshow_create_name(FEH_FILE(winwid->file->data), winwid);
		winwidget_rename(winwid, s);
		free(s);
		winwidget_render_image(winwid, 1, 0);
	} else if ((winwid->type == WIN_TYPE_SINGLE)
		   || (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
		if (do_delete)
			filelist = feh_file_rm_and_free(filelist, winwid->file);
		else
			filelist = feh_file_remove_from_list(filelist, winwid->file);
		winwidget_destroy(winwid);
	}
}
开发者ID:aeroevan,项目名称:feh,代码行数:30,代码来源:slideshow.c

示例4: feh_file_free

gib_list *feh_file_remove_from_list(gib_list * list, gib_list * l)
{
	feh_file_free(FEH_FILE(l->data));
	D(("filelist_len %d -> %d\n", filelist_len, filelist_len - 1));
	filelist_len--;
	return(gib_list_remove(list, l));
}
开发者ID:uqs,项目名称:feh,代码行数:7,代码来源:filelist.c

示例5: return

static feh_menu *feh_menu_func_gen_info(feh_menu * m)
{
	Imlib_Image im;
	feh_menu *mm;
	feh_file *file;
	char buffer[400];

	if (!m->fehwin->file)
		return(NULL);
	file = FEH_FILE(m->fehwin->file->data);
	im = m->fehwin->im;
	if (!im)
		return(NULL);
	mm = feh_menu_new();
	mm->name = estrdup("INFO");
	snprintf(buffer, sizeof(buffer), "Filename: %s", file->name);
	feh_menu_add_entry(mm, buffer, NULL, NULL, 0, NULL, NULL);
	if (!file->info)
		feh_file_info_load(file, im);
	if (file->info) {
		snprintf(buffer, sizeof(buffer), "Size: %dKb", file->info->size / 1024);
		feh_menu_add_entry(mm, buffer, NULL, NULL, 0, NULL, NULL);
		snprintf(buffer, sizeof(buffer), "Dimensions: %dx%d", file->info->width, file->info->height);
		feh_menu_add_entry(mm, buffer, NULL, NULL, 0, NULL, NULL);
		snprintf(buffer, sizeof(buffer), "Type: %s", file->info->format);
		feh_menu_add_entry(mm, buffer, NULL, NULL, 0, NULL, NULL);
	}

	mm->func_free = feh_menu_func_free_info;
	return(mm);
}
开发者ID:talisein,项目名称:feh,代码行数:31,代码来源:menu.c

示例6: winwidget_create_from_file

winwidget winwidget_create_from_file(gib_list * list, char *name, char type)
{
	winwidget ret = NULL;
	feh_file *file = FEH_FILE(list->data);

	if (!file || !file->filename)
		return(NULL);

	ret = winwidget_allocate();
	ret->file = list;
	ret->type = type;
	if (name)
		ret->name = estrdup(name);
	else
		ret->name = estrdup(file->filename);

	if (winwidget_loadimage(ret, file) == 0) {
		winwidget_destroy(ret);
		return(NULL);
	}

	if (!ret->win) {
		ret->w = ret->im_w = gib_imlib_image_get_width(ret->im);
		ret->h = ret->im_h = gib_imlib_image_get_height(ret->im);
		D(("image is %dx%d pixels, format %s\n", ret->w, ret->h, gib_imlib_image_format(ret->im)));
		if (opt.full_screen)
			ret->full_screen = True;
		winwidget_create_window(ret, ret->w, ret->h);
		winwidget_render_image(ret, 1, 0);
	}

	return(ret);
}
开发者ID:phrac,项目名称:feh-browser,代码行数:33,代码来源:winwidget.c

示例7: slideshow_save_image

void slideshow_save_image(winwidget win)
{
	char *tmpname;
	Imlib_Load_Error err;

	if (win->file) {
		tmpname = feh_unique_filename("", FEH_FILE(win->file->data)->name);
	} else if (mode) {
		char *tmp;
		tmp = estrjoin(".", mode, "png", NULL);
		tmpname = feh_unique_filename("", tmp);
		free(tmp);
	} else {
		tmpname = feh_unique_filename("", "noname.png");
	}

	if (opt.verbose)
		fprintf(stderr, "saving image to filename '%s'\n", tmpname);

	ungib_imlib_save_image_with_error_return(win->im, tmpname, &err);

	if (err)
		feh_imlib_print_load_error(tmpname, win, err);

	free(tmpname);
	return;
}
开发者ID:EvinceMoi,项目名称:feh,代码行数:27,代码来源:slideshow.c

示例8: fprintf

gib_list *feh_file_info_preload(gib_list * list)
{
	gib_list *l;
	feh_file *file = NULL;
	gib_list *remove_list = NULL;

	if (opt.verbose)
		fprintf(stdout, PACKAGE " - preloading...\n");

	for (l = list; l; l = l->next) {
		file = FEH_FILE(l->data);
		D(5, ("file %p, file->next %p, file->name %s\n", l, l->next, file->name));
		if (feh_file_info_load(file, NULL)) {
			D(3, ("Failed to load file %p\n", file));
			remove_list = gib_list_add_front(remove_list, l);
			if (opt.verbose)
				feh_display_status('x');
		} else if (opt.verbose)
			feh_display_status('.');
	}
	if (opt.verbose)
		fprintf(stdout, "\n");

	if (remove_list) {
		for (l = remove_list; l; l = l->next)
			filelist = list = gib_list_remove(list, (gib_list *) l->data);

		gib_list_free(remove_list);
	}

	return(list);
}
开发者ID:trapd00r,项目名称:feh,代码行数:32,代码来源:filelist.c

示例9: slideshow_save_image

void slideshow_save_image(winwidget win)
{
	char *tmpname;
	Imlib_Load_Error err;

	if (win->file) {
		tmpname = feh_unique_filename("", FEH_FILE(win->file->data)->name);
	} else if (mode) {
		char *tmp;
		tmp = estrjoin(".", mode, "png", NULL);
		tmpname = feh_unique_filename("", tmp);
		free(tmp);
	} else {
		tmpname = feh_unique_filename("", "noname.png");
	}

	if (opt.verbose)
		printf("saving image to filename '%s'\n", tmpname);

	/* XXX gib_imlib_save_image_with_error_return breaks with *.XXX and
	 * similar because it tries to set the image format, which only works
	 * with .xxx .
	 * So we leave that part out.
	 */
	imlib_context_set_image(win->im);
	imlib_save_image_with_error_return(tmpname, &err);

	if (err)
		im_weprintf(win, "Can't save image %s:", tmpname);

	free(tmpname);
	return;
}
开发者ID:aeroevan,项目名称:feh,代码行数:33,代码来源:slideshow.c

示例10: init_slideshow_mode

void init_slideshow_mode(void)
{
	winwidget w = NULL;
	int success = 0;
	char *s = NULL;
	gib_list *l = filelist, *last = NULL;
	feh_file *file = NULL;

	for (; l && opt.start_list_at; l = l->next) {
		if (!strcmp(opt.start_list_at, FEH_FILE(l->data)->filename)) {
			opt.start_list_at = NULL;
			break;
		}
	}

	if (opt.start_list_at)
		eprintf("--start-at %s: File not found in filelist",
				opt.start_list_at);

	mode = "slideshow";
	for (; l; l = l->next) {
		file = FEH_FILE(l->data);
		if (last) {
			filelist = feh_file_remove_from_list(filelist, last);
			last = NULL;
		}
		current_file = l;
		s = slideshow_create_name(file, NULL);
		if ((w = winwidget_create_from_file(l, s, WIN_TYPE_SLIDESHOW)) != NULL) {
			free(s);
			success = 1;
			winwidget_show(w);
			if (opt.slideshow_delay > 0.0)
				feh_add_timer(cb_slide_timer, w, opt.slideshow_delay, "SLIDE_CHANGE");
			if (opt.reload > 0)
				feh_add_unique_timer(cb_reload_timer, w, opt.reload);
			break;
		} else {
			free(s);
			last = l;
		}
	}
	if (!success)
		show_mini_usage();

	return;
}
开发者ID:EvinceMoi,项目名称:feh,代码行数:47,代码来源:slideshow.c

示例11: delete_rm_files

void delete_rm_files(void)
{
	gib_list *l;

	for (l = rm_filelist; l; l = l->next)
		unlink(FEH_FILE(l->data)->filename);
	return;
}
开发者ID:trapd00r,项目名称:feh,代码行数:8,代码来源:filelist.c

示例12: feh_event_invoke_action

void feh_event_invoke_action(winwidget winwid, char *action)
{
	D_ENTER(4);
	D(4, ("action is '%s'\n", action));
	D(4, ("winwid is '%p'\n", winwid));
	if (action) {
		if (opt.slideshow) {
			feh_action_run(FEH_FILE(winwid->file->data), action);
			slideshow_change_image(winwid, SLIDE_NEXT);
		} else if ((winwid->type == WIN_TYPE_SINGLE)
				|| (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER)) {
			feh_action_run(FEH_FILE(winwid->file->data), action);
			winwidget_destroy(winwid);
		} else if (winwid->type == WIN_TYPE_THUMBNAIL) {
			printf("actions from the main thumb window aren't currentl supported!\n");
			printf("For now, open the image to perform the action on it.\n");
		}
	}
	D_RETURN_(4);
}
开发者ID:decklin,项目名称:feh,代码行数:20,代码来源:keyevents.c

示例13: feh_edit_inplace

void feh_edit_inplace(winwidget w, int op)
{
	int tmp;
	Imlib_Image old = NULL;
	Imlib_Load_Error err = IMLIB_LOAD_ERROR_NONE;
	if (!w->file || !w->file->data || !FEH_FILE(w->file->data)->filename)
		return;

	if (!strcmp(gib_imlib_image_format(w->im), "jpeg") &&
			!path_is_url(FEH_FILE(w->file->data)->filename)) {
		feh_edit_inplace_lossless(w, op);
		feh_reload_image(w, 1, 1);
		return;
	}

	old = imlib_load_image_with_error_return(FEH_FILE(w->file->data)->filename, &err);

	if ((old != NULL) && (err == IMLIB_LOAD_ERROR_NONE)) {
		imlib_context_set_image(old);
		if (op == INPLACE_EDIT_FLIP)
			imlib_image_flip_vertical();
		else if (op == INPLACE_EDIT_MIRROR)
			imlib_image_flip_horizontal();
		else
			imlib_image_orientate(op);
		gib_imlib_save_image_with_error_return(old,
			FEH_FILE(w->file->data)->filename, &err);
		gib_imlib_free_image(old);
		if (err)
			feh_imlib_print_load_error(FEH_FILE(w->file->data)->filename,
				w, err);
		feh_reload_image(w, 1, 1);
	} else {
		/*
		 * Image was opened using curl/magick or has been deleted after
		 * opening it
		 */
		imlib_context_set_image(w->im);
		if (op == INPLACE_EDIT_FLIP)
			imlib_image_flip_vertical();
		else if (op == INPLACE_EDIT_MIRROR)
			imlib_image_flip_horizontal();
		else {
			imlib_image_orientate(op);
			tmp = w->im_w;
			FEH_FILE(w->file->data)->info->width = w->im_w = w->im_h;
			FEH_FILE(w->file->data)->info->height = w->im_h = tmp;
		}
		im_weprintf(w, "unable to edit in place. Changes have not been saved.");
		winwidget_render_image(w, 1, 0);
	}

	return;
}
开发者ID:Caellian,项目名称:feh,代码行数:54,代码来源:imlib.c

示例14: feh_edit_inplace

void feh_edit_inplace(winwidget w, int op)
{
	int ret;
	Imlib_Image old;
	Imlib_Load_Error err;
	if (!w->file || !w->file->data || !FEH_FILE(w->file->data)->filename)
		return;

	if (!strcmp(gib_imlib_image_format(w->im), "jpeg")) {
		feh_edit_inplace_lossless(w, op);
		feh_reload_image(w, 1, 1);
		return;
	}

	ret = feh_load_image(&old, FEH_FILE(w->file->data));
	if (ret) {
		if (op == INPLACE_EDIT_FLIP) {
			imlib_context_set_image(old);
			imlib_image_flip_vertical();
		} else if (op == INPLACE_EDIT_MIRROR) {
			imlib_context_set_image(old);
			imlib_image_flip_horizontal();
		} else
			gib_imlib_image_orientate(old, op);
		ungib_imlib_save_image_with_error_return(old,
			FEH_FILE(w->file->data)->filename, &err);
		gib_imlib_free_image(old);
		if (err)
			feh_imlib_print_load_error(FEH_FILE(w->file->data)->filename,
				w, err);
		feh_reload_image(w, 1, 1);
	} else {
		im_weprintf(w, "failed to load image from disk to edit it in place");
	}

	return;
}
开发者ID:phrac,项目名称:feh-browser,代码行数:37,代码来源:imlib.c

示例15: feh_edit_inplace_lossless

void feh_edit_inplace_lossless(winwidget w, int op)
{
	char *filename = FEH_FILE(w->file->data)->filename;
	int len = strlen(filename) + 1;
	char *file_str = emalloc(len);
	int pid, status;
	int devnull = -1;
	char op_name[]  = "rotate";     /* message */
	char op_op[]    = "-rotate";    /* jpegtran option */
	char op_value[] = "horizontal"; /* jpegtran option's value */

	if (op == INPLACE_EDIT_FLIP) {
		sprintf(op_name,  "flip");
		sprintf(op_op,    "-flip");
		sprintf(op_value, "vertical");
	} else if (op == INPLACE_EDIT_MIRROR) {
		sprintf(op_name,  "mirror");
		sprintf(op_op,    "-flip");
	} else
		snprintf(op_value, 4, "%d", 90 * op);

	snprintf(file_str, len, "%s", filename);

	if ((pid = fork()) < 0) {
		im_weprintf(w, "lossless %s: fork failed:", op_name);
		free(file_str);
		return;
	}
	else if (pid == 0) {

		execlp("jpegtran", "jpegtran", "-copy", "all", op_op, op_value,
				"-outfile", file_str, file_str, NULL);

		weprintf("lossless %s: Is 'jpegtran' installed? Failed to exec:", op_name);
		_exit(1);
	}
	else {
		waitpid(pid, &status, 0);

		if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
			im_weprintf(w,
					"lossless %s: Got exitcode %d from jpegtran."
					" Commandline was: "
					"jpegtran -copy all %s %s -outfile %s %s",
					op_name, status >> 8, op_op, op_value, file_str, file_str);
			free(file_str);
			return;
		}
	}
开发者ID:Caellian,项目名称:feh,代码行数:49,代码来源:imlib.c


注:本文中的FEH_FILE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。