Exemple #1
0
void init_parse_options(int argc, char **argv)
{
	/* TODO: sort these to match declaration of __fehoptions */

	/* For setting the command hint on X windows */
	cmdargc = argc;
	cmdargv = argv;

	/* Set default options */
	memset(&opt, 0, sizeof(fehoptions));
	opt.display = 1;
	opt.aspect = 1;
	opt.slideshow_delay = 0.0;
	opt.magick_timeout = -1;
	opt.thumb_w = 60;
	opt.thumb_h = 60;
	opt.thumb_redraw = 10;
	opt.menu_font = estrdup(DEFAULT_MENU_FONT);
	opt.font = NULL;
	opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png");
	opt.max_height = opt.max_width = UINT_MAX;

	opt.start_list_at = NULL;
	opt.jump_on_resort = 1;

	opt.screen_clip = 1;
#ifdef HAVE_LIBXINERAMA
	/* if we're using xinerama, then enable it by default */
	opt.xinerama = 1;
#endif				/* HAVE_LIBXINERAMA */

	feh_getopt_theme(argc, argv);

	D(("About to check for theme configuration\n"));
	feh_check_theme_options(argv);

	D(("About to parse commandline options\n"));
	/* Parse the cmdline args */
	feh_parse_option_array(argc, argv, 1);

	/* If we have a filelist to read, do it now */
	if (opt.filelistfile) {
		/* joining two reverse-sorted lists in this manner works nicely for us
		   here, as files specified on the commandline end up at the *end* of
		   the combined filelist, in the specified order. */
		D(("About to load filelist from file\n"));
		filelist = gib_list_cat(filelist, feh_read_filelist(opt.filelistfile));
	}

	D(("Options parsed\n"));

	filelist_len = gib_list_length(filelist);
	if (!filelist_len)
		show_mini_usage();

	check_options();

	feh_prepare_filelist();
	return;
}
Exemple #2
0
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 (opt.filelistfile) {
		filelist = gib_list_cat(filelist, feh_read_filelist(opt.filelistfile));
	}
	
	if (!(filelist_len = gib_list_length(filelist))) {
		eprintf("No files found to reload.");
	}

	feh_prepare_filelist();

	/* 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);

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

	feh_reload_image(w, 1, 0);
	feh_add_unique_timer(cb_reload_timer, w, opt.reload);
	return;
}