Newer
Older
int pid, status;
snprintf(rotate_str, 4, "%d", rotatearg);
snprintf(file_str, len, "%s", filename);
if ((pid = fork()) < 0) {
weprintf("lossless rotate: fork failed:");
D_RETURN_(4);
} else if (pid == 0) {
execlp("jpegtran", "jpegtran", "-copy", "all", "-rotate",
rotate_str, "-outfile", file_str, file_str, NULL);
eprintf("lossless rotate: exec failed: jpegtran:");
} else {
waitpid(pid, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
weprintf("lossless rotate: Got exitcode %d from jpegtran."
" Commandline was:\n"
"jpegtran -copy all -rotate %d -outfile %s %s\n",
status >> 8, rotate_str, file_str, file_str);
D_RETURN_(4);
}
}
void feh_draw_actions(winwidget w)
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
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;
static DATA8 atab[256];
int i = 0;
int num_actions = 0;
int cur_action = 0;
char index[1];
char *line;
D_ENTER(4);
/* 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))
D_RETURN_(4);
if (!fn) {
memset(atab, 0, sizeof(atab));
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");
D_RETURN_(4);
}
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);
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
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);
D_RETURN_(4);