comparison gui/interface.c @ 33745:2d1babde7b29

Cosmetic: Separate interface functions. Sort out GUI -> MPlayer functions and add comment.
author ib
date Thu, 07 Jul 2011 13:37:14 +0000
parents 8497620cefca
children 23c804f4efbf
comparison
equal deleted inserted replaced
33744:8497620cefca 33745:2d1babde7b29
70 70
71 float gtkEquChannels[6][10]; 71 float gtkEquChannels[6][10];
72 72
73 static int initialized; 73 static int initialized;
74 74
75 /* MPlayer -> GUI */
76
75 void guiInit(void) 77 void guiInit(void)
76 { 78 {
77 int i; 79 int i;
78 80
79 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI init.\n"); 81 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI init.\n");
316 m_config_free(gui_conf); 318 m_config_free(gui_conf);
317 gui_conf = NULL; 319 gui_conf = NULL;
318 } 320 }
319 321
320 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n"); 322 mp_msg(MSGT_GPLAYER, MSGL_V, "GUI done.\n");
321 }
322
323 void guiExit(enum exit_reason how)
324 {
325 exit_player_with_rc(how, how >= EXIT_ERROR);
326 }
327
328 void guiLoadFont(void)
329 {
330 #ifdef CONFIG_FREETYPE
331 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
332 #else
333 if (vo_font) {
334 int i;
335
336 free(vo_font->name);
337 free(vo_font->fpath);
338
339 for (i = 0; i < 16; i++) {
340 if (vo_font->pic_a[i]) {
341 free(vo_font->pic_a[i]->bmp);
342 free(vo_font->pic_a[i]->pal);
343 }
344 }
345
346 for (i = 0; i < 16; i++) {
347 if (vo_font->pic_b[i]) {
348 free(vo_font->pic_b[i]->bmp);
349 free(vo_font->pic_b[i]->pal);
350 }
351 }
352
353 free(vo_font);
354 vo_font = NULL;
355 }
356
357 if (font_name) {
358 vo_font = read_font_desc(font_name, font_factor, 0);
359
360 if (!vo_font)
361 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
362 } else {
363 font_name = gstrdup(get_path("font/font.desc"));
364 vo_font = read_font_desc(font_name, font_factor, 0);
365
366 if (!vo_font) {
367 nfree(font_name);
368 font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc");
369 vo_font = read_font_desc(font_name, font_factor, 0);
370 }
371 }
372 #endif
373 }
374
375 void guiLoadSubtitle(char *name)
376 {
377 if (guiInfo.Playing == 0) {
378 guiInfo.SubtitleChanged = 1; // what is this for? (mw)
379 return;
380 }
381
382 if (subdata) {
383 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
384
385 sub_free(subdata);
386 subdata = NULL;
387 vo_sub = NULL;
388
389 if (vo_osd_list) {
390 int len;
391 mp_osd_obj_t *osd;
392
393 osd = vo_osd_list;
394
395 while (osd) {
396 if (osd->type == OSDTYPE_SUBTITLE)
397 break;
398
399 osd = osd->next;
400 }
401
402 if (osd && (osd->flags & OSDFLAG_VISIBLE)) {
403 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
404 memset(osd->bitmap_buffer, 0, len);
405 memset(osd->alpha_buffer, 0, len);
406 }
407 }
408 }
409
410 if (name) {
411 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
412
413 subdata = sub_read_file(name, guiInfo.FPS);
414
415 if (!subdata)
416 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name);
417
418 sub_name = (malloc(2 * sizeof(char *))); // when mplayer will be restarted
419 sub_name[0] = strdup(name); // sub_name[0] will be read
420 sub_name[1] = NULL;
421 }
422
423 update_set_of_subtitles();
424 } 323 }
425 324
426 static void add_vf(char *str) 325 static void add_vf(char *str)
427 { 326 {
428 void *p; 327 void *p;
1188 filename = NULL; 1087 filename = NULL;
1189 1088
1190 return result; 1089 return result;
1191 } 1090 }
1192 1091
1092 void guiLoadFont(void)
1093 {
1094 #ifdef CONFIG_FREETYPE
1095 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
1096 #else
1097 if (vo_font) {
1098 int i;
1099
1100 free(vo_font->name);
1101 free(vo_font->fpath);
1102
1103 for (i = 0; i < 16; i++) {
1104 if (vo_font->pic_a[i]) {
1105 free(vo_font->pic_a[i]->bmp);
1106 free(vo_font->pic_a[i]->pal);
1107 }
1108 }
1109
1110 for (i = 0; i < 16; i++) {
1111 if (vo_font->pic_b[i]) {
1112 free(vo_font->pic_b[i]->bmp);
1113 free(vo_font->pic_b[i]->pal);
1114 }
1115 }
1116
1117 free(vo_font);
1118 vo_font = NULL;
1119 }
1120
1121 if (font_name) {
1122 vo_font = read_font_desc(font_name, font_factor, 0);
1123
1124 if (!vo_font)
1125 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
1126 } else {
1127 font_name = gstrdup(get_path("font/font.desc"));
1128 vo_font = read_font_desc(font_name, font_factor, 0);
1129
1130 if (!vo_font) {
1131 nfree(font_name);
1132 font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc");
1133 vo_font = read_font_desc(font_name, font_factor, 0);
1134 }
1135 }
1136 #endif
1137 }
1138
1139 void guiLoadSubtitle(char *name)
1140 {
1141 if (guiInfo.Playing == 0) {
1142 guiInfo.SubtitleChanged = 1; // what is this for? (mw)
1143 return;
1144 }
1145
1146 if (subdata) {
1147 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
1148
1149 sub_free(subdata);
1150 subdata = NULL;
1151 vo_sub = NULL;
1152
1153 if (vo_osd_list) {
1154 int len;
1155 mp_osd_obj_t *osd;
1156
1157 osd = vo_osd_list;
1158
1159 while (osd) {
1160 if (osd->type == OSDTYPE_SUBTITLE)
1161 break;
1162
1163 osd = osd->next;
1164 }
1165
1166 if (osd && (osd->flags & OSDFLAG_VISIBLE)) {
1167 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
1168 memset(osd->bitmap_buffer, 0, len);
1169 memset(osd->alpha_buffer, 0, len);
1170 }
1171 }
1172 }
1173
1174 if (name) {
1175 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
1176
1177 subdata = sub_read_file(name, guiInfo.FPS);
1178
1179 if (!subdata)
1180 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name);
1181
1182 sub_name = (malloc(2 * sizeof(char *))); // when mplayer will be restarted
1183 sub_name[0] = strdup(name); // sub_name[0] will be read
1184 sub_name[1] = NULL;
1185 }
1186
1187 update_set_of_subtitles();
1188 }
1189
1190 void guiExit(enum exit_reason how)
1191 {
1192 exit_player_with_rc(how, how >= EXIT_ERROR);
1193 }
1194
1193 // NOTE TO MYSELF: This function is nonsense. 1195 // NOTE TO MYSELF: This function is nonsense.
1194 // MPlayer should pass messages to the GUI 1196 // MPlayer should pass messages to the GUI
1195 // which must decide then which message has 1197 // which must decide then which message has
1196 // to be shown (MSGL_FATAL, for example). 1198 // to be shown (MSGL_FATAL, for example).
1197 // But with this function it is at least 1199 // But with this function it is at least