Skip to content
Snippets Groups Projects
imlib.c 27.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		if (opt.actions[i])
    			num_actions++;
    	}
    
    	if (num_actions == 0)
    		return;
    
    	if ((!w->file) || (!FEH_FILE(w->file->data))
    			|| (!FEH_FILE(w->file->data)->filename))
    
    	if (opt.font)
    		fn = gib_imlib_load_font(opt.font);
    
    
    	if (!fn) {
    		if (w->full_screen)
    			fn = gib_imlib_load_font(DEFAULT_FONT_BIG);
    		else
    			fn = gib_imlib_load_font(DEFAULT_FONT);
    	}
    
    	if (!fn) {
    		weprintf("Couldn't load font for actions printing");
    
    	memset(atab, 0, sizeof(atab));
    
    
    	gib_imlib_get_text_size(fn, "defined actions:", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
    
    /* Check for the widest line */
    
    	max_tw = tw;
    
    	for (i = 0; i < 10; i++) {
    		if (opt.actions[i]) {
    
    			line = emalloc(strlen(opt.actions[i]) + 5);
    			strcpy(line, "0: ");
    			line = strcat(line, opt.actions[i]);
    			gib_imlib_get_text_size(fn, line, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT);
    			free(line);
    
    			if (tw > max_tw)
    				max_tw = tw;
    		}
    	}
    
    	tw = max_tw;
    	tw += 3;
    	th += 3;
    	line_th = th;
    	th = (th * num_actions) + line_th;
    
    	/* This depends on feh_draw_filename internals...
    	 * should be fixed some time
    	 */
    	if (opt.draw_filename && w->full_screen)
    		th_offset = line_th * 2;
    	else if (opt.draw_filename)
    		th_offset = line_th;
    
    	im = imlib_create_image(tw, th);
    	if (!im)
    		eprintf("Couldn't create image. Out of memory?");
    
    	gib_imlib_image_set_has_alpha(im, 1);
    	gib_imlib_apply_color_modifier_to_rectangle(im, 0, 0, tw, th, NULL, NULL, NULL, atab);
    	gib_imlib_image_fill_rectangle(im, 0, 0, tw, th, 0, 0, 0, 0);
    
    	gib_imlib_text_draw(im, fn, NULL, 2, 2, "defined actions:", IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
    	gib_imlib_text_draw(im, fn, NULL, 1, 1, "defined actions:", IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);
    
    	for (i = 0; i < 10; i++) {
    		if (opt.actions[i]) {
    			cur_action++;
    			line = emalloc(strlen(opt.actions[i]) + 5);
    			sprintf(index, "%d", i);
    			strcpy(line, index);
    			strcat(line, ": ");
    			strcat(line, opt.actions[i]);
    
    			gib_imlib_text_draw(im, fn, NULL, 2,
    					(cur_action * line_th) + 2, line,
    					IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255);
    			gib_imlib_text_draw(im, fn, NULL, 1,
    					(cur_action * line_th) + 1, line,
    					IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255);
    			free(line);
    		}
    	}
    
    	gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, 0 + th_offset, 1, 1, 0);
    
    	gib_imlib_free_image_and_decache(im);