Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 35806:ea15d7aebf13
Cosmetic: Adjust indent.
author | ib |
---|---|
date | Sat, 26 Jan 2013 15:35:10 +0000 |
parents | 5d163370a554 |
children | 9474726062ef |
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 |
35437 | 19 /** |
20 * @file | |
21 * @brief User interface actions | |
22 */ | |
23 | |
23077 | 24 #include <stdlib.h> |
25 #include <string.h> | |
26 | |
33556 | 27 #include "actions.h" |
35528 | 28 #include "ui.h" |
35525 | 29 #include "gui/app/app.h" |
35771 | 30 #include "gui/app/cfg.h" |
35525 | 31 #include "gui/app/gui.h" |
35771 | 32 #include "gui/dialog/dialog.h" |
32881 | 33 #include "gui/interface.h" |
34 #include "gui/skin/skin.h" | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
35 #include "gui/util/list.h" |
33739 | 36 #include "gui/util/mem.h" |
33737 | 37 #include "gui/util/string.h" |
35435 | 38 #include "gui/wm/ws.h" |
32881 | 39 #include "gui/wm/wsxdnd.h" |
23077 | 40 |
35771 | 41 #include "access_mpcontext.h" |
42 #include "config.h" | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
43 #include "help_mp.h" |
32881 | 44 #include "input/input.h" |
35771 | 45 #include "libmpcodecs/vd.h" |
35431 | 46 #include "libmpdemux/demuxer.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
47 #include "libvo/video_out.h" |
35771 | 48 #include "libvo/wskeys.h" |
49 #include "libvo/x11_common.h" | |
50 #include "m_property.h" | |
51 #include "mixer.h" | |
32881 | 52 #include "mp_core.h" |
35435 | 53 #include "mp_msg.h" |
35771 | 54 #include "mpcommon.h" |
35435 | 55 #include "mplayer.h" |
35771 | 56 #include "osdep/timer.h" |
57 #include "stream/stream.h" | |
58 #include "sub/sub.h" | |
59 | |
35776 | 60 #define GUI_REDRAW_WAIT 375 // in milliseconds |
35771 | 61 |
35777 | 62 int uiLoadPlay; |
63 | |
35775 | 64 static unsigned int last_redraw_time; |
35771 | 65 |
35776 | 66 /** |
67 * @brief Clear information not used for this @a type of stream. | |
68 * | |
69 * @param type stream type | |
70 */ | |
35771 | 71 static void MediumPrepare(int type) |
72 { | |
73 switch (type) { | |
74 case STREAMTYPE_DVD: | |
75 listMgr(PLAYLIST_DELETE, 0); | |
76 break; | |
77 | |
78 case STREAMTYPE_CDDA: | |
79 case STREAMTYPE_VCD: | |
80 listMgr(PLAYLIST_DELETE, 0); | |
81 case STREAMTYPE_FILE: | |
82 case STREAMTYPE_STREAM: | |
83 case STREAMTYPE_PLAYLIST: | |
84 guiInfo.AudioStreams = 0; | |
85 guiInfo.Subtitles = 0; | |
86 guiInfo.Chapters = 0; | |
87 guiInfo.Angles = 0; | |
88 break; | |
89 } | |
90 } | |
91 | |
35773 | 92 void uiEvent(int ev, float param) |
35771 | 93 { |
94 int iparam = (int)param, osd; | |
95 mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
96 | |
35773 | 97 switch (ev) { |
35771 | 98 /* user events */ |
99 case evExit: | |
100 mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0); | |
101 break; | |
102 | |
103 case evLoadURL: | |
104 gtkShow(evLoadURL, NULL); | |
105 break; | |
106 | |
107 case ivSetAudio: | |
108 | |
109 if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam) | |
110 break; | |
111 | |
112 mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
113 break; | |
114 | |
115 case ivSetVideo: | |
116 | |
117 if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam) | |
118 break; | |
119 | |
120 mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
121 break; | |
122 | |
123 case ivSetSubtitle: | |
124 mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
125 break; | |
126 | |
127 #ifdef CONFIG_CDDA | |
128 case ivSetCDTrack: | |
129 guiInfo.Track = iparam; | |
130 | |
131 case evPlayCD: | |
132 guiInfo.StreamType = STREAMTYPE_CDDA; | |
133 goto play; | |
134 | |
135 #endif | |
136 #ifdef CONFIG_VCD | |
137 case ivSetVCDTrack: | |
138 guiInfo.Track = iparam; | |
139 | |
140 case evPlayVCD: | |
141 guiInfo.StreamType = STREAMTYPE_VCD; | |
142 goto play; | |
143 | |
144 #endif | |
145 #ifdef CONFIG_DVDREAD | |
146 case ivSetDVDSubtitle: | |
147 dvdsub_id = iparam; | |
35773 | 148 uiEvent(ivPlayDVD, 0); |
35771 | 149 break; |
150 | |
151 case ivSetDVDAudio: | |
152 audio_id = iparam; | |
35773 | 153 uiEvent(ivPlayDVD, 0); |
35771 | 154 break; |
155 | |
156 case ivSetDVDChapter: | |
157 guiInfo.Chapter = iparam; | |
35773 | 158 uiEvent(ivPlayDVD, 0); |
35771 | 159 break; |
160 | |
161 case ivSetDVDTitle: | |
162 guiInfo.Track = iparam; | |
163 guiInfo.Chapter = 1; | |
164 guiInfo.Angle = 1; | |
35773 | 165 uiEvent(ivPlayDVD, 0); |
35771 | 166 break; |
167 | |
168 case evPlayDVD: | |
169 guiInfo.Chapter = 1; | |
170 guiInfo.Angle = 1; | |
171 | |
172 case ivPlayDVD: | |
173 guiInfo.StreamType = STREAMTYPE_DVD; | |
174 goto play; | |
175 | |
176 #endif | |
177 case evPlay: | |
178 case evPlaySwitchToPause: | |
179 play: | |
180 | |
35791 | 181 if (guiInfo.Playing != GUI_PAUSE) { |
35792 | 182 MediumPrepare(guiInfo.StreamType); |
35771 | 183 |
35792 | 184 switch (guiInfo.StreamType) { |
185 case STREAMTYPE_FILE: | |
186 case STREAMTYPE_STREAM: | |
187 case STREAMTYPE_PLAYLIST: | |
35771 | 188 |
35792 | 189 if (!guiInfo.Track) |
190 guiInfo.Track = 1; | |
35771 | 191 |
35792 | 192 guiInfo.NewPlay = GUI_FILE_NEW; |
193 guiInfo.PlaylistNext = !guiInfo.Playing; | |
35791 | 194 |
35792 | 195 break; |
35771 | 196 |
35792 | 197 case STREAMTYPE_CDDA: |
198 case STREAMTYPE_VCD: | |
199 case STREAMTYPE_DVD: | |
35771 | 200 |
201 if (!guiInfo.Track) | |
35793 | 202 guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); |
35771 | 203 |
204 guiInfo.NewPlay = GUI_FILE_SAME; | |
205 | |
35792 | 206 break; |
207 } | |
35791 | 208 } |
35771 | 209 |
210 uiPlay(); | |
211 break; | |
212 | |
213 case evPause: | |
214 case evPauseSwitchToPlay: | |
215 uiPause(); | |
216 break; | |
217 | |
218 case evStop: | |
219 guiInfo.Playing = GUI_STOP; | |
220 uiState(); | |
221 break; | |
222 | |
223 case evLoadPlay: | |
224 uiLoadPlay = True; | |
225 | |
226 // guiInfo.StreamType=STREAMTYPE_FILE; | |
227 case evLoad: | |
228 gtkShow(evLoad, NULL); | |
229 break; | |
230 | |
231 case evLoadSubtitle: | |
232 gtkShow(evLoadSubtitle, NULL); | |
233 break; | |
234 | |
235 case evDropSubtitle: | |
236 nfree(guiInfo.SubtitleFilename); | |
237 mplayerLoadSubtitle(NULL); | |
238 break; | |
239 | |
240 case evLoadAudioFile: | |
241 gtkShow(evLoadAudioFile, NULL); | |
242 break; | |
243 | |
244 case evPrev: | |
245 uiPrev(); | |
246 break; | |
247 | |
248 case evNext: | |
249 uiNext(); | |
250 break; | |
251 | |
252 case evPlaylist: | |
253 gtkShow(evPlaylist, NULL); | |
254 break; | |
255 | |
256 case evSkinBrowser: | |
257 gtkShow(evSkinBrowser, skinName); | |
258 break; | |
259 | |
260 case evAbout: | |
261 gtkShow(evAbout, NULL); | |
262 break; | |
263 | |
264 case evPreferences: | |
265 gtkShow(evPreferences, NULL); | |
266 break; | |
267 | |
268 case evEqualizer: | |
269 gtkShow(evEqualizer, NULL); | |
270 break; | |
271 | |
272 case evForward10min: | |
273 uiRelSeek(600); | |
274 break; | |
275 | |
276 case evBackward10min: | |
277 uiRelSeek(-600); | |
278 break; | |
279 | |
280 case evForward1min: | |
281 uiRelSeek(60); | |
282 break; | |
283 | |
284 case evBackward1min: | |
285 uiRelSeek(-60); | |
286 break; | |
287 | |
288 case evForward10sec: | |
289 uiRelSeek(10); | |
290 break; | |
291 | |
292 case evBackward10sec: | |
293 uiRelSeek(-10); | |
294 break; | |
295 | |
296 case evSetMoviePosition: | |
297 uiAbsSeek(param); | |
298 break; | |
299 | |
300 case evIncVolume: | |
301 vo_x11_putkey(wsGrayMul); | |
302 break; | |
303 | |
304 case evDecVolume: | |
305 vo_x11_putkey(wsGrayDiv); | |
306 break; | |
307 | |
308 case evMute: | |
309 mixer_mute(mixer); | |
310 break; | |
311 | |
312 case evSetVolume: | |
313 guiInfo.Volume = param; | |
314 { | |
315 float l = guiInfo.Volume * ((100.0 - guiInfo.Balance) / 50.0); | |
316 float r = guiInfo.Volume * ((guiInfo.Balance) / 50.0); | |
317 mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); | |
318 } | |
319 | |
320 if (osd_level) { | |
321 osd_visible = (GetTimerMS() + 1000) | 1; | |
322 vo_osd_progbar_type = OSD_VOLUME; | |
323 vo_osd_progbar_value = ((guiInfo.Volume) * 256.0) / 100.0; | |
324 vo_osd_changed(OSDTYPE_PROGBAR); | |
325 } | |
326 | |
327 break; | |
328 | |
329 case evSetBalance: | |
330 guiInfo.Balance = param; | |
331 mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 | |
332 osd = osd_level; | |
333 osd_level = 0; | |
35773 | 334 uiEvent(evSetVolume, guiInfo.Volume); |
35771 | 335 osd_level = osd; |
336 | |
337 if (osd_level) { | |
338 osd_visible = (GetTimerMS() + 1000) | 1; | |
339 vo_osd_progbar_type = OSD_BALANCE; | |
340 vo_osd_progbar_value = ((guiInfo.Balance) * 256.0) / 100.0; | |
341 vo_osd_changed(OSDTYPE_PROGBAR); | |
342 } | |
343 | |
344 break; | |
345 | |
346 case evMenu: | |
347 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse | |
348 * { pointer and cursor keys work | |
349 * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
350 * uiMenuShow( 0,0 ); they do with normal menus. | |
351 * } | |
352 * else*/gtkShow(ivShowPopUpMenu, NULL); | |
353 break; | |
354 | |
355 case evIconify: | |
356 | |
357 switch (iparam) { | |
358 case 0: | |
359 wsWindowIconify(&guiApp.mainWindow); | |
360 break; | |
361 | |
362 case 1: | |
363 wsWindowIconify(&guiApp.videoWindow); | |
364 break; | |
365 } | |
366 | |
367 break; | |
368 | |
369 case evHalfSize: | |
370 | |
371 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
372 if (guiApp.videoWindow.isFullScreen) { | |
373 uiFullScreen(); | |
374 } | |
375 | |
376 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); | |
377 btnSet(evFullScreen, btnReleased); | |
378 } | |
379 | |
380 break; | |
381 | |
382 case evDoubleSize: | |
383 | |
384 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
385 if (guiApp.videoWindow.isFullScreen) { | |
386 uiFullScreen(); | |
387 } | |
388 | |
389 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); | |
390 wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
391 btnSet(evFullScreen, btnReleased); | |
392 } | |
393 | |
394 break; | |
395 | |
396 case evNormalSize: | |
397 | |
398 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
399 if (guiApp.videoWindow.isFullScreen) { | |
400 uiFullScreen(); | |
401 } | |
402 | |
403 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); | |
404 btnSet(evFullScreen, btnReleased); | |
405 break; | |
406 } else if (!guiApp.videoWindow.isFullScreen) | |
407 break; | |
408 | |
409 case evFullScreen: | |
410 | |
411 if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { | |
412 uiFullScreen(); | |
413 | |
414 if (!guiApp.videoWindow.isFullScreen) | |
415 wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); | |
416 } | |
417 | |
418 if (guiApp.videoWindow.isFullScreen) | |
419 btnSet(evFullScreen, btnPressed); | |
420 else | |
421 btnSet(evFullScreen, btnReleased); | |
422 | |
423 break; | |
424 | |
425 case evSetAspect: | |
426 | |
427 switch (iparam) { | |
428 case 2: | |
429 movie_aspect = 16.0f / 9.0f; | |
430 break; | |
431 | |
432 case 3: | |
433 movie_aspect = 4.0f / 3.0f; | |
434 break; | |
435 | |
436 case 4: | |
437 movie_aspect = 2.35; | |
438 break; | |
439 | |
440 case 1: | |
441 default: | |
442 movie_aspect = -1; | |
443 } | |
444 | |
445 if (guiInfo.StreamType == STREAMTYPE_VCD) | |
35773 | 446 uiEvent(evPlayVCD, 0); |
35771 | 447 else if (guiInfo.StreamType == STREAMTYPE_DVD) |
35773 | 448 uiEvent(ivPlayDVD, 0); |
35771 | 449 else |
450 guiInfo.NewPlay = GUI_FILE_NEW; | |
451 | |
452 break; | |
453 | |
454 /* timer events */ | |
455 case ivRedraw: | |
456 { | |
35775 | 457 unsigned int now = GetTimerMS(); |
35771 | 458 |
459 if ((now > last_redraw_time) && | |
460 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
461 !uiPlaybarFade && (iparam == 0)) | |
462 break; | |
463 | |
464 last_redraw_time = now; | |
465 } | |
466 uiMainRender = True; | |
467 wsWindowRedraw(&guiApp.mainWindow); | |
468 wsWindowRedraw(&guiApp.playbarWindow); | |
469 break; | |
470 | |
471 /* system events */ | |
472 case evNone: | |
35773 | 473 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); |
35771 | 474 break; |
475 | |
476 default: | |
35773 | 477 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); |
35771 | 478 break; |
479 } | |
480 } | |
23077 | 481 |
35437 | 482 /** |
483 * @brief Switch video window fullscreen mode. | |
484 * | |
485 * Switch normal video to fullscreen and fullscreen video to normal. | |
486 */ | |
33555 | 487 void uiFullScreen(void) |
23077 | 488 { |
33960 | 489 if (!guiInfo.VideoWindow) |
32881 | 490 return; |
491 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
492 wsWindowFullscreen(&guiApp.videoWindow); |
23077 | 493 |
34697 | 494 vo_fs = guiApp.videoWindow.isFullScreen; |
23077 | 495 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
496 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 497 |
33555 | 498 if (guiApp.menuIsPresent) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
499 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
23077 | 500 } |
501 | |
35437 | 502 /** |
503 * @brief Switch to play mode. | |
504 */ | |
33555 | 505 void uiPlay(void) |
23077 | 506 { |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
507 if (guiInfo.Playing == GUI_PLAY) |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
508 return; |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
509 |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
510 if (guiInfo.StreamType != STREAMTYPE_CDDA && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
511 guiInfo.StreamType != STREAMTYPE_VCD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
512 guiInfo.StreamType != STREAMTYPE_DVD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
513 (!guiInfo.Filename || (guiInfo.Filename[0] == 0))) |
32881 | 514 return; |
23077 | 515 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
516 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 517 uiPause(); |
32881 | 518 return; |
519 } | |
520 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
521 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
23077 | 522 } |
523 | |
35437 | 524 /** |
525 * @brief Switch to pause mode. | |
526 */ | |
33555 | 527 void uiPause(void) |
23077 | 528 { |
33555 | 529 if (!guiInfo.Playing) |
32881 | 530 return; |
531 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
532 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 533 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
35433 | 534 |
35432 | 535 if (cmd) { |
35433 | 536 cmd->id = MP_CMD_PAUSE; |
537 cmd->name = strdup("pause"); | |
538 mp_input_queue_cmd(cmd); | |
35432 | 539 } |
32881 | 540 } else |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
541 guiInfo.Playing = GUI_PLAY; |
23077 | 542 } |
543 | |
35437 | 544 /** |
545 * @brief Adjust GUI items to reflect current state (i.e. current playing mode). | |
546 */ | |
33555 | 547 void uiState(void) |
32881 | 548 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
549 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 550 btnSet(evPlaySwitchToPause, btnReleased); |
551 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 552 } else { |
35434 | 553 btnSet(evPauseSwitchToPlay, btnReleased); |
33978 | 554 btnSet(evPlaySwitchToPause, btnDisabled); |
32881 | 555 } |
23077 | 556 } |
557 | |
35437 | 558 /** |
559 * @brief Seek new playback position. | |
560 * | |
35438 | 561 * The new position is a relative one. |
35437 | 562 * |
563 * @param sec seconds to seek (either forward (> 0) or backward (< 0)) | |
564 */ | |
33555 | 565 void uiRelSeek(float sec) |
32881 | 566 { |
32971 | 567 rel_seek_secs = sec; |
32881 | 568 abs_seek_pos = 0; |
569 } | |
570 | |
35437 | 571 /** |
572 * @brief Seek new playback position. | |
573 * | |
35438 | 574 * The new position is an absolute one. |
35437 | 575 * |
576 * @param percent percentage of playback time to position to | |
577 */ | |
33555 | 578 void uiAbsSeek(float percent) |
32881 | 579 { |
32971 | 580 rel_seek_secs = percent / 100.0; |
35431 | 581 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; |
23077 | 582 } |
583 | |
35437 | 584 /** |
585 * @brief Change to a different skin. | |
586 * | |
587 * @param name name of the skin to change to | |
588 */ | |
33555 | 589 void uiChangeSkin(char *name) |
23077 | 590 { |
35799 | 591 int was_menu, was_playbar; |
32881 | 592 |
35799 | 593 was_menu = guiApp.menuIsPresent; |
594 was_playbar = guiApp.playbarIsPresent; | |
32881 | 595 |
35493 | 596 mainVisible = False; |
32881 | 597 |
32893 | 598 if (skinRead(name) != 0) { |
599 if (skinRead(skinName) != 0) { | |
35801
98693cc5df48
Exit GUI if we can't return to the skin we started with.
ib
parents:
35800
diff
changeset
|
600 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName); |
98693cc5df48
Exit GUI if we can't return to the skin we started with.
ib
parents:
35800
diff
changeset
|
601 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32893 | 602 } |
32881 | 603 } |
604 | |
35800 | 605 /* reload main window (must be first!) */ |
23077 | 606 |
35800 | 607 uiMainDone(); |
608 uiMainInit(); | |
32881 | 609 |
35800 | 610 wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); |
611 mainVisible = True; | |
23077 | 612 |
35805 | 613 /* adjust video window */ |
23077 | 614 |
35805 | 615 if (guiApp.video.Bitmap.Image) { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
616 wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); |
35805 | 617 wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); |
618 } | |
32881 | 619 |
35805 | 620 if (!guiInfo.Playing) { |
621 if (!guiApp.videoWindow.isFullScreen) { | |
35806 | 622 wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); |
623 wsWindowMove(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
624 } | |
32881 | 625 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
626 wsWindowRedraw(&guiApp.videoWindow); |
35805 | 627 } |
32881 | 628 |
34684 | 629 /* reload playbar */ |
32881 | 630 |
35799 | 631 if (was_playbar) |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35795
diff
changeset
|
632 uiPlaybarDone(); |
32881 | 633 |
33555 | 634 uiPlaybarInit(); |
23077 | 635 |
35800 | 636 /* reload menu window */ |
637 | |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
638 if (was_menu) |
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
639 uiMenuDone(); |
32881 | 640 |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
641 uiMenuInit(); |
35800 | 642 |
643 /* */ | |
32881 | 644 |
33555 | 645 btnModify(evSetVolume, guiInfo.Volume); |
646 btnModify(evSetBalance, guiInfo.Balance); | |
647 btnModify(evSetMoviePosition, guiInfo.Position); | |
34697 | 648 btnSet(evFullScreen, (guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 649 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
650 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
651 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 652 } |
653 | |
35437 | 654 /** |
35452 | 655 * @brief Set the file to be played. |
35437 | 656 * |
657 * @param dir directory (optional, else NULL) | |
658 * @param name filename | |
659 * @param type stream type of the file | |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
660 * |
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
661 * @note All #guiInfo members associated with the file will be cleared. |
35437 | 662 */ |
35452 | 663 void uiSetFile(char *dir, char *name, int type) |
32881 | 664 { |
665 if (!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
666 setdup(&guiInfo.Filename, name); |
32881 | 667 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
668 setddup(&guiInfo.Filename, dir, name); |
23077 | 669 |
34064 | 670 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
671 |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
672 if (type != SAME_STREAMTYPE) { |
34400 | 673 guiInfo.StreamType = type; |
35568 | 674 uiUnsetMedia(False); |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
675 } |
23077 | 676 } |
677 | |
35437 | 678 /** |
35453 | 679 * @brief Unset the file being played. |
680 */ | |
681 void uiUnsetFile(void) | |
682 { | |
683 uiSetFile(NULL, NULL, STREAMTYPE_DUMMY); | |
684 } | |
685 | |
686 /** | |
35562 | 687 * @brief Unset media information. |
35568 | 688 * |
689 * @param totals whether to unset number of chapters and angles (#True) or | |
690 * just track, chapter and angle (#False) as well | |
35562 | 691 */ |
35568 | 692 void uiUnsetMedia(int totals) |
35562 | 693 { |
694 guiInfo.VideoWidth = 0; | |
695 guiInfo.VideoHeight = 0; | |
696 guiInfo.AudioChannels = 0; | |
697 guiInfo.RunningTime = 0; | |
35568 | 698 |
699 if (totals) { | |
700 guiInfo.Chapters = 0; | |
701 guiInfo.Angles = 0; | |
702 } else { | |
35569 | 703 guiInfo.Track = 0; |
704 guiInfo.Chapter = 0; | |
705 guiInfo.Angle = 0; | |
35568 | 706 } |
35562 | 707 |
708 nfree(guiInfo.CodecName); | |
709 nfree(guiInfo.AudioFilename); | |
710 nfree(guiInfo.SubtitleFilename); | |
711 } | |
712 | |
713 /** | |
35437 | 714 * @brief Set file to be played to current playlist entry. |
715 */ | |
33555 | 716 void uiCurr(void) |
23077 | 717 { |
32881 | 718 plItem *curr; |
23077 | 719 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
720 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 721 return; |
23077 | 722 |
33555 | 723 switch (guiInfo.StreamType) { |
34387 | 724 case STREAMTYPE_CDDA: |
34077 | 725 case STREAMTYPE_VCD: |
726 case STREAMTYPE_DVD: | |
35433 | 727 |
32881 | 728 break; |
729 | |
730 default: | |
731 | |
34663 | 732 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
32881 | 733 |
734 if (curr) { | |
35452 | 735 uiSetFile(curr->path, curr->name, STREAMTYPE_FILE); |
35493 | 736 guiInfo.PlaylistNext = False; |
35485 | 737 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, curr); |
32881 | 738 break; |
739 } | |
740 | |
741 return; | |
742 } | |
743 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
744 if (guiInfo.Playing == GUI_PLAY) |
35773 | 745 uiEvent(evPlay, 0); |
23077 | 746 } |
747 | |
35437 | 748 /** |
749 * @brief Switch to previous playback track. | |
750 */ | |
33555 | 751 void uiPrev(void) |
23077 | 752 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
753 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
754 plItem *prev = NULL; |
32881 | 755 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
756 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 757 return; |
758 | |
33555 | 759 switch (guiInfo.StreamType) { |
34387 | 760 case STREAMTYPE_CDDA: |
35426 | 761 |
34387 | 762 if (--guiInfo.Track == 0) { |
763 guiInfo.Track = 1; | |
35493 | 764 stop = True; |
34387 | 765 } |
35426 | 766 |
34387 | 767 break; |
768 | |
34077 | 769 case STREAMTYPE_VCD: |
35426 | 770 |
34077 | 771 if (--guiInfo.Track == 1) { |
772 guiInfo.Track = 2; | |
35493 | 773 stop = True; |
34077 | 774 } |
35426 | 775 |
34077 | 776 break; |
777 | |
32881 | 778 case STREAMTYPE_DVD: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
779 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
780 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
781 guiInfo.Chapter = 1; |
32881 | 782 |
35428 | 783 if (--guiInfo.Track == 0) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
784 guiInfo.Track = 1; |
35493 | 785 stop = True; |
32881 | 786 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
787 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
788 unset = False; |
32881 | 789 |
790 break; | |
791 | |
792 default: | |
793 | |
34663 | 794 prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); |
32881 | 795 |
796 if (prev) { | |
35452 | 797 uiSetFile(prev->path, prev->name, STREAMTYPE_FILE); |
35500 | 798 guiInfo.PlaylistNext = !guiInfo.Playing; |
35458 | 799 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, prev); |
32881 | 800 break; |
801 } | |
802 | |
803 return; | |
804 } | |
805 | |
806 if (stop) | |
35773 | 807 uiEvent(evStop, 0); |
32881 | 808 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
809 if (guiInfo.Playing == GUI_PLAY) |
35773 | 810 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
811 else if (!stop && !prev && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
812 uiUnsetMedia(True); |
23077 | 813 } |
814 | |
35437 | 815 /** |
816 * @brief Switch to next playback track. | |
817 */ | |
33555 | 818 void uiNext(void) |
23077 | 819 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
820 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
821 plItem *next = NULL; |
23077 | 822 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
823 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 824 return; |
825 | |
33555 | 826 switch (guiInfo.StreamType) { |
34387 | 827 case STREAMTYPE_CDDA: |
35425 | 828 case STREAMTYPE_VCD: |
34387 | 829 |
830 if (++guiInfo.Track > guiInfo.Tracks) { | |
831 guiInfo.Track = guiInfo.Tracks; | |
35493 | 832 stop = True; |
34387 | 833 } |
834 | |
835 break; | |
836 | |
32881 | 837 case STREAMTYPE_DVD: |
838 | |
35570 | 839 if (guiInfo.Chapter++ >= guiInfo.Chapters) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
840 guiInfo.Chapter = 1; |
32881 | 841 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
842 if (++guiInfo.Track > guiInfo.Tracks) { |
35561 | 843 guiInfo.Track = guiInfo.Tracks; |
35560
1a2200a93ea8
Make DVD stop if manually advancing beyond last chapter of last track.
ib
parents:
35528
diff
changeset
|
844 guiInfo.Chapter = guiInfo.Chapters; |
35493 | 845 stop = True; |
32881 | 846 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
847 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
848 unset = False; |
32881 | 849 |
850 break; | |
851 | |
852 default: | |
853 | |
34663 | 854 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
32881 | 855 |
856 if (next) { | |
35452 | 857 uiSetFile(next->path, next->name, STREAMTYPE_FILE); |
35500 | 858 guiInfo.PlaylistNext = !guiInfo.Playing; |
35458 | 859 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, next); |
32881 | 860 break; |
861 } | |
862 | |
863 return; | |
864 } | |
865 | |
866 if (stop) | |
35773 | 867 uiEvent(evStop, 0); |
32881 | 868 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
869 if (guiInfo.Playing == GUI_PLAY) |
35773 | 870 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
871 else if (!stop && !next && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
872 uiUnsetMedia(True); |
23077 | 873 } |