Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 34399:f2c03009068d
Don't explicitly set stream type if the type doesn't change.
Use a self-explanatory symbolic constant which makes the code
more easily understandable.
author | ib |
---|---|
date | Mon, 02 Jan 2012 15:16:55 +0000 |
parents | 0ba85cad4c7e |
children | 19b68f388735 |
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" | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
28 #include "gui/util/list.h" |
33739 | 29 #include "gui/util/mem.h" |
33737 | 30 #include "gui/util/string.h" |
32881 | 31 #include "gui/wm/wsxdnd.h" |
32 #include "widgets.h" | |
23077 | 33 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
34 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "help_mp.h" |
32881 | 36 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
37 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/video_out.h" |
32881 | 39 #include "mp_core.h" |
23077 | 40 |
33555 | 41 int uiGotoTheNext = 1; |
23077 | 42 |
33555 | 43 void uiFullScreen(void) |
23077 | 44 { |
33960 | 45 if (!guiInfo.VideoWindow) |
32881 | 46 return; |
47 | |
33960 | 48 wsFullScreen(&guiApp.subWindow); |
23077 | 49 |
33960 | 50 vo_fs = guiApp.subWindow.isFullScreen; |
23077 | 51 |
33555 | 52 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
32881 | 53 |
33555 | 54 if (guiApp.menuIsPresent) |
55 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 56 |
33555 | 57 if (guiInfo.Playing) |
58 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
32881 | 59 else |
33555 | 60 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); |
23077 | 61 } |
62 | |
33555 | 63 void uiPlay(void) |
23077 | 64 { |
33555 | 65 if (!guiInfo.Filename || |
66 (guiInfo.Filename[0] == 0) || | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
67 (guiInfo.Playing == GUI_PLAY)) |
32881 | 68 return; |
23077 | 69 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
70 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 71 uiPause(); |
32881 | 72 return; |
73 } | |
74 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
75 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
33555 | 76 uiSubRender = 0; |
77 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
78 wsClearWindow(guiApp.subWindow); | |
23077 | 79 } |
80 | |
33555 | 81 void uiPause(void) |
23077 | 82 { |
33555 | 83 if (!guiInfo.Playing) |
32881 | 84 return; |
85 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
86 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 87 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
88 cmd->id = MP_CMD_PAUSE; | |
89 cmd->name = strdup("pause"); | |
90 mp_input_queue_cmd(cmd); | |
91 } else | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
92 guiInfo.Playing = GUI_PLAY; |
23077 | 93 } |
94 | |
33555 | 95 void uiState(void) |
32881 | 96 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
97 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 98 btnSet(evPlaySwitchToPause, btnReleased); |
99 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 100 } else { |
33978 | 101 btnSet(evPlaySwitchToPause, btnDisabled); |
102 btnSet(evPauseSwitchToPlay, btnReleased); | |
32881 | 103 } |
23077 | 104 } |
105 | |
33555 | 106 void uiRelSeek(float sec) |
32881 | 107 { |
32971 | 108 rel_seek_secs = sec; |
32881 | 109 abs_seek_pos = 0; |
110 } | |
111 | |
33555 | 112 void uiAbsSeek(float percent) |
32881 | 113 { |
32971 | 114 rel_seek_secs = percent / 100.0; |
32881 | 115 abs_seek_pos = 3; |
23077 | 116 } |
117 | |
33555 | 118 void uiChangeSkin(char *name) |
23077 | 119 { |
32893 | 120 int prev, bprev; |
32881 | 121 |
33555 | 122 prev = guiApp.menuIsPresent; |
123 bprev = guiApp.playbarIsPresent; | |
32881 | 124 |
125 mainVisible = 0; | |
126 | |
32893 | 127 if (skinRead(name) != 0) { |
128 if (skinRead(skinName) != 0) { | |
32894 | 129 mainVisible = 1; |
130 return; | |
32893 | 131 } |
32881 | 132 } |
133 | |
134 // reload menu window | |
23077 | 135 |
33555 | 136 if (prev && guiApp.menuIsPresent) { |
137 free(menuDrawBuffer); | |
138 menuDrawBuffer = calloc(1, guiApp.menu.Bitmap.ImageSize); | |
32881 | 139 |
33555 | 140 if (!menuDrawBuffer) { |
33530 | 141 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 142 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 143 } |
23077 | 144 |
33555 | 145 wsResizeWindow(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); |
146 wsResizeImage(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); | |
147 wsSetShape(&guiApp.menuWindow, guiApp.menu.Mask.Image); | |
148 wsVisibleWindow(&guiApp.menuWindow, wsHideWindow); | |
32881 | 149 } else |
33555 | 150 uiMenuInit(); |
32881 | 151 |
152 // reload sub window | |
23077 | 153 |
33555 | 154 if (guiApp.sub.Bitmap.Image) |
155 wsResizeImage(&guiApp.subWindow, guiApp.sub.Bitmap.Width, guiApp.sub.Bitmap.Height); | |
32881 | 156 |
33555 | 157 if (!guiApp.subWindow.isFullScreen && !guiInfo.Playing) { |
158 wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); | |
33993 | 159 wsMoveWindow(&guiApp.subWindow, False, guiApp.sub.x, guiApp.sub.y); |
32881 | 160 } |
161 | |
33555 | 162 if (guiApp.sub.Bitmap.Image) |
163 wsConvert(&guiApp.subWindow, guiApp.sub.Bitmap.Image); | |
23077 | 164 |
33555 | 165 if (!guiInfo.Playing) { |
166 uiSubRender = 1; | |
167 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); | |
168 wsClearWindow(guiApp.subWindow); | |
169 wsPostRedisplay(&guiApp.subWindow); | |
32881 | 170 } |
171 | |
33555 | 172 // reload playbar |
32881 | 173 |
174 if (bprev) | |
33555 | 175 wsDestroyWindow(&guiApp.playbarWindow); |
32881 | 176 |
33555 | 177 uiPlaybarInit(); |
23077 | 178 |
32881 | 179 // reload main window |
180 | |
33555 | 181 free(mainDrawBuffer); |
182 mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize); | |
23077 | 183 |
33555 | 184 if (!mainDrawBuffer) { |
33530 | 185 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 186 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 187 } |
23077 | 188 |
33555 | 189 wsDestroyWindow(&guiApp.mainWindow); |
32881 | 190 |
33555 | 191 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); |
192 wsCreateImage(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height); | |
193 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
194 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); | |
23077 | 195 |
33555 | 196 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
197 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
198 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
199 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
32881 | 200 |
33555 | 201 wsXDNDMakeAwareness(&guiApp.mainWindow); |
23077 | 202 |
33555 | 203 if (!guiApp.mainDecoration) |
204 wsWindowDecoration(&guiApp.mainWindow, 0); | |
32881 | 205 |
33555 | 206 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
32881 | 207 mainVisible = 1; |
208 | |
33555 | 209 btnModify(evSetVolume, guiInfo.Volume); |
210 btnModify(evSetBalance, guiInfo.Balance); | |
211 btnModify(evSetMoviePosition, guiInfo.Position); | |
33978 | 212 btnSet(evFullScreen, (guiApp.subWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 213 |
33555 | 214 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
215 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 216 } |
217 | |
33555 | 218 void uiSetFileName(char *dir, char *name, int type) |
32881 | 219 { |
220 if (!name) | |
221 return; | |
23077 | 222 |
32881 | 223 if (!dir) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
224 setdup(&guiInfo.Filename, name); |
32881 | 225 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
226 setddup(&guiInfo.Filename, dir, name); |
23077 | 227 |
34064 | 228 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
229 |
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
230 if (type != SAME_STREAMTYPE) |
33555 | 231 guiInfo.StreamType = type; |
34064 | 232 |
33897 | 233 nfree(guiInfo.AudioFilename); |
234 nfree(guiInfo.SubtitleFilename); | |
23077 | 235 } |
236 | |
33555 | 237 void uiCurr(void) |
23077 | 238 { |
32881 | 239 plItem *curr; |
240 int stop = 0; | |
23077 | 241 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
242 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 243 return; |
23077 | 244 |
33555 | 245 switch (guiInfo.StreamType) { |
34387 | 246 #ifdef CONFIG_CDDA |
247 case STREAMTYPE_CDDA: | |
248 break; | |
249 #endif | |
250 | |
34077 | 251 #ifdef CONFIG_VCD |
252 case STREAMTYPE_VCD: | |
32881 | 253 break; |
32953 | 254 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
255 |
34077 | 256 #ifdef CONFIG_DVDREAD |
257 case STREAMTYPE_DVD: | |
32881 | 258 break; |
32953 | 259 #endif |
32881 | 260 |
261 default: | |
262 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
263 curr = listSet(gtkGetCurrPlItem, NULL); |
32881 | 264 |
265 if (curr) { | |
33555 | 266 uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE); |
267 uiGotoTheNext = 0; | |
32881 | 268 break; |
269 } | |
270 | |
271 return; | |
272 } | |
273 | |
274 if (stop) | |
33555 | 275 uiEventHandling(evStop, 0); |
32881 | 276 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
277 if (guiInfo.Playing == GUI_PLAY) |
33555 | 278 uiEventHandling(evPlay, 0); |
23077 | 279 } |
280 | |
33555 | 281 void uiPrev(void) |
23077 | 282 { |
32881 | 283 plItem *prev; |
284 int stop = 0; | |
285 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
286 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 287 return; |
288 | |
33555 | 289 switch (guiInfo.StreamType) { |
34387 | 290 #ifdef CONFIG_CDDA |
291 case STREAMTYPE_CDDA: | |
292 if (--guiInfo.Track == 0) { | |
293 guiInfo.Track = 1; | |
294 stop = 1; | |
295 } | |
296 break; | |
297 #endif | |
298 | |
34077 | 299 #ifdef CONFIG_VCD |
300 case STREAMTYPE_VCD: | |
301 if (--guiInfo.Track == 1) { | |
302 guiInfo.Track = 2; | |
303 stop = 1; | |
304 } | |
305 break; | |
306 #endif | |
307 | |
32881 | 308 #ifdef CONFIG_DVDREAD |
309 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
310 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
311 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
312 guiInfo.Chapter = 1; |
32881 | 313 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
314 if (--guiInfo.Track <= 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
315 guiInfo.Track = 1; |
32881 | 316 stop = 1; |
317 } | |
318 } | |
319 | |
320 break; | |
32953 | 321 #endif |
32881 | 322 |
323 default: | |
324 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
325 prev = listSet(gtkGetPrevPlItem, NULL); |
32881 | 326 |
327 if (prev) { | |
33555 | 328 uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE); |
329 uiGotoTheNext = 0; | |
33898 | 330 guiInfo.Track--; |
32881 | 331 break; |
332 } | |
333 | |
334 return; | |
335 } | |
336 | |
337 if (stop) | |
33555 | 338 uiEventHandling(evStop, 0); |
32881 | 339 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
340 if (guiInfo.Playing == GUI_PLAY) |
33555 | 341 uiEventHandling(evPlay, 0); |
23077 | 342 } |
343 | |
33555 | 344 void uiNext(void) |
23077 | 345 { |
32881 | 346 int stop = 0; |
347 plItem *next; | |
23077 | 348 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
349 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 350 return; |
351 | |
33555 | 352 switch (guiInfo.StreamType) { |
34387 | 353 #ifdef CONFIG_CDDA |
354 case STREAMTYPE_CDDA: | |
355 | |
356 if (++guiInfo.Track > guiInfo.Tracks) { | |
357 guiInfo.Track = guiInfo.Tracks; | |
358 stop = 1; | |
359 } | |
360 | |
361 break; | |
362 #endif | |
363 | |
34077 | 364 #ifdef CONFIG_VCD |
365 case STREAMTYPE_VCD: | |
366 | |
367 if (++guiInfo.Track >= guiInfo.Tracks) { | |
368 stop = (guiInfo.Track > guiInfo.Tracks); | |
369 guiInfo.Track = FFMAX(2, guiInfo.Tracks); | |
370 } | |
371 | |
372 break; | |
373 #endif | |
374 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
375 #ifdef CONFIG_DVDREAD |
32881 | 376 case STREAMTYPE_DVD: |
377 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
378 if (guiInfo.Chapter++ == guiInfo.Chapters) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
379 guiInfo.Chapter = 1; |
32881 | 380 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
381 if (++guiInfo.Track > guiInfo.Tracks) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
382 guiInfo.Track = guiInfo.Tracks; |
32881 | 383 stop = 1; |
384 } | |
385 } | |
386 | |
387 break; | |
32953 | 388 #endif |
32881 | 389 |
390 default: | |
391 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
392 next = listSet(gtkGetNextPlItem, NULL); |
32881 | 393 |
394 if (next) { | |
33555 | 395 uiSetFileName(next->path, next->name, STREAMTYPE_FILE); |
396 uiGotoTheNext = 0; | |
33898 | 397 guiInfo.Track++; |
32881 | 398 break; |
399 } | |
400 | |
401 return; | |
402 } | |
403 | |
404 if (stop) | |
33555 | 405 uiEventHandling(evStop, 0); |
32881 | 406 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
407 if (guiInfo.Playing == GUI_PLAY) |
33555 | 408 uiEventHandling(evPlay, 0); |
23077 | 409 } |