Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 33714:5fda3578d1c5
Do not assign anything when a stream control returns an error.
Avoids issues with some places that don't check the return
value of stream_control.
author | reimar |
---|---|
date | Sun, 03 Jul 2011 09:45:29 +0000 |
parents | 24d919fb6778 |
children | c919fb3d2531 |
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 | |
33556 | 22 #include "actions.h" |
32881 | 23 #include "gmplayer.h" |
24 #include "gui/app.h" | |
25 #include "gui/interface.h" | |
26 #include "gui/skin/font.h" | |
27 #include "gui/skin/skin.h" | |
28 #include "gui/wm/wsxdnd.h" | |
29 #include "widgets.h" | |
23077 | 30 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
32 #include "help_mp.h" |
32881 | 33 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
34 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "libvo/video_out.h" |
32881 | 36 #include "mp_core.h" |
23077 | 37 #include "stream/stream.h" |
38 | |
33555 | 39 int uiGotoTheNext = 1; |
23077 | 40 |
33555 | 41 void uiFullScreen(void) |
23077 | 42 { |
33655 | 43 if (!guiInfo.MovieWindow && guiInfo.Playing) |
32881 | 44 return; |
45 | |
33555 | 46 if (guiInfo.Playing && guiApp.subWindow.isFullScreen) { |
47 guiApp.subWindow.OldWidth = guiInfo.MovieWidth; | |
48 guiApp.subWindow.OldHeight = guiInfo.MovieHeight; | |
32881 | 49 |
33555 | 50 switch (guiApp.sub.x) { |
32881 | 51 case -1: |
33555 | 52 guiApp.subWindow.OldX = wsMaxX / 2 - guiApp.subWindow.OldWidth / 2 + wsOrgX; |
32881 | 53 break; |
54 | |
55 case -2: | |
33555 | 56 guiApp.subWindow.OldX = wsMaxX - guiApp.subWindow.OldWidth + wsOrgX; |
32881 | 57 break; |
58 | |
59 default: | |
33555 | 60 guiApp.subWindow.OldX = guiApp.sub.x; |
32881 | 61 break; |
62 } | |
23077 | 63 |
33555 | 64 switch (guiApp.sub.y) { |
32881 | 65 case -1: |
33555 | 66 guiApp.subWindow.OldY = wsMaxY / 2 - guiApp.subWindow.OldHeight / 2 + wsOrgY; |
32881 | 67 break; |
68 | |
69 case -2: | |
33555 | 70 guiApp.subWindow.OldY = wsMaxY - guiApp.subWindow.OldHeight + wsOrgY; |
32881 | 71 break; |
23077 | 72 |
32881 | 73 default: |
33555 | 74 guiApp.subWindow.OldY = guiApp.sub.y; |
32881 | 75 break; |
76 } | |
77 } | |
78 | |
33555 | 79 if (guiInfo.Playing || gtkShowVideoWindow) |
80 wsFullScreen(&guiApp.subWindow); | |
32881 | 81 |
33555 | 82 fullscreen = vo_fs = guiApp.subWindow.isFullScreen; |
83 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 84 |
33555 | 85 if (guiApp.menuIsPresent) |
86 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 87 |
33555 | 88 if (guiInfo.Playing) |
89 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
32881 | 90 else |
33555 | 91 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); |
23077 | 92 } |
93 | |
33555 | 94 void uiPlay(void) |
23077 | 95 { |
33555 | 96 if (!guiInfo.Filename || |
97 (guiInfo.Filename[0] == 0) || | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
98 (guiInfo.Playing == GUI_PLAY)) |
32881 | 99 return; |
23077 | 100 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
101 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 102 uiPause(); |
32881 | 103 return; |
104 } | |
105 | |
33614 | 106 guiGetEvent(guiSetState, (void *)GUI_PLAY); |
33555 | 107 uiSubRender = 0; |
108 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
109 wsClearWindow(guiApp.subWindow); | |
23077 | 110 } |
111 | |
33555 | 112 void uiPause(void) |
23077 | 113 { |
33555 | 114 if (!guiInfo.Playing) |
32881 | 115 return; |
116 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
117 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 118 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
119 cmd->id = MP_CMD_PAUSE; | |
120 cmd->name = strdup("pause"); | |
121 mp_input_queue_cmd(cmd); | |
122 } else | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
123 guiInfo.Playing = GUI_PLAY; |
23077 | 124 } |
125 | |
33555 | 126 void uiState(void) |
32881 | 127 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
128 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
32881 | 129 btnModify(evPlaySwitchToPause, btnReleased); |
130 btnModify(evPauseSwitchToPlay, btnDisabled); | |
131 } else { | |
132 btnModify(evPlaySwitchToPause, btnDisabled); | |
133 btnModify(evPauseSwitchToPlay, btnReleased); | |
134 } | |
23077 | 135 } |
136 | |
33555 | 137 void uiRelSeek(float sec) |
32881 | 138 { |
32971 | 139 rel_seek_secs = sec; |
32881 | 140 abs_seek_pos = 0; |
141 } | |
142 | |
33555 | 143 void uiAbsSeek(float percent) |
32881 | 144 { |
33555 | 145 if (guiInfo.StreamType == STREAMTYPE_STREAM) |
32881 | 146 return; |
147 | |
32971 | 148 rel_seek_secs = percent / 100.0; |
32881 | 149 abs_seek_pos = 3; |
23077 | 150 } |
151 | |
33555 | 152 void uiChangeSkin(char *name) |
23077 | 153 { |
32893 | 154 int prev, bprev; |
32881 | 155 |
33555 | 156 prev = guiApp.menuIsPresent; |
157 bprev = guiApp.playbarIsPresent; | |
32881 | 158 |
159 mainVisible = 0; | |
160 | |
32893 | 161 if (skinRead(name) != 0) { |
162 if (skinRead(skinName) != 0) { | |
32894 | 163 mainVisible = 1; |
164 return; | |
32893 | 165 } |
32881 | 166 } |
167 | |
168 // reload menu window | |
23077 | 169 |
33555 | 170 if (prev && guiApp.menuIsPresent) { |
171 free(menuDrawBuffer); | |
172 menuDrawBuffer = calloc(1, guiApp.menu.Bitmap.ImageSize); | |
32881 | 173 |
33555 | 174 if (!menuDrawBuffer) { |
33530 | 175 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
176 guiExit(EXIT_ERROR); | |
32881 | 177 } |
23077 | 178 |
33555 | 179 wsResizeWindow(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); |
180 wsResizeImage(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); | |
181 wsSetShape(&guiApp.menuWindow, guiApp.menu.Mask.Image); | |
182 wsVisibleWindow(&guiApp.menuWindow, wsHideWindow); | |
32881 | 183 } else |
33555 | 184 uiMenuInit(); |
32881 | 185 |
186 // reload sub window | |
23077 | 187 |
33555 | 188 if (guiApp.sub.Bitmap.Image) |
189 wsResizeImage(&guiApp.subWindow, guiApp.sub.Bitmap.Width, guiApp.sub.Bitmap.Height); | |
32881 | 190 |
33555 | 191 if (!guiApp.subWindow.isFullScreen && !guiInfo.Playing) { |
192 wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); | |
193 wsMoveWindow(&guiApp.subWindow, True, guiApp.sub.x, guiApp.sub.y); | |
32881 | 194 } |
195 | |
33555 | 196 if (guiApp.sub.Bitmap.Image) |
197 wsConvert(&guiApp.subWindow, guiApp.sub.Bitmap.Image); | |
23077 | 198 |
33555 | 199 if (!guiInfo.Playing) { |
200 uiSubRender = 1; | |
201 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); | |
202 wsClearWindow(guiApp.subWindow); | |
203 wsPostRedisplay(&guiApp.subWindow); | |
32881 | 204 } |
205 | |
33555 | 206 // reload playbar |
32881 | 207 |
208 if (bprev) | |
33555 | 209 wsDestroyWindow(&guiApp.playbarWindow); |
32881 | 210 |
33555 | 211 uiPlaybarInit(); |
23077 | 212 |
32881 | 213 // reload main window |
214 | |
33555 | 215 free(mainDrawBuffer); |
216 mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize); | |
23077 | 217 |
33555 | 218 if (!mainDrawBuffer) { |
33530 | 219 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
220 guiExit(EXIT_ERROR); | |
32881 | 221 } |
23077 | 222 |
33555 | 223 wsDestroyWindow(&guiApp.mainWindow); |
32881 | 224 |
33555 | 225 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); |
226 wsCreateImage(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height); | |
227 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
228 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); | |
23077 | 229 |
33555 | 230 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
231 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
232 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
233 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
32881 | 234 |
33555 | 235 wsXDNDMakeAwareness(&guiApp.mainWindow); |
23077 | 236 |
33555 | 237 if (!guiApp.mainDecoration) |
238 wsWindowDecoration(&guiApp.mainWindow, 0); | |
32881 | 239 |
33555 | 240 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
32881 | 241 mainVisible = 1; |
242 | |
33555 | 243 btnModify(evSetVolume, guiInfo.Volume); |
244 btnModify(evSetBalance, guiInfo.Balance); | |
245 btnModify(evSetMoviePosition, guiInfo.Position); | |
246 btnModify(evFullScreen, !guiApp.subWindow.isFullScreen); | |
23077 | 247 |
33555 | 248 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
249 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 250 } |
251 | |
33555 | 252 void uiSetFileName(char *dir, char *name, int type) |
32881 | 253 { |
254 if (!name) | |
255 return; | |
23077 | 256 |
32881 | 257 if (!dir) |
33555 | 258 guiSetFilename(guiInfo.Filename, name) |
32881 | 259 else |
33555 | 260 guiSetDF(guiInfo.Filename, dir, name) |
23077 | 261 |
33555 | 262 guiInfo.StreamType = type; |
263 gfree((void **)&guiInfo.AudioFile); | |
264 gfree((void **)&guiInfo.Subtitlename); | |
23077 | 265 } |
266 | |
33555 | 267 void uiCurr(void) |
23077 | 268 { |
32881 | 269 plItem *curr; |
270 int stop = 0; | |
23077 | 271 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
272 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 273 return; |
23077 | 274 |
33555 | 275 switch (guiInfo.StreamType) { |
32881 | 276 #ifdef CONFIG_DVDREAD |
277 case STREAMTYPE_DVD: | |
278 break; | |
32953 | 279 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
280 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
281 #ifdef CONFIG_VCD |
32881 | 282 case STREAMTYPE_VCD: |
283 break; | |
32953 | 284 #endif |
32881 | 285 |
286 default: | |
287 | |
288 curr = gtkSet(gtkGetCurrPlItem, 0, NULL); | |
289 | |
290 if (curr) { | |
33555 | 291 uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE); |
292 uiGotoTheNext = 0; | |
32881 | 293 break; |
294 } | |
295 | |
296 return; | |
297 } | |
298 | |
299 if (stop) | |
33555 | 300 uiEventHandling(evStop, 0); |
32881 | 301 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
302 if (guiInfo.Playing == GUI_PLAY) |
33555 | 303 uiEventHandling(evPlay, 0); |
23077 | 304 } |
305 | |
33555 | 306 void uiPrev(void) |
23077 | 307 { |
32881 | 308 plItem *prev; |
309 int stop = 0; | |
310 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
311 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 312 return; |
313 | |
33555 | 314 switch (guiInfo.StreamType) { |
32881 | 315 #ifdef CONFIG_DVDREAD |
316 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
317 |
33555 | 318 if (--guiInfo.DVD.current_chapter == 0) { |
319 guiInfo.DVD.current_chapter = 1; | |
32881 | 320 |
33555 | 321 if (--guiInfo.DVD.current_title <= 0) { |
322 guiInfo.DVD.current_title = 1; | |
32881 | 323 stop = 1; |
324 } | |
325 } | |
326 | |
33555 | 327 guiInfo.Track = guiInfo.DVD.current_title; |
32881 | 328 break; |
32953 | 329 #endif |
32881 | 330 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
331 #ifdef CONFIG_VCD |
32881 | 332 case STREAMTYPE_VCD: |
33555 | 333 if (--guiInfo.Track == 0) { |
334 guiInfo.Track = 1; | |
32881 | 335 stop = 1; |
336 } | |
337 break; | |
32953 | 338 #endif |
32881 | 339 |
340 default: | |
341 | |
342 prev = gtkSet(gtkGetPrevPlItem, 0, NULL); | |
343 | |
344 if (prev) { | |
33555 | 345 uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE); |
346 uiGotoTheNext = 0; | |
32881 | 347 break; |
348 } | |
349 | |
350 return; | |
351 } | |
352 | |
353 if (stop) | |
33555 | 354 uiEventHandling(evStop, 0); |
32881 | 355 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
356 if (guiInfo.Playing == GUI_PLAY) |
33555 | 357 uiEventHandling(evPlay, 0); |
23077 | 358 } |
359 | |
33555 | 360 void uiNext(void) |
23077 | 361 { |
32881 | 362 int stop = 0; |
363 plItem *next; | |
23077 | 364 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
365 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 366 return; |
367 | |
33555 | 368 switch (guiInfo.StreamType) { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
369 #ifdef CONFIG_DVDREAD |
32881 | 370 case STREAMTYPE_DVD: |
371 | |
33555 | 372 if (guiInfo.DVD.current_chapter++ == guiInfo.DVD.chapters) { |
373 guiInfo.DVD.current_chapter = 1; | |
32881 | 374 |
33555 | 375 if (++guiInfo.DVD.current_title > guiInfo.DVD.titles) { |
376 guiInfo.DVD.current_title = guiInfo.DVD.titles; | |
32881 | 377 stop = 1; |
378 } | |
379 } | |
380 | |
33555 | 381 guiInfo.Track = guiInfo.DVD.current_title; |
32881 | 382 break; |
32953 | 383 #endif |
32881 | 384 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
385 #ifdef CONFIG_VCD |
32881 | 386 case STREAMTYPE_VCD: |
33003 | 387 |
33555 | 388 if (++guiInfo.Track >= guiInfo.VCDTracks) { |
389 guiInfo.Track = guiInfo.VCDTracks; | |
33003 | 390 |
33555 | 391 if (guiInfo.VCDTracks > 1) |
392 guiInfo.Track--; | |
33003 | 393 |
32881 | 394 stop = 1; |
395 } | |
33003 | 396 |
32881 | 397 break; |
32953 | 398 #endif |
32881 | 399 |
400 default: | |
401 | |
402 next = gtkSet(gtkGetNextPlItem, 0, NULL); | |
403 | |
404 if (next) { | |
33555 | 405 uiSetFileName(next->path, next->name, STREAMTYPE_FILE); |
406 uiGotoTheNext = 0; | |
32881 | 407 break; |
408 } | |
409 | |
410 return; | |
411 } | |
412 | |
413 if (stop) | |
33555 | 414 uiEventHandling(evStop, 0); |
32881 | 415 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
416 if (guiInfo.Playing == GUI_PLAY) |
33555 | 417 uiEventHandling(evPlay, 0); |
23077 | 418 } |