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