Newer
Older
}
l = l->next;
}
gib_list_free_and_data(lines);
lines = list;
}
return lines;
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;
Birte Kristina Friesel
committed
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);
Birte Kristina Friesel
committed
return;
} else if (pid == 0) {
execlp("jpegtran", "jpegtran", "-copy", "all", op_op, op_value,
"-outfile", file_str, file_str, NULL);
im_weprintf(w, "lossless %s: Is 'jpegtran' installed? Failed to exec:", op_name);
return;
} 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);
Birte Kristina Friesel
committed
return;
}
void feh_draw_actions(winwidget w)
static Imlib_Font fn = NULL;
int tw = 0, th = 0;
int th_offset = 0;
int max_tw = 0;
int line_th = 0;
Imlib_Image im = NULL;
int i = 0;
int num_actions = 0;
int cur_action = 0;
char index[2];
char *line;
/* Count number of defined actions. This method sucks a bit since it needs
* to be changed if the number of actions changes, but at least it doesn't
* miss actions 2 to 9 if action1 isn't defined
*/
for (i = 0; i < 10; i++) {
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))
Birte Kristina Friesel
committed
return;
fn = feh_load_font(w);
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
*/
th_offset = line_th * 2;
im = imlib_create_image(tw, th);
if (!im)
eprintf("Couldn't create image. Out of memory?");
Birte Kristina Friesel
committed
feh_imlib_image_fill_text_bg(im, tw, th);
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
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);
Birte Kristina Friesel
committed
return;