Mercurial > mplayer.hg
annotate gui/interface.c @ 33218:f0c2a62e3e89
Position windows initially at coordinates given in skin file.
So far, the initial positions of the main and subwindow were not
the ones specified in the skin file, but fixed defaults.
author | ib |
---|---|
date | Sat, 23 Apr 2011 08:05:27 +0000 |
parents | f64d41dac10b |
children | 5f9eaf3eea63 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 | |
32984 | 22 #include "interface.h" |
23 #include "app.h" | |
24 #include "mplayer/gmplayer.h" | |
25 #include "mplayer/widgets.h" | |
26 #include "skin/skin.h" | |
23077 | 27 #include "wm/ws.h" |
28 #include "wm/wsxdnd.h" | |
29 | |
30 #include "access_mpcontext.h" | |
32984 | 31 #include "config.h" |
23077 | 32 #include "help_mp.h" |
32984 | 33 #include "input/input.h" |
34 #include "libaf/equalizer.h" | |
35 #include "libao2/audio_out.h" | |
36 #include "libmpcodecs/dec_audio.h" | |
37 #include "libmpcodecs/dec_video.h" | |
38 #include "libmpcodecs/vd.h" | |
39 #include "libmpcodecs/vf.h" | |
40 #include "libvo/video_out.h" | |
41 #include "libvo/x11_common.h" | |
42 #include "mixer.h" | |
30516 | 43 #include "mp_core.h" |
32984 | 44 #include "mp_msg.h" |
32032 | 45 #include "mpcommon.h" |
30536
39a4dd7ec420
Move GUI-related extern declarations to a GUI header file.
diego
parents:
30535
diff
changeset
|
46 #include "mplayer.h" |
32984 | 47 #include "path.h" |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
32461
diff
changeset
|
48 #include "sub/font_load.h" |
32467 | 49 #include "sub/sub.h" |
23077 | 50 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
51 #ifdef CONFIG_DVDREAD |
23077 | 52 #include "stream/stream_dvd.h" |
53 #endif | |
54 | |
32984 | 55 guiInterface_t guiIntfStruct; |
23077 | 56 |
32984 | 57 int guiWinID = -1; |
23077 | 58 |
32900 | 59 char *skinName; |
60 char *skinDirInHome; | |
61 char *skinMPlayerDir; | |
62 | |
32984 | 63 plItem *plCurrent = NULL; |
64 plItem *plList = NULL; | |
65 plItem *plLastPlayed = NULL; | |
66 | |
67 URLItem *URLList = NULL; | |
68 | |
69 char *fsHistory[fsPersistant_MaxPos] = { NULL, NULL, NULL, NULL, NULL }; | |
70 | |
71 float gtkEquChannels[6][10]; | |
72 | |
73 int gstrcmp(const char *a, const char *b) | |
23077 | 74 { |
32984 | 75 if (!a && !b) |
76 return 0; | |
77 if (!a || !b) | |
78 return -1; | |
23077 | 79 |
32984 | 80 return strcmp(a, b); |
23077 | 81 } |
82 | |
32984 | 83 static int gstrncmp(const char *a, const char *b, int size) |
23077 | 84 { |
32984 | 85 if (!a && !b) |
86 return 0; | |
87 if (!a || !b) | |
88 return -1; | |
89 | |
90 return strncmp(a, b, size); | |
23077 | 91 } |
92 | |
32984 | 93 char *gstrdup(const char *str) |
23077 | 94 { |
32984 | 95 if (!str) |
96 return NULL; | |
97 | |
98 return strdup(str); | |
23077 | 99 } |
100 | |
32984 | 101 char *gstrchr(char *str, int c) |
23077 | 102 { |
32984 | 103 if (!str) |
104 return NULL; | |
105 | |
106 return strchr(str, c); | |
107 } | |
108 | |
109 void gfree(void **p) | |
110 { | |
111 free(*p); | |
112 *p = NULL; | |
23077 | 113 } |
114 | |
115 /** | |
32984 | 116 * \brief This actually creates a new list containing only one element... |
23077 | 117 */ |
32984 | 118 void gaddlist(char ***list, const char *entry) |
23077 | 119 { |
32984 | 120 int i; |
23077 | 121 |
32984 | 122 if (*list) { |
123 for (i = 0; (*list)[i]; i++) | |
124 free((*list)[i]); | |
23077 | 125 |
32984 | 126 free(*list); |
127 } | |
128 | |
129 *list = malloc(2 * sizeof(char **)); | |
130 (*list)[0] = gstrdup(entry); | |
131 (*list)[1] = NULL; | |
23077 | 132 } |
133 | |
134 /** | |
32984 | 135 * \brief This replaces a string starting with search by replace. |
23077 | 136 * If not found, replace is appended. |
137 */ | |
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
30516
diff
changeset
|
138 static void greplace(char ***list, const char *search, const char *replace) |
23077 | 139 { |
32984 | 140 int i = 0; |
141 int len = (search ? strlen(search) : 0); | |
23077 | 142 |
32984 | 143 if (*list) { |
144 for (i = 0; (*list)[i]; i++) { | |
145 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
146 free((*list)[i]); | |
147 (*list)[i] = gstrdup(replace); | |
148 return; | |
149 } | |
150 } | |
23077 | 151 |
32984 | 152 *list = realloc(*list, (i + 2) * sizeof(char *)); |
153 } else | |
154 *list = malloc(2 * sizeof(char *)); | |
155 | |
156 (*list)[i] = gstrdup(replace); | |
157 (*list)[i + 1] = NULL; | |
23077 | 158 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
159 |
32984 | 160 void guiInit(void) |
23077 | 161 { |
32984 | 162 int i; |
23077 | 163 |
32984 | 164 memset(&guiIntfStruct, 0, sizeof(guiIntfStruct)); |
165 guiIntfStruct.Balance = 50.0f; | |
166 guiIntfStruct.StreamType = -1; | |
167 | |
168 appInitStruct(); | |
169 | |
170 memset(>kEquChannels, 0, sizeof(gtkEquChannels)); | |
23077 | 171 |
32984 | 172 #ifdef CONFIG_DXR3 |
173 if (!gtkDXR3Device) | |
174 gtkDXR3Device = strdup("/dev/em8300-0"); | |
175 #endif | |
32927 | 176 |
32984 | 177 if (stream_cache_size > 0) { |
178 gtkCacheOn = 1; | |
179 gtkCacheSize = stream_cache_size; | |
180 } else if (stream_cache_size == 0) | |
181 gtkCacheOn = 0; | |
182 | |
183 if (autosync && (autosync != gtkAutoSync)) { | |
184 gtkAutoSyncOn = 1; | |
185 gtkAutoSync = autosync; | |
186 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
187 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
188 #ifdef CONFIG_ASS |
32984 | 189 gtkASS.enabled = ass_enabled; |
190 gtkASS.use_margins = ass_use_margins; | |
191 gtkASS.top_margin = ass_top_margin; | |
192 gtkASS.bottom_margin = ass_bottom_margin; | |
23077 | 193 #endif |
194 | |
32984 | 195 gtkInit(); |
196 | |
197 // initialize X | |
198 wsXInit((void *)mDisplay); | |
199 | |
200 // load skin | |
201 | |
202 skinDirInHome = get_path("skins"); | |
203 skinMPlayerDir = MPLAYER_DATADIR "/skins"; | |
204 | |
205 mp_msg(MSGT_GPLAYER, MSGL_V, "SKIN dir 1: '%s'\n", skinDirInHome); | |
206 mp_msg(MSGT_GPLAYER, MSGL_V, "SKIN dir 2: '%s'\n", skinMPlayerDir); | |
207 | |
208 if (!skinName) | |
209 skinName = strdup("default"); | |
210 | |
211 i = skinRead(skinName); | |
212 | |
213 if (i == -1 && strcmp(skinName, "default") != 0) { | |
214 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
215 | |
216 skinName = strdup("default"); | |
217 i = skinRead(skinName); | |
218 } | |
219 | |
220 switch (i) { | |
221 case -1: | |
33024 | 222 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinNotFound, skinName); |
223 exit_player(EXIT_ERROR); | |
23077 | 224 |
32984 | 225 case -2: |
33025 | 226 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName); |
33024 | 227 exit_player(EXIT_ERROR); |
32984 | 228 } |
229 | |
230 // initialize windows | |
231 | |
232 mplDrawBuffer = malloc(appMPlayer.main.Bitmap.ImageSize); | |
233 | |
234 if (!mplDrawBuffer) { | |
33024 | 235 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
236 exit_player(EXIT_ERROR); | |
32984 | 237 } |
23077 | 238 |
32984 | 239 if (gui_save_pos) { |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
240 if (gui_main_pos_x != -3) |
32984 | 241 appMPlayer.main.x = gui_main_pos_x; |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
242 if (gui_main_pos_y != -3) |
32984 | 243 appMPlayer.main.y = gui_main_pos_y; |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
244 if (gui_sub_pos_x != -3) |
32984 | 245 appMPlayer.sub.x = gui_sub_pos_x; |
33218
f0c2a62e3e89
Position windows initially at coordinates given in skin file.
ib
parents:
33053
diff
changeset
|
246 if (gui_sub_pos_y != -3) |
32984 | 247 appMPlayer.sub.y = gui_sub_pos_y; |
248 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
249 |
32984 | 250 if (WinID > 0) { |
251 appMPlayer.subWindow.Parent = WinID; | |
252 appMPlayer.sub.x = 0; | |
253 appMPlayer.sub.y = 0; | |
254 } | |
23077 | 255 |
32984 | 256 if (guiWinID >= 0) |
257 appMPlayer.mainWindow.Parent = guiWinID; | |
23077 | 258 |
32984 | 259 wsCreateWindow(&appMPlayer.subWindow, appMPlayer.sub.x, appMPlayer.sub.y, appMPlayer.sub.width, appMPlayer.sub.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsHideWindow, "MPlayer - Video"); |
260 wsDestroyImage(&appMPlayer.subWindow); | |
261 wsCreateImage(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Width, appMPlayer.sub.Bitmap.Height); | |
262 wsXDNDMakeAwareness(&appMPlayer.subWindow); | |
263 | |
264 mplMenuInit(); | |
265 mplPBInit(); | |
23077 | 266 |
267 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
268 // if ( appMPlayer.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; | |
32984 | 269 i = wsShowFrame | wsMaxSize | wsHideWindow; |
270 wsCreateWindow(&appMPlayer.mainWindow, appMPlayer.main.x, appMPlayer.main.y, appMPlayer.main.width, appMPlayer.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, i, "MPlayer"); | |
271 wsSetShape(&appMPlayer.mainWindow, appMPlayer.main.Mask.Image); | |
272 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
23077 | 273 |
274 #ifdef DEBUG | |
32984 | 275 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] depth on screen: %d\n", wsDepthOnScreen); |
276 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] parent: 0x%x\n", (int)appMPlayer.mainWindow.WindowID); | |
277 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] sub: 0x%x\n", (int)appMPlayer.subWindow.WindowID); | |
23077 | 278 #endif |
279 | |
32984 | 280 appMPlayer.mainWindow.ReDraw = (void *)mplMainDraw; |
281 appMPlayer.mainWindow.MouseHandler = mplMainMouseHandle; | |
282 appMPlayer.mainWindow.KeyHandler = mplMainKeyHandle; | |
283 appMPlayer.mainWindow.DandDHandler = mplDandDHandler; | |
284 | |
285 appMPlayer.subWindow.ReDraw = (void *)mplSubDraw; | |
286 appMPlayer.subWindow.MouseHandler = mplSubMouseHandle; | |
287 appMPlayer.subWindow.KeyHandler = mplMainKeyHandle; | |
288 appMPlayer.subWindow.DandDHandler = mplDandDHandler; | |
23077 | 289 |
32984 | 290 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); |
291 wsClearWindow(appMPlayer.subWindow); | |
23077 | 292 |
32984 | 293 if (appMPlayer.sub.Bitmap.Image) |
294 wsConvert(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Image, appMPlayer.sub.Bitmap.ImageSize); | |
295 | |
296 btnModify(evSetVolume, guiIntfStruct.Volume); | |
297 btnModify(evSetBalance, guiIntfStruct.Balance); | |
298 btnModify(evSetMoviePosition, guiIntfStruct.Position); | |
23077 | 299 |
32984 | 300 wsSetIcon(wsDisplay, appMPlayer.mainWindow.WindowID, guiIcon, guiIconMask); |
301 wsSetIcon(wsDisplay, appMPlayer.subWindow.WindowID, guiIcon, guiIconMask); | |
302 | |
303 guiIntfStruct.Playing = 0; | |
23077 | 304 |
32984 | 305 if (!appMPlayer.mainDecoration) |
306 wsWindowDecoration(&appMPlayer.mainWindow, 0); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
307 |
32984 | 308 wsVisibleWindow(&appMPlayer.mainWindow, wsShowWindow); |
23077 | 309 |
310 #if 0 | |
32984 | 311 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); |
312 { | |
313 XEvent xev; | |
23077 | 314 |
32984 | 315 do |
316 XNextEvent(wsDisplay, &xev); | |
317 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
318 | |
319 appMPlayer.subWindow.Mapped = wsMapped; | |
320 } | |
321 | |
322 if (!fullscreen) | |
323 fullscreen = gtkLoadFullscreen; | |
23077 | 324 |
32984 | 325 if (fullscreen) { |
23077 | 326 mplFullScreen(); |
32984 | 327 btnModify(evFullScreen, btnPressed); |
328 } | |
329 #else | |
330 if (!fullscreen) | |
331 fullscreen = gtkLoadFullscreen; | |
332 | |
333 if (gtkShowVideoWindow) { | |
334 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
335 { | |
336 XEvent xev; | |
337 | |
338 do | |
339 XNextEvent(wsDisplay, &xev); | |
340 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
341 | |
342 appMPlayer.subWindow.Mapped = wsMapped; | |
343 } | |
23077 | 344 |
32984 | 345 if (fullscreen) { |
346 mplFullScreen(); | |
347 btnModify(evFullScreen, btnPressed); | |
348 } | |
349 } else { | |
350 if (fullscreen) { | |
351 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
352 { | |
353 XEvent xev; | |
354 | |
355 do | |
356 XNextEvent(wsDisplay, &xev); | |
357 while (xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID); | |
358 | |
359 appMPlayer.subWindow.Mapped = wsMapped; | |
360 } | |
361 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
362 mplFullScreen(); | |
363 btnModify(evFullScreen, btnPressed); | |
364 } | |
365 } | |
23077 | 366 #endif |
32984 | 367 |
368 mplSubRender = 1; | |
369 | |
370 if (filename) | |
371 mplSetFileName(NULL, filename, STREAMTYPE_FILE); | |
23077 | 372 |
32984 | 373 if (plCurrent && !filename) |
374 mplSetFileName(plCurrent->path, plCurrent->name, STREAMTYPE_FILE); | |
375 | |
376 if (subdata) | |
377 guiSetFilename(guiIntfStruct.Subtitlename, subdata->filename); | |
378 | |
379 guiLoadFont(); | |
23077 | 380 } |
381 | |
32984 | 382 void guiDone(void) |
23077 | 383 { |
32984 | 384 mplMainRender = 0; |
385 | |
386 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] done.\n"); | |
23077 | 387 |
32984 | 388 if (gui_save_pos) { |
389 gui_main_pos_x = appMPlayer.mainWindow.X; | |
390 gui_main_pos_y = appMPlayer.mainWindow.Y; | |
391 gui_sub_pos_x = appMPlayer.subWindow.X; | |
392 gui_sub_pos_y = appMPlayer.subWindow.Y; | |
393 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
394 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
395 #ifdef CONFIG_ASS |
32984 | 396 ass_enabled = gtkASS.enabled; |
397 ass_use_margins = gtkASS.use_margins; | |
398 ass_top_margin = gtkASS.top_margin; | |
399 ass_bottom_margin = gtkASS.bottom_margin; | |
23077 | 400 #endif |
401 | |
32984 | 402 cfg_write(); |
403 wsXDone(); | |
23077 | 404 } |
405 | |
32984 | 406 void guiLoadFont(void) |
23077 | 407 { |
27393 | 408 #ifdef CONFIG_FREETYPE |
32984 | 409 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor); |
23077 | 410 #else |
32984 | 411 if (vo_font) { |
412 int i; | |
413 | |
414 free(vo_font->name); | |
415 free(vo_font->fpath); | |
416 | |
417 for (i = 0; i < 16; i++) { | |
418 if (vo_font->pic_a[i]) { | |
419 free(vo_font->pic_a[i]->bmp); | |
420 free(vo_font->pic_a[i]->pal); | |
421 } | |
422 } | |
423 | |
424 for (i = 0; i < 16; i++) { | |
425 if (vo_font->pic_b[i]) { | |
426 free(vo_font->pic_b[i]->bmp); | |
427 free(vo_font->pic_b[i]->pal); | |
428 } | |
429 } | |
430 | |
431 free(vo_font); | |
432 vo_font = NULL; | |
433 } | |
434 | |
435 if (font_name) { | |
436 vo_font = read_font_desc(font_name, font_factor, 0); | |
437 | |
438 if (!vo_font) | |
439 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name); | |
440 } else { | |
441 font_name = gstrdup(get_path("font/font.desc")); | |
442 vo_font = read_font_desc(font_name, font_factor, 0); | |
443 | |
444 if (!vo_font) { | |
445 gfree((void **)&font_name); | |
446 font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc"); | |
447 vo_font = read_font_desc(font_name, font_factor, 0); | |
448 } | |
449 } | |
23077 | 450 #endif |
451 } | |
452 | |
32984 | 453 void guiLoadSubtitle(char *name) |
23077 | 454 { |
32984 | 455 if (guiIntfStruct.Playing == 0) { |
456 guiIntfStruct.SubtitleChanged = 1; // what is this for? (mw) | |
457 return; | |
23077 | 458 } |
32984 | 459 |
460 if (subdata) { | |
461 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles); | |
462 | |
463 sub_free(subdata); | |
464 subdata = NULL; | |
465 vo_sub = NULL; | |
466 | |
467 if (vo_osd_list) { | |
468 int len; | |
469 mp_osd_obj_t *osd; | |
470 | |
471 osd = vo_osd_list; | |
472 | |
473 while (osd) { | |
474 if (osd->type == OSDTYPE_SUBTITLE) | |
475 break; | |
476 | |
477 osd = osd->next; | |
478 } | |
23077 | 479 |
32984 | 480 if (osd && (osd->flags & OSDFLAG_VISIBLE)) { |
481 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1); | |
482 memset(osd->bitmap_buffer, 0, len); | |
483 memset(osd->alpha_buffer, 0, len); | |
484 } | |
485 } | |
486 } | |
487 | |
488 if (name) { | |
489 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name); | |
490 | |
491 subdata = sub_read_file(name, guiIntfStruct.FPS); | |
492 | |
493 if (!subdata) | |
494 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name); | |
495 | |
496 sub_name = (malloc(2 * sizeof(char *))); // when mplayer will be restarted | |
497 sub_name[0] = strdup(name); // sub_name[0] will be read | |
498 sub_name[1] = NULL; | |
499 } | |
500 | |
501 update_set_of_subtitles(); | |
23077 | 502 } |
503 | |
32984 | 504 static void add_vf(char *str) |
23077 | 505 { |
32984 | 506 void *p; |
507 | |
508 if (vf_settings) { | |
509 int i = 0; | |
510 | |
511 while (vf_settings[i].name) { | |
512 if (!gstrcmp(vf_settings[i++].name, str)) { | |
513 i = -1; | |
514 break; | |
515 } | |
516 } | |
517 | |
518 if (i != -1) { | |
519 p = realloc(vf_settings, (i + 2) * sizeof(m_obj_settings_t)); | |
32712 | 520 |
32984 | 521 if (!p) |
522 return; | |
523 | |
524 vf_settings = p; | |
525 vf_settings[i].name = strdup(str); | |
526 vf_settings[i].attribs = NULL; | |
527 vf_settings[i + 1].name = NULL; | |
528 } | |
529 } else { | |
530 vf_settings = malloc(2 * sizeof(m_obj_settings_t)); | |
531 vf_settings[0].name = strdup(str); | |
532 vf_settings[0].attribs = NULL; | |
533 vf_settings[1].name = NULL; | |
32712 | 534 } |
535 | |
32984 | 536 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_AddingVideoFilter, str); |
23077 | 537 } |
538 | |
32984 | 539 static void remove_vf(char *str) |
23077 | 540 { |
32984 | 541 int n = 0; |
542 | |
543 if (!vf_settings) | |
544 return; | |
23077 | 545 |
32984 | 546 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_RemovingVideoFilter, str); |
547 | |
548 while (vf_settings[n++].name) ; | |
23077 | 549 |
32984 | 550 n--; |
551 | |
552 if (n > -1) { | |
553 int i = 0, m = -1; | |
23077 | 554 |
32984 | 555 while (vf_settings[i].name) { |
556 if (!gstrcmp(vf_settings[i++].name, str)) { | |
557 m = i - 1; | |
558 break; | |
559 } | |
560 } | |
561 | |
562 i--; | |
563 | |
564 if (m > -1) { | |
565 if (n == 1) { | |
566 free(vf_settings[0].name); | |
567 free(vf_settings[0].attribs); | |
568 free(vf_settings); | |
569 vf_settings = NULL; | |
570 } else { | |
571 free(vf_settings[i].name); | |
572 free(vf_settings[i].attribs); | |
573 memcpy(&vf_settings[i], &vf_settings[i + 1], (n - i) * sizeof(m_obj_settings_t)); | |
574 } | |
575 } | |
23077 | 576 } |
577 } | |
578 | |
32984 | 579 int guiGetEvent(int type, void *arg) |
23077 | 580 { |
32984 | 581 const ao_functions_t *audio_out = NULL; |
582 const vo_functions_t *video_out = NULL; | |
583 mixer_t *mixer = NULL; | |
23077 | 584 |
32984 | 585 stream_t *stream = arg; |
586 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
587 #ifdef CONFIG_DVDREAD |
32984 | 588 dvd_priv_t *dvdp = arg; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
589 #endif |
23077 | 590 |
32984 | 591 if (guiIntfStruct.mpcontext) { |
592 audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext); | |
593 video_out = mpctx_get_video_out(guiIntfStruct.mpcontext); | |
594 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
595 } | |
23077 | 596 |
32984 | 597 switch (type) { |
598 case guiXEvent: | |
599 guiIntfStruct.event_struct = arg; | |
600 wsEvents(wsDisplay, arg, NULL); | |
23077 | 601 gtkEventHandling(); |
602 break; | |
32984 | 603 |
604 case guiCEvent: | |
605 | |
606 switch ((int)arg) { | |
607 case guiSetPlay: | |
608 guiIntfStruct.Playing = 1; | |
609 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
610 break; | |
611 | |
612 case guiSetStop: | |
613 guiIntfStruct.Playing = 0; | |
614 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
615 break; | |
616 | |
617 case guiSetPause: | |
618 guiIntfStruct.Playing = 2; | |
619 break; | |
620 } | |
621 | |
622 mplState(); | |
23077 | 623 break; |
32984 | 624 |
625 case guiSetState: | |
626 mplState(); | |
627 break; | |
628 | |
629 case guiSetFileName: | |
630 if (arg) | |
631 guiSetFilename(guiIntfStruct.Filename, arg); | |
23077 | 632 break; |
32984 | 633 |
634 case guiSetAudioOnly: | |
635 | |
636 guiIntfStruct.AudioOnly = (int)arg; | |
637 | |
638 if ((int)arg) { | |
639 guiIntfStruct.NoWindow = True; | |
640 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
641 } else | |
642 wsVisibleWindow(&appMPlayer.subWindow, wsShowWindow); | |
643 | |
23077 | 644 break; |
32984 | 645 |
646 case guiSetContext: | |
647 guiIntfStruct.mpcontext = arg; | |
648 // NOTE TO MYSELF: is break missing? | |
649 | |
650 case guiSetDemuxer: | |
651 guiIntfStruct.demuxer = arg; | |
652 break; | |
653 | |
654 case guiSetAfilter: | |
655 guiIntfStruct.afilter = arg; | |
656 break; | |
657 | |
658 case guiSetShVideo: | |
659 | |
660 if (!appMPlayer.subWindow.isFullScreen) { | |
661 wsResizeWindow(&appMPlayer.subWindow, vo_dwidth, vo_dheight); | |
662 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
663 } | |
664 | |
665 guiIntfStruct.MovieWidth = vo_dwidth; | |
666 guiIntfStruct.MovieHeight = vo_dheight; | |
667 | |
668 if (guiWinID >= 0) | |
669 wsMoveWindow(&appMPlayer.mainWindow, 0, 0, vo_dheight); | |
670 | |
671 WinID = appMPlayer.subWindow.WindowID; | |
672 break; | |
673 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
674 #ifdef CONFIG_DVDREAD |
32984 | 675 case guiSetDVD: |
676 guiIntfStruct.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
677 guiIntfStruct.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
678 guiIntfStruct.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
679 guiIntfStruct.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
680 memcpy(guiIntfStruct.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
681 guiIntfStruct.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
682 memcpy(guiIntfStruct.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
683 guiIntfStruct.DVD.current_title = dvd_title + 1; | |
684 guiIntfStruct.DVD.current_chapter = dvd_chapter + 1; | |
685 guiIntfStruct.DVD.current_angle = dvd_angle + 1; | |
686 guiIntfStruct.Track = dvd_title + 1; | |
23077 | 687 break; |
688 #endif | |
32984 | 689 |
690 case guiSetStream: | |
691 | |
692 guiIntfStruct.StreamType = stream->type; | |
693 | |
694 switch (stream->type) { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
695 #ifdef CONFIG_DVDREAD |
32984 | 696 case STREAMTYPE_DVD: |
697 guiGetEvent(guiSetDVD, (char *)stream->priv); | |
698 break; | |
23077 | 699 #endif |
32984 | 700 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
701 #ifdef CONFIG_VCD |
32984 | 702 case STREAMTYPE_VCD: |
33006 | 703 guiIntfStruct.VCDTracks = 0; |
704 stream_control(stream, STREAM_CTRL_GET_NUM_CHAPTERS, &guiIntfStruct.VCDTracks); | |
32984 | 705 break; |
23077 | 706 #endif |
32984 | 707 |
708 default: | |
709 break; | |
710 } | |
711 | |
712 break; | |
713 | |
714 case guiIEvent: | |
715 | |
716 mp_msg(MSGT_GPLAYER, MSGL_V, "cmd: %d\n", (int)arg); | |
717 | |
718 switch ((int)arg) { | |
719 case MP_CMD_QUIT: | |
720 mplEventHandling(evExit, 0); | |
721 break; | |
23077 | 722 |
32984 | 723 case MP_CMD_VO_FULLSCREEN: |
724 mplEventHandling(evFullScreen, 0); | |
725 break; | |
726 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
727 |
32984 | 728 break; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
729 |
32984 | 730 case guiReDraw: |
731 mplEventHandling(evRedraw, 0); | |
732 break; | |
733 | |
734 case guiSetVolume: | |
735 if (audio_out) { | |
736 float l, r; | |
737 | |
738 mixer_getvolume(mixer, &l, &r); | |
739 guiIntfStruct.Volume = (r > l ? r : l); | |
23077 | 740 |
32984 | 741 if (r != l) |
742 guiIntfStruct.Balance = ((r - l) + 100) * 0.5f; | |
743 else | |
744 guiIntfStruct.Balance = 50.0f; | |
745 | |
746 btnModify(evSetVolume, guiIntfStruct.Volume); | |
747 btnModify(evSetBalance, guiIntfStruct.Balance); | |
748 } | |
749 break; | |
750 | |
751 case guiSetFileFormat: | |
752 guiIntfStruct.FileFormat = (int)arg; | |
753 break; | |
754 | |
755 case guiSetValues: | |
756 | |
757 // video | |
758 | |
759 guiIntfStruct.sh_video = arg; | |
760 | |
761 if (arg) { | |
762 sh_video_t *sh = arg; | |
763 guiIntfStruct.FPS = sh->fps; | |
764 } | |
765 | |
766 if (guiIntfStruct.NoWindow) | |
767 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
768 | |
769 if (guiIntfStruct.StreamType == STREAMTYPE_STREAM) | |
770 btnSet(evSetMoviePosition, btnDisabled); | |
771 else | |
772 btnSet(evSetMoviePosition, btnReleased); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
773 |
32984 | 774 // audio |
775 | |
776 if (audio_out) { | |
777 float l, r; | |
778 | |
779 mixer_getvolume(mixer, &l, &r); | |
780 guiIntfStruct.Volume = (r > l ? r : l); | |
781 | |
782 if (r != l) | |
783 guiIntfStruct.Balance = ((r - l) + 100) * 0.5f; | |
784 else | |
785 guiIntfStruct.Balance = 50.0f; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
786 |
32984 | 787 btnModify(evSetVolume, guiIntfStruct.Volume); |
788 btnModify(evSetBalance, guiIntfStruct.Balance); | |
789 } | |
790 | |
791 if (gtkEnableAudioEqualizer) { | |
792 equalizer_t eq; | |
793 int i, j; | |
23077 | 794 |
32984 | 795 for (i = 0; i < 6; i++) { |
796 for (j = 0; j < 10; j++) { | |
797 eq.channel = i; | |
798 eq.band = j; | |
799 eq.gain = gtkEquChannels[i][j]; | |
800 gtkSet(gtkSetEqualizer, 0, &eq); | |
801 } | |
802 } | |
803 } | |
804 | |
805 // subtitle | |
23077 | 806 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
807 #ifdef CONFIG_DXR3 |
32984 | 808 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3") && (guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS) && !gtkVfLAVC) { |
809 gtkMessageBox(GTK_MB_FATAL, MSGTR_NEEDLAVC); | |
810 guiIntfStruct.Playing = 0; | |
811 return True; | |
812 } | |
23077 | 813 #endif |
32984 | 814 |
815 break; | |
816 | |
817 case guiSetDefaults: | |
818 | |
819 // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) | |
820 if (guiIntfStruct.FilenameChanged) { | |
821 audio_id = -1; | |
822 video_id = -1; | |
823 dvdsub_id = -1; | |
824 vobsub_id = -1; | |
825 stream_cache_size = -1; | |
826 autosync = 0; | |
827 dvd_title = 0; | |
828 force_fps = 0; | |
829 } | |
830 | |
831 guiIntfStruct.demuxer = NULL; | |
832 guiIntfStruct.sh_video = NULL; | |
833 wsPostRedisplay(&appMPlayer.subWindow); | |
834 | |
835 break; | |
836 | |
837 case guiSetParameters: | |
838 | |
839 guiGetEvent(guiSetDefaults, NULL); | |
840 | |
841 switch (guiIntfStruct.StreamType) { | |
842 case STREAMTYPE_PLAYLIST: | |
843 break; | |
844 | |
845 #ifdef CONFIG_VCD | |
846 case STREAMTYPE_VCD: | |
847 { | |
848 char tmp[512]; | |
849 | |
850 sprintf(tmp, "vcd://%d", guiIntfStruct.Track + 1); | |
851 guiSetFilename(guiIntfStruct.Filename, tmp); | |
852 } | |
853 break; | |
854 #endif | |
855 | |
856 #ifdef CONFIG_DVDREAD | |
857 case STREAMTYPE_DVD: | |
858 { | |
859 char tmp[512]; | |
860 | |
861 sprintf(tmp, "dvd://%d", guiIntfStruct.Title); | |
862 guiSetFilename(guiIntfStruct.Filename, tmp); | |
863 } | |
864 | |
865 dvd_chapter = guiIntfStruct.Chapter; | |
866 dvd_angle = guiIntfStruct.Angle; | |
867 | |
868 break; | |
869 #endif | |
870 } | |
871 | |
872 // if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! | |
873 { | |
874 if (guiIntfStruct.Filename) | |
875 filename = gstrdup(guiIntfStruct.Filename); | |
876 else if (filename) | |
877 guiSetFilename(guiIntfStruct.Filename, filename); | |
878 } | |
879 | |
880 // video opts | |
881 | |
882 if (!video_driver_list) { | |
883 int i = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
884 |
32984 | 885 while (video_out_drivers[i++]) { |
886 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
887 gaddlist(&video_driver_list, (char *)video_out_drivers[i - 1]->info->short_name); | |
888 break; | |
889 } | |
890 } | |
891 } | |
892 | |
893 if (!video_driver_list && !video_driver_list[0]) { | |
33024 | 894 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_IDFGCVD); |
32984 | 895 exit_player(EXIT_ERROR); |
896 } | |
897 | |
898 { | |
899 int i = 0; | |
900 | |
901 guiIntfStruct.NoWindow = False; | |
902 | |
903 while (video_out_drivers[i++]) { | |
904 if (video_out_drivers[i - 1]->control(VOCTRL_GUISUPPORT, NULL) == VO_TRUE) { | |
905 if ((video_driver_list && !gstrcmp(video_driver_list[0], (char *)video_out_drivers[i - 1]->info->short_name)) && (video_out_drivers[i - 1]->control(VOCTRL_GUI_NOWINDOW, NULL) == VO_TRUE)) { | |
906 guiIntfStruct.NoWindow = True; | |
907 break; | |
908 } | |
909 } | |
910 } | |
911 } | |
912 | |
913 #ifdef CONFIG_DXR3 | |
914 remove_vf("lavc"); | |
915 | |
916 if (video_driver_list && !gstrcmp(video_driver_list[0], "dxr3")) | |
917 if (guiIntfStruct.StreamType != STREAMTYPE_DVD && guiIntfStruct.StreamType != STREAMTYPE_VCD) | |
918 if (gtkVfLAVC) | |
919 add_vf("lavc"); | |
920 #endif | |
921 | |
922 if (gtkVfPP) | |
923 add_vf("pp"); | |
924 else | |
925 remove_vf("pp"); | |
926 | |
927 // audio opts | |
928 | |
929 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
930 if (gtkAONorm) | |
931 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
932 | |
933 if (gtkEnableAudioEqualizer) | |
934 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
935 | |
936 if (gtkAOExtraStereo) { | |
937 char *name; | |
938 | |
939 name = malloc(12 + 20 + 1); | |
940 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
941 name[12 + 20] = 0; | |
942 greplace(&af_cfg.list, "extrastereo", name); | |
943 free(name); | |
944 } | |
945 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
946 #ifdef CONFIG_OSS_AUDIO |
32984 | 947 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "oss", 3)) { |
948 char *tmp; | |
949 | |
950 mixer_device = gtkAOOSSMixer; | |
951 mixer_channel = gtkAOOSSMixerChannel; | |
952 | |
953 if (gtkAOOSSDevice) { | |
954 tmp = calloc(1, strlen(gtkAOOSSDevice) + 7); | |
955 sprintf(tmp, "oss:%s", gtkAOOSSDevice); | |
956 } else | |
957 tmp = strdup("oss"); | |
958 | |
959 gaddlist(&audio_driver_list, tmp); | |
960 free(tmp); | |
961 } | |
23077 | 962 #endif |
32984 | 963 |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
964 #ifdef CONFIG_ALSA |
32984 | 965 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "alsa", 4)) { |
966 char *tmp; | |
967 | |
968 mixer_device = gtkAOALSAMixer; | |
969 mixer_channel = gtkAOALSAMixerChannel; | |
970 | |
971 if (gtkAOALSADevice) { | |
972 tmp = calloc(1, strlen(gtkAOALSADevice) + 14); | |
973 sprintf(tmp, "alsa:device=%s", gtkAOALSADevice); | |
974 } else | |
975 tmp = strdup("alsa"); | |
976 | |
977 gaddlist(&audio_driver_list, tmp); | |
978 free(tmp); | |
979 } | |
23077 | 980 #endif |
32984 | 981 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
982 #ifdef CONFIG_SDL |
32984 | 983 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "sdl", 3)) { |
984 char *tmp; | |
985 | |
986 if (gtkAOSDLDriver) { | |
987 tmp = calloc(1, strlen(gtkAOSDLDriver) + 10); | |
988 sprintf(tmp, "sdl:%s", gtkAOSDLDriver); | |
989 } else | |
990 tmp = strdup("sdl"); | |
991 | |
992 gaddlist(&audio_driver_list, tmp); | |
993 free(tmp); | |
994 } | |
23077 | 995 #endif |
32984 | 996 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
997 #ifdef CONFIG_ESD |
32984 | 998 if (audio_driver_list && !gstrncmp(audio_driver_list[0], "esd", 3)) { |
999 char *tmp; | |
1000 | |
1001 if (gtkAOESDDevice) { | |
1002 tmp = calloc(1, strlen(gtkAOESDDevice) + 10); | |
1003 sprintf(tmp, "esd:%s", gtkAOESDDevice); | |
1004 } else | |
1005 tmp = strdup("esd"); | |
1006 | |
1007 gaddlist(&audio_driver_list, tmp); | |
1008 free(tmp); | |
1009 } | |
23077 | 1010 #endif |
32984 | 1011 |
1012 // subtitle | |
1013 | |
1014 // subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); | |
1015 stream_dump_type = 0; | |
1016 | |
1017 if (gtkSubDumpMPSub) | |
1018 stream_dump_type = 4; | |
1019 | |
1020 if (gtkSubDumpSrt) | |
1021 stream_dump_type = 6; | |
1022 | |
1023 gtkSubDumpMPSub = gtkSubDumpSrt = 0; | |
23077 | 1024 guiLoadFont(); |
1025 | |
32984 | 1026 // misc |
1027 | |
1028 if (gtkCacheOn) | |
1029 stream_cache_size = gtkCacheSize; | |
1030 | |
1031 if (gtkAutoSyncOn) | |
1032 autosync = gtkAutoSync; | |
23077 | 1033 |
32984 | 1034 if (guiIntfStruct.AudioFile) |
1035 audio_stream = gstrdup(guiIntfStruct.AudioFile); | |
1036 else if (guiIntfStruct.FilenameChanged) | |
1037 gfree((void **)&audio_stream); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1038 |
32984 | 1039 // audio_stream = NULL; |
1040 | |
1041 guiIntfStruct.DiskChanged = 0; | |
1042 guiIntfStruct.FilenameChanged = 0; | |
1043 guiIntfStruct.NewPlay = 0; | |
23077 | 1044 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1045 #ifdef CONFIG_ASS |
32984 | 1046 ass_enabled = gtkASS.enabled; |
1047 ass_use_margins = gtkASS.use_margins; | |
1048 ass_top_margin = gtkASS.top_margin; | |
23077 | 1049 ass_bottom_margin = gtkASS.bottom_margin; |
1050 #endif | |
1051 | |
32984 | 1052 break; |
1053 } | |
1054 | |
1055 return False; | |
23077 | 1056 } |
1057 | |
32984 | 1058 void guiEventHandling(void) |
23077 | 1059 { |
32984 | 1060 if (!guiIntfStruct.Playing || guiIntfStruct.NoWindow) |
1061 wsHandleEvents(); | |
1062 | |
1063 gtkEventHandling(); | |
23077 | 1064 } |
1065 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1066 // --- |
32984 | 1067 #if defined(MP_DEBUG) && 0 |
1068 void list(void) | |
1069 { | |
1070 plItem *next = plList; | |
23077 | 1071 |
32984 | 1072 printf("--- list ---\n"); |
23077 | 1073 |
32984 | 1074 while (next || next->next) { |
1075 printf("item: %s/%s\n", next->path, next->name); | |
1076 | |
1077 if (next->next) | |
1078 next = next->next; | |
1079 else | |
1080 break; | |
1081 } | |
1082 | |
1083 printf("--- end of list ---\n"); | |
23077 | 1084 } |
1085 #else | |
1086 #define list(); | |
1087 #endif | |
1088 | |
32984 | 1089 void *gtkSet(int cmd, float fparam, void *vparam) |
23077 | 1090 { |
32984 | 1091 equalizer_t *eq = (equalizer_t *)vparam; |
1092 plItem *item = (plItem *)vparam; | |
1093 URLItem *url_item = (URLItem *)vparam; | |
1094 int is_added = True; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1095 |
32984 | 1096 switch (cmd) { |
1097 // handle playlist | |
1098 | |
1099 // add item to playlist | |
1100 case gtkAddPlItem: | |
23077 | 1101 |
32984 | 1102 if (plList) { |
1103 plItem *next = plList; | |
1104 | |
1105 while (next->next) | |
1106 // { | |
1107 // printf( "%s\n",next->name ); | |
1108 next = next->next; | |
1109 // } | |
1110 | |
1111 next->next = item; | |
1112 item->prev = next; | |
1113 } else { | |
1114 item->prev = item->next = NULL; | |
1115 plCurrent = plList = item; | |
1116 } | |
1117 | |
23077 | 1118 list(); |
33053 | 1119 |
23077 | 1120 return NULL; |
32984 | 1121 |
1122 // add item into playlist after current | |
1123 case gtkInsertPlItem: | |
1124 if (plCurrent) { | |
1125 plItem *curr = plCurrent; | |
1126 item->next = curr->next; | |
1127 | |
1128 if (item->next) | |
1129 item->next->prev = item; | |
1130 | |
1131 item->prev = curr; | |
1132 curr->next = item; | |
1133 plCurrent = plCurrent->next; | |
1134 | |
1135 return plCurrent; | |
1136 } else | |
1137 return gtkSet(gtkAddPlItem, 0, (void *)item); | |
1138 return NULL; // NOTE TO MYSELF: remove this | |
1139 | |
1140 // get current item from playlist | |
1141 case gtkGetNextPlItem: | |
1142 if (plCurrent && plCurrent->next) { | |
1143 plCurrent = plCurrent->next; | |
1144 // if (!plCurrent && plList) | |
1145 // { | |
1146 // plItem *next = plList; | |
1147 // | |
1148 // while (next->next) | |
1149 // { | |
1150 // if (!next->next) break; | |
1151 // next = next->next; | |
1152 // } | |
1153 // | |
1154 // plCurrent = next; | |
1155 // } | |
1156 return plCurrent; | |
1157 } | |
33053 | 1158 |
23077 | 1159 return NULL; |
32984 | 1160 |
1161 case gtkGetPrevPlItem: | |
1162 if (plCurrent && plCurrent->prev) { | |
1163 plCurrent = plCurrent->prev; | |
1164 // if ( !plCurrent && plList ) plCurrent=plList; | |
1165 return plCurrent; | |
1166 } | |
33053 | 1167 |
23077 | 1168 return NULL; |
32984 | 1169 |
1170 // set current item | |
1171 case gtkSetCurrPlItem: | |
1172 plCurrent = item; | |
1173 return plCurrent; | |
1174 | |
1175 // get current item | |
1176 case gtkGetCurrPlItem: | |
23077 | 1177 return plCurrent; |
32984 | 1178 |
1179 // delete current item | |
1180 case gtkDelCurrPlItem: | |
1181 { | |
1182 plItem *curr = plCurrent; | |
1183 | |
1184 if (!curr) | |
1185 return NULL; | |
23077 | 1186 |
32984 | 1187 if (curr->prev) |
1188 curr->prev->next = curr->next; | |
1189 if (curr->next) | |
1190 curr->next->prev = curr->prev; | |
1191 if (curr == plList) | |
1192 plList = curr->next; | |
1193 | |
1194 plCurrent = curr->next; | |
1195 | |
1196 // free it | |
1197 free(curr->path); | |
1198 free(curr->name); | |
1199 free(curr); | |
1200 } | |
1201 | |
1202 mplCurr(); // instead of using mplNext && mplPrev | |
33053 | 1203 |
32984 | 1204 return plCurrent; |
1205 | |
1206 // delete list | |
1207 case gtkDelPl: | |
1208 { | |
1209 plItem *curr = plList; | |
1210 plItem *next; | |
1211 | |
1212 if (!plList) | |
1213 return NULL; | |
23077 | 1214 |
32984 | 1215 if (!curr->next) { |
1216 free(curr->path); | |
1217 free(curr->name); | |
1218 free(curr); | |
1219 } else { | |
1220 while (curr->next) { | |
1221 next = curr->next; | |
1222 free(curr->path); | |
1223 free(curr->name); | |
1224 free(curr); | |
1225 curr = next; | |
1226 } | |
1227 } | |
1228 | |
1229 plList = NULL; | |
1230 plCurrent = NULL; | |
1231 } | |
33053 | 1232 |
23077 | 1233 return NULL; |
32984 | 1234 |
1235 // handle url | |
1236 case gtkAddURLItem: | |
1237 if (URLList) { | |
1238 URLItem *next_url = URLList; | |
1239 is_added = False; | |
1240 | |
1241 while (next_url->next) { | |
1242 if (!gstrcmp(next_url->url, url_item->url)) { | |
1243 is_added = True; | |
1244 break; | |
1245 } | |
1246 | |
1247 next_url = next_url->next; | |
1248 } | |
1249 | |
1250 if (!is_added && gstrcmp(next_url->url, url_item->url)) | |
1251 next_url->next = url_item; | |
1252 } else { | |
1253 url_item->next = NULL; | |
1254 URLList = url_item; | |
1255 } | |
33053 | 1256 |
23077 | 1257 return NULL; |
32984 | 1258 |
1259 // subtitle | |
1260 | |
27393 | 1261 #ifndef CONFIG_FREETYPE |
32984 | 1262 case gtkSetFontFactor: |
1263 font_factor = fparam; | |
1264 guiLoadFont(); | |
1265 return NULL; | |
23077 | 1266 #else |
32984 | 1267 case gtkSetFontOutLine: |
1268 subtitle_font_thickness = (8.0f / 100.0f) * fparam; | |
1269 guiLoadFont(); | |
1270 return NULL; | |
1271 | |
1272 case gtkSetFontBlur: | |
1273 subtitle_font_radius = (8.0f / 100.0f) * fparam; | |
1274 guiLoadFont(); | |
1275 return NULL; | |
1276 | |
1277 case gtkSetFontTextScale: | |
1278 text_font_scale_factor = fparam; | |
1279 guiLoadFont(); | |
1280 return NULL; | |
1281 | |
1282 case gtkSetFontOSDScale: | |
1283 osd_font_scale_factor = fparam; | |
1284 guiLoadFont(); | |
1285 return NULL; | |
1286 | |
1287 case gtkSetFontEncoding: | |
1288 gfree((void **)&subtitle_font_encoding); | |
1289 subtitle_font_encoding = gstrdup((char *)vparam); | |
1290 guiLoadFont(); | |
1291 return NULL; | |
1292 | |
1293 case gtkSetFontAutoScale: | |
1294 subtitle_autoscale = (int)fparam; | |
1295 guiLoadFont(); | |
1296 return NULL; | |
23077 | 1297 #endif |
32984 | 1298 |
27393 | 1299 #ifdef CONFIG_ICONV |
32984 | 1300 case gtkSetSubEncoding: |
1301 gfree((void **)&sub_cp); | |
1302 sub_cp = gstrdup((char *)vparam); | |
1303 break; | |
23077 | 1304 #endif |
32984 | 1305 |
1306 // misc | |
1307 | |
1308 case gtkClearStruct: | |
1309 | |
1310 if ((unsigned int)vparam & guiFilenames) { | |
1311 gfree((void **)&guiIntfStruct.Filename); | |
1312 gfree((void **)&guiIntfStruct.Subtitlename); | |
1313 gfree((void **)&guiIntfStruct.AudioFile); | |
1314 gtkSet(gtkDelPl, 0, NULL); | |
1315 } | |
1316 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
1317 #ifdef CONFIG_DVDREAD |
32984 | 1318 if ((unsigned int)vparam & guiDVD) |
1319 memset(&guiIntfStruct.DVD, 0, sizeof(guiDVDStruct)); | |
23077 | 1320 #endif |
32984 | 1321 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
1322 #ifdef CONFIG_VCD |
32984 | 1323 if ((unsigned int)vparam & guiVCD) |
1324 guiIntfStruct.VCDTracks = 0; | |
23077 | 1325 #endif |
32984 | 1326 |
1327 return NULL; | |
1328 | |
1329 case gtkSetExtraStereo: | |
1330 gtkAOExtraStereoMul = fparam; | |
23077 | 1331 if (guiIntfStruct.afilter) |
32984 | 1332 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); |
1333 return NULL; | |
1334 | |
1335 case gtkSetPanscan: | |
1336 { | |
1337 mp_cmd_t *mp_cmd; | |
1338 | |
1339 mp_cmd = calloc(1, sizeof(*mp_cmd)); | |
1340 mp_cmd->id = MP_CMD_PANSCAN; | |
1341 mp_cmd->name = strdup("panscan"); | |
1342 mp_cmd->args[0].v.f = fparam; | |
1343 mp_cmd->args[1].v.i = 1; | |
1344 mp_input_queue_cmd(mp_cmd); | |
1345 } | |
33053 | 1346 |
23077 | 1347 return NULL; |
32984 | 1348 |
1349 case gtkSetAutoq: | |
1350 auto_quality = (int)fparam; | |
1351 return NULL; | |
1352 | |
1353 // set equalizers | |
1354 | |
1355 case gtkSetContrast: | |
1356 if (guiIntfStruct.sh_video) | |
1357 set_video_colors(guiIntfStruct.sh_video, "contrast", (int)fparam); | |
1358 return NULL; | |
1359 | |
1360 case gtkSetBrightness: | |
1361 if (guiIntfStruct.sh_video) | |
1362 set_video_colors(guiIntfStruct.sh_video, "brightness", (int)fparam); | |
1363 return NULL; | |
1364 | |
1365 case gtkSetHue: | |
1366 if (guiIntfStruct.sh_video) | |
1367 set_video_colors(guiIntfStruct.sh_video, "hue", (int)fparam); | |
23077 | 1368 return NULL; |
32984 | 1369 |
1370 case gtkSetSaturation: | |
1371 if (guiIntfStruct.sh_video) | |
1372 set_video_colors(guiIntfStruct.sh_video, "saturation", (int)fparam); | |
1373 return NULL; | |
1374 | |
1375 case gtkSetEqualizer: | |
1376 { | |
23077 | 1377 af_control_ext_t tmp; |
32984 | 1378 |
1379 if (eq) { | |
1380 gtkEquChannels[eq->channel][eq->band] = eq->gain; | |
1381 tmp.ch = eq->channel; | |
1382 tmp.arg = gtkEquChannels[eq->channel]; | |
1383 | |
1384 if (guiIntfStruct.afilter) | |
1385 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1386 } else { | |
1387 int i; | |
1388 | |
1389 memset(gtkEquChannels, 0, sizeof(gtkEquChannels)); | |
1390 | |
1391 if (guiIntfStruct.afilter) { | |
1392 for (i = 0; i < 6; i++) { | |
1393 tmp.ch = i; | |
1394 tmp.arg = gtkEquChannels[i]; | |
1395 af_control_any_rev(guiIntfStruct.afilter, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1396 } | |
1397 } | |
1398 } | |
1399 | |
1400 return NULL; | |
1401 } | |
1402 } | |
1403 | |
1404 return NULL; | |
23077 | 1405 } |
1406 | |
32984 | 1407 // This function adds/inserts one file into the gui playlist. |
1408 static int import_file_into_gui(char *temp, int insert) | |
1409 { | |
1410 char *filename, *pathname; | |
1411 plItem *item; | |
23077 | 1412 |
32984 | 1413 filename = strdup(mp_basename(temp)); |
1414 pathname = strdup(temp); | |
1415 | |
1416 if (strlen(pathname) - strlen(filename) > 0) | |
1417 pathname[strlen(pathname) - strlen(filename) - 1] = 0; // we have some path, so remove / at end | |
1418 else | |
1419 pathname[strlen(pathname) - strlen(filename)] = 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1420 |
32984 | 1421 // NOTE TO MYSELF: FIXME: Change to MSGL_DBG2? |
1422 mp_msg(MSGT_PLAYTREE, MSGL_V, "Adding filename %s && pathname %s\n", filename, pathname); | |
1423 | |
1424 item = calloc(1, sizeof(plItem)); | |
1425 | |
1426 if (!item) | |
1427 return 0; | |
1428 | |
1429 item->name = filename; | |
1430 item->path = pathname; | |
1431 | |
1432 if (insert) | |
1433 gtkSet(gtkInsertPlItem, 0, (void *)item); // inserts the item after current, and makes current=item | |
1434 else | |
1435 gtkSet(gtkAddPlItem, 0, (void *)item); | |
1436 | |
1437 return 1; | |
23077 | 1438 } |
1439 | |
32984 | 1440 // This function imports the initial playtree (based on cmd-line files) |
1441 // into the gui playlist by either: | |
1442 // - overwriting gui pl (enqueue=0) | |
1443 // - appending it to gui pl (enqueue=1) | |
1444 int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue) | |
1445 { | |
1446 play_tree_iter_t *my_pt_iter = NULL; | |
1447 int result = 0; | |
23077 | 1448 |
32984 | 1449 if (!enqueue) |
1450 gtkSet(gtkDelPl, 0, 0); // delete playlist before "appending" | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1451 |
32984 | 1452 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
1453 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
1454 // add it to end of list | |
1455 if (import_file_into_gui(filename, 0)) | |
1456 result = 1; | |
23077 | 1457 } |
1458 | |
32984 | 1459 mplCurr(); // update filename |
1460 mplGotoTheNext = 1; | |
23077 | 1461 |
32984 | 1462 if (!enqueue) |
1463 filename = guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline, | |
1464 // gmplayer does directly start in Play-Mode. | |
1465 else | |
1466 filename = NULL; | |
23077 | 1467 |
32984 | 1468 return result; |
23077 | 1469 } |
1470 | |
32984 | 1471 // This function imports and inserts an playtree, that is created "on the fly", |
1472 // for example by parsing some MOV-Reference-File; or by loading an playlist | |
1473 // with "File Open". | |
23077 | 1474 // The file which contained the playlist is thereby replaced with it's contents. |
32984 | 1475 int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config) |
1476 { | |
1477 play_tree_iter_t *my_pt_iter = NULL; | |
1478 int result = 0; | |
1479 plItem *save; | |
23077 | 1480 |
32984 | 1481 save = (plItem *)gtkSet(gtkGetCurrPlItem, 0, 0); // save current item |
23077 | 1482 |
32984 | 1483 if ((my_pt_iter = pt_iter_create(&my_playtree, config))) { |
1484 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
1485 // insert it into the list and set plCurrent=new item | |
1486 if (import_file_into_gui(filename, 1)) | |
1487 result = 1; | |
1488 | |
1489 pt_iter_destroy(&my_pt_iter); | |
23077 | 1490 } |
1491 | |
32984 | 1492 if (save) |
1493 gtkSet(gtkSetCurrPlItem, 0, (void *)save); | |
1494 else | |
1495 gtkSet(gtkSetCurrPlItem, 0, (void *)plList); // go to head, if plList was empty before | |
23077 | 1496 |
32984 | 1497 if (save && result) |
1498 gtkSet(gtkDelCurrPlItem, 0, 0); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1499 |
32984 | 1500 mplCurr(); // update filename |
1501 filename = NULL; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27393
diff
changeset
|
1502 |
32984 | 1503 return result; |
23077 | 1504 } |
33023 | 1505 |
1506 // NOTE TO MYSELF: This function is nonsense. | |
1507 // MPlayer should pass messages to the GUI | |
1508 // which must decide then which message has | |
1509 // to be shown (MSGL_FATAL, for example). | |
1510 // But with this function it is at least | |
1511 // possible to show GUI's very critical or | |
1512 // abort messages. | |
1513 void gmp_msg(int mod, int lev, const char *format, ...) | |
1514 { | |
1515 char msg[512]; | |
1516 va_list va; | |
1517 | |
1518 va_start(va, format); | |
1519 vsnprintf(msg, sizeof(msg), format, va); | |
1520 va_end(va); | |
1521 | |
1522 mp_msg(mod, lev, msg); | |
1523 | |
1524 if (mp_msg_test(mod, lev)) | |
1525 gtkMessageBox(GTK_MB_FATAL, msg); | |
1526 } |