diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/collage.c | 12 | ||||
| -rw-r--r-- | src/feh.h | 2 | ||||
| -rw-r--r-- | src/index.c | 12 | ||||
| -rw-r--r-- | src/multiwindow.c | 20 | ||||
| -rw-r--r-- | src/slideshow.c | 56 | ||||
| -rw-r--r-- | src/thumbnail.c | 38 | ||||
| -rw-r--r-- | src/winwidget.c | 29 | ||||
| -rw-r--r-- | src/winwidget.h | 4 | 
8 files changed, 33 insertions, 140 deletions
| diff --git a/src/collage.c b/src/collage.c index b975136..431d3b6 100644 --- a/src/collage.c +++ b/src/collage.c @@ -41,7 +41,6 @@ void init_collage_mode(void)  	feh_file *file = NULL;  	unsigned char trans_bg = 0;  	gib_list *l, *last = NULL; -	char *s;  	mode = "collage"; @@ -105,15 +104,9 @@ void init_collage_mode(void)  		gib_imlib_image_fill_rectangle(im_main, 0, 0, w, h, 0, 0, 0, 255);  	} -	/* Create the title string */ - -	if (!opt.title) -		s = estrdup(PACKAGE " [collage mode]"); -	else -		s = estrdup(feh_printf(opt.title, NULL, NULL)); -  	if (opt.display) { -		winwid = winwidget_create_from_image(im_main, s, WIN_TYPE_SINGLE); +		winwid = winwidget_create_from_image(im_main, WIN_TYPE_SINGLE); +		winwidget_rename(winwid, PACKAGE " [collage mode]");  		winwidget_show(winwid);  	} @@ -210,7 +203,6 @@ void init_collage_mode(void)  	if (!opt.display)  		gib_imlib_free_image_and_decache(im_main); -	free(s);  	return;  } @@ -137,8 +137,6 @@ int feh_load_image(Imlib_Image * im, feh_file * file);  void show_mini_usage(void);  void slideshow_change_image(winwidget winwid, int change, int render);  void slideshow_pause_toggle(winwidget w); -char *slideshow_create_name(feh_file * file, winwidget winwid); -char *thumbnail_create_name(feh_file * file, winwidget winwid);  void init_keyevents(void);  void init_buttonbindings(void);  void setup_stdin(void); diff --git a/src/index.c b/src/index.c index fbc25b8..c8c34c5 100644 --- a/src/index.c +++ b/src/index.c @@ -59,7 +59,6 @@ void init_index_mode(void)  	int lineno;  	unsigned char trans_bg = 0;  	int index_image_width, index_image_height; -	char *s;  	gib_list *line, *lines;  	if (opt.montage) { @@ -164,15 +163,9 @@ void init_index_mode(void)  		gib_imlib_image_fill_rectangle(im_main, 0, 0, w, h + title_area_h, 0, 0, 0, 255);  	} -	/* Create the window title at this point */ - -	if (!opt.title) -		s = estrdup(PACKAGE " [index mode]"); -	else -		s = estrdup(feh_printf(opt.title, NULL, NULL)); -  	if (opt.display) { -		winwid = winwidget_create_from_image(im_main, s, WIN_TYPE_SINGLE); +		winwid = winwidget_create_from_image(im_main, WIN_TYPE_SINGLE); +		winwidget_rename(winwid, PACKAGE " [index mode]");  		winwidget_show(winwid);  	} @@ -348,7 +341,6 @@ void init_index_mode(void)  	if (!opt.display)  		gib_imlib_free_image_and_decache(im_main); -	free(s);  	return;  } diff --git a/src/multiwindow.c b/src/multiwindow.c index 13cff90..abbf6c9 100644 --- a/src/multiwindow.c +++ b/src/multiwindow.c @@ -34,25 +34,14 @@ void init_multiwindow_mode(void)  {  	winwidget w = NULL;  	gib_list *l; -	feh_file *file = NULL; + +	if (!opt.title) +		opt.title = PACKAGE " - %f";  	mode = "multiwindow";  	for (l = filelist; l; l = l->next) { -		char *s = NULL; -		int len = 0; -		file = FEH_FILE(l->data); -		current_file = l; - -		if (!opt.title) { -			len = strlen(PACKAGE " - ") + strlen(file->filename) + 1; -			s = emalloc(len); -			snprintf(s, len, PACKAGE " - %s", file->filename); -		} else { -			s = estrdup(feh_printf(opt.title, file, w)); -		} - -		if ((w = winwidget_create_from_file(l, s, WIN_TYPE_SINGLE)) != NULL) { +		if ((w = winwidget_create_from_file(l, WIN_TYPE_SINGLE)) != NULL) {  			winwidget_show(w);  			if (opt.reload > 0)  				feh_add_unique_timer(cb_reload_timer, w, opt.reload); @@ -62,7 +51,6 @@ void init_multiwindow_mode(void)  			D(("EEEK. Couldn't load image in multiwindow mode. "  						"I 'm not sure if this is a problem\n"));  		} -		free(s);  	}  	return; diff --git a/src/slideshow.c b/src/slideshow.c index 80fa918..c6d82a6 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -48,6 +48,9 @@ void init_slideshow_mode(void)  		eprintf("--start-at %s: File not found in filelist",  				opt.start_list_at); +	if (!opt.title) +		opt.title = PACKAGE " [%u of %l] - %f", +  	mode = "slideshow";  	for (; l; l = l->next) {  		if (last) { @@ -55,7 +58,7 @@ void init_slideshow_mode(void)  			last = NULL;  		}  		current_file = l; -		if ((w = winwidget_create_from_file(l, NULL, WIN_TYPE_SLIDESHOW)) != NULL) { +		if ((w = winwidget_create_from_file(l, WIN_TYPE_SLIDESHOW)) != NULL) {  			success = 1;  			winwidget_show(w);  			if (opt.slideshow_delay > 0.0) @@ -124,13 +127,6 @@ void cb_reload_timer(void *data)  		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);  	feh_add_unique_timer(cb_reload_timer, w, opt.reload);  	return; @@ -138,7 +134,7 @@ void cb_reload_timer(void *data)  void feh_reload_image(winwidget w, int resize, int force_new)  { -	char *title, *new_title; +	char *new_title;  	int len;  	Imlib_Image tmp;  	int old_w, old_h; @@ -167,8 +163,8 @@ void feh_reload_image(winwidget w, int resize, int force_new)  	len = strlen(w->name) + sizeof("Reloading: ") + 1;  	new_title = emalloc(len);  	snprintf(new_title, len, "Reloading: %s", w->name); -	title = estrdup(w->name);  	winwidget_rename(w, new_title); +	free(new_title);  	old_w = gib_imlib_image_get_width(w->im);  	old_h = gib_imlib_image_get_height(w->im); @@ -189,9 +185,6 @@ void feh_reload_image(winwidget w, int resize, int force_new)  			im_weprintf(w, "Couldn't reload image. Is it still there?");  			winwidget_render_image(w, 0, 0);  		} -		winwidget_rename(w, title); -		free(title); -		free(new_title);  		return;  	} @@ -231,10 +224,6 @@ void feh_reload_image(winwidget w, int resize, int force_new)  		winwidget_render_image(w, resize, 0);  	} -	winwidget_rename(w, title); -	free(title); -	free(new_title); -  	return;  } @@ -247,7 +236,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)  	 * encounter invalid images.  	 */  	int our_filelist_len = filelist_len; -	char *s;  	unsigned char tmode =0;  	int tim_x =0; @@ -396,11 +384,6 @@ void slideshow_change_image(winwidget winwid, int change, int render)  					winwidget_render_image(winwid, 1, 0);  				}  			} - -			s = slideshow_create_name(FEH_FILE(current_file->data), winwid); -			winwidget_rename(winwid, s); -			free(s); -  			break;  		} else  			last = current_file; @@ -427,23 +410,6 @@ void slideshow_pause_toggle(winwidget w)  	winwidget_rename(w, NULL);  } -char *slideshow_create_name(feh_file * file, winwidget winwid) -{ -	char *s = NULL; -	int len = 0; - -	if (!opt.title) { -		len = strlen(PACKAGE " [slideshow mode] - ") + strlen(file->filename) + 1; -		s = emalloc(len); -		snprintf(s, len, PACKAGE " [%d of %d] - %s", -			gib_list_num(filelist, current_file) + 1, gib_list_length(filelist), file->filename); -	} else { -		s = estrdup(feh_printf(opt.title, file, winwid)); -	} - -	return(s); -} -  void feh_action_run(feh_file * file, char *action, winwidget winwid)  {  	if (action) { @@ -480,6 +446,7 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)  	ret[0] = '\0';  	filelist_tmppath = NULL; +	gib_list *f;  	for (c = str; *c != '\0'; c++) {  		if ((*c == '%') && (*(c+1) != '\0')) { @@ -564,9 +531,8 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)  				}  				break;  			case 'u': -				snprintf(buf, sizeof(buf), "%d", -					 current_file != NULL ? gib_list_num(filelist, current_file) -					 + 1 : 0); +				f = current_file ? current_file : gib_list_find_by_data(filelist, file); +				snprintf(buf, sizeof(buf), "%d", f ? gib_list_num(filelist, f) + 1 : 0);  				strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);  				break;  			case 'v': @@ -620,7 +586,6 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)  void feh_filelist_image_remove(winwidget winwid, char do_delete)  {  	if (winwid->type == WIN_TYPE_SLIDESHOW) { -		char *s;  		gib_list *doomed;  		doomed = current_file; @@ -647,9 +612,6 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete)  			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)) { diff --git a/src/thumbnail.c b/src/thumbnail.c index edf0f4f..003c7b4 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -71,7 +71,6 @@ void init_thumbnail_mode(void)  	gib_list *l, *last = NULL;  	int lineno;  	int index_image_width, index_image_height; -	char *s;  	unsigned int thumb_counter = 0;  	gib_list *line, *lines; @@ -92,6 +91,9 @@ void init_thumbnail_mode(void)  	td.vertical = 0;  	td.max_column_w = 0; +	if (!opt.thumb_title) +		opt.thumb_title = "%n"; +  	mode = "thumbnail";  	if (opt.font) @@ -168,15 +170,9 @@ void init_thumbnail_mode(void)  				td.h + title_area_h, 0, 0, 0, 255);  	} -	/* Create title now */ - -	if (!opt.title) -		s = estrdup(PACKAGE " [thumbnail mode]"); -	else -		s = estrdup(feh_printf(opt.title, NULL, NULL)); -  	if (opt.display) { -		winwid = winwidget_create_from_image(td.im_main, s, WIN_TYPE_THUMBNAIL); +		winwid = winwidget_create_from_image(td.im_main, WIN_TYPE_THUMBNAIL); +		winwidget_rename(winwid, PACKAGE " [thumbnail mode]");  		winwidget_show(winwid);  	} @@ -415,8 +411,6 @@ void init_thumbnail_mode(void)  		}  	} - -	free(s);  	return;  } @@ -772,24 +766,17 @@ int feh_thumbnail_get_generated(Imlib_Image * image, feh_file * file,  void feh_thumbnail_show_fullsize(feh_file *thumbfile)  {  	winwidget thumbwin = NULL; -	char *s; -	if (!opt.thumb_title) -		s = thumbfile->name; -	else -		s = feh_printf(opt.thumb_title, thumbfile, NULL); -	  	thumbwin = winwidget_get_first_window_of_type(WIN_TYPE_THUMBNAIL_VIEWER);  	if (!thumbwin) {  		thumbwin = winwidget_create_from_file(  				gib_list_add_front(NULL, thumbfile), -				s, WIN_TYPE_THUMBNAIL_VIEWER); +				WIN_TYPE_THUMBNAIL_VIEWER);  		if (thumbwin)  			winwidget_show(thumbwin);  	} else if (FEH_FILE(thumbwin->file->data) != thumbfile) {  		free(thumbwin->file);  		thumbwin->file = gib_list_add_front(NULL, thumbfile); -		winwidget_rename(thumbwin, s);  		feh_reload_image(thumbwin, 1, 1);  	}  } @@ -925,16 +912,3 @@ int feh_thumbnail_setup_thumbnail_dir(void)  	return status;  } - -char *thumbnail_create_name(feh_file * file, winwidget winwid) -{ -	char *s = NULL; - -	if (!opt.thumb_title) { -		s = estrdup(file->filename); -	} else { -		s = estrdup(feh_printf(opt.thumb_title, file, winwid)); -	} - -	return(s); -} diff --git a/src/winwidget.c b/src/winwidget.c index d636a85..3311383 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -81,7 +81,7 @@ static winwidget winwidget_allocate(void)  	return(ret);  } -winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type) +winwidget winwidget_create_from_image(Imlib_Image im, char type)  {  	winwidget ret = NULL; @@ -95,11 +95,6 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)  	ret->w = ret->im_w = gib_imlib_image_get_width(ret->im);  	ret->h = ret->im_h = gib_imlib_image_get_height(ret->im); -	if (name) -		ret->name = estrdup(name); -	else -		ret->name = estrdup(PACKAGE); -  	if (opt.full_screen && (type != WIN_TYPE_THUMBNAIL))  		ret->full_screen = True;  	winwidget_create_window(ret, ret->w, ret->h); @@ -108,7 +103,7 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)  	return(ret);  } -winwidget winwidget_create_from_file(gib_list * list, char *name, char type) +winwidget winwidget_create_from_file(gib_list * list, char type)  {  	winwidget ret = NULL;  	feh_file *file = FEH_FILE(list->data); @@ -119,10 +114,6 @@ winwidget winwidget_create_from_file(gib_list * list, char *name, char type)  	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); @@ -632,16 +623,12 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)  			feh_draw_info(winwid);  		if (winwid->errstr)  			feh_draw_errstr(winwid); -		if (opt.title && (winwid->type != WIN_TYPE_THUMBNAIL_VIEWER) && -				(winwid->file != NULL)) { -			char *s = slideshow_create_name(FEH_FILE(winwid->file->data), winwid); -			winwidget_rename(winwid, s); -			free(s); -		} else if (opt.thumb_title && (winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) && -				(winwid->file != NULL)) { -			char *s = thumbnail_create_name(FEH_FILE(winwid->file->data), winwid); -			winwidget_rename(winwid, s); -			free(s); +		if (winwid->file != NULL) { +			if (opt.title && winwid->type != WIN_TYPE_THUMBNAIL_VIEWER) { +				winwidget_rename(winwid, feh_printf(opt.title, FEH_FILE(winwid->file->data), winwid)); +			} else if (opt.thumb_title && winwid->type == WIN_TYPE_THUMBNAIL_VIEWER) { +				winwidget_rename(winwid, feh_printf(opt.thumb_title, FEH_FILE(winwid->file->data), winwid)); +			}  		}  	} else if ((opt.mode == MODE_ZOOM) && !antialias)  		feh_draw_zoom(winwid); diff --git a/src/winwidget.h b/src/winwidget.h index 6a794e7..dd8489a 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -141,8 +141,8 @@ void winwidget_get_geometry(winwidget winwid, int *rect);  int winwidget_get_width(winwidget winwid);  int winwidget_get_height(winwidget winwid);  winwidget winwidget_get_from_window(Window win); -winwidget winwidget_create_from_file(gib_list * filename, char *name, char type); -winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type); +winwidget winwidget_create_from_file(gib_list * filename, char type); +winwidget winwidget_create_from_image(Imlib_Image im, char type);  void winwidget_rename(winwidget winwid, char *newname);  void winwidget_destroy(winwidget winwid);  void winwidget_create_window(winwidget ret, int w, int h); | 
