Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 35374:8249c2131cd3
Rename uiGotoTheNext uiProcessNextInPlaylist.
This is a more descriptive (although very long) name for the variable.
author | ib |
---|---|
date | Sat, 24 Nov 2012 15:54:22 +0000 |
parents | dd38e289f246 |
children | 2b49f4c8c47f |
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 |
35374 | 41 int uiProcessNextInPlaylist = 1; |
23077 | 42 |
33555 | 43 void uiFullScreen(void) |
23077 | 44 { |
33960 | 45 if (!guiInfo.VideoWindow) |
32881 | 46 return; |
47 | |
34697 | 48 wsFullScreen(&guiApp.videoWindow); |
23077 | 49 |
34697 | 50 vo_fs = guiApp.videoWindow.isFullScreen; |
23077 | 51 |
34697 | 52 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 53 |
33555 | 54 if (guiApp.menuIsPresent) |
34697 | 55 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 56 |
33555 | 57 if (guiInfo.Playing) |
34697 | 58 wsSetBackgroundRGB(&guiApp.videoWindow, 0, 0, 0); |
32881 | 59 else |
34697 | 60 wsSetBackgroundRGB(&guiApp.videoWindow, guiApp.video.R, guiApp.video.G, guiApp.video.B); |
23077 | 61 } |
62 | |
33555 | 63 void uiPlay(void) |
23077 | 64 { |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
65 if (guiInfo.Playing == GUI_PLAY) |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
66 return; |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
67 |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
68 if (guiInfo.StreamType != STREAMTYPE_CDDA && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
69 guiInfo.StreamType != STREAMTYPE_VCD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
70 guiInfo.StreamType != STREAMTYPE_DVD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
71 (!guiInfo.Filename || (guiInfo.Filename[0] == 0))) |
32881 | 72 return; |
23077 | 73 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
74 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 75 uiPause(); |
32881 | 76 return; |
77 } | |
78 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
79 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
34697 | 80 uiVideoRender = 0; |
81 wsSetBackgroundRGB(&guiApp.videoWindow, 0, 0, 0); | |
35357
80fe9ad7f318
Pass guiApp's wsTWindow parameters always by reference (if possible).
ib
parents:
34697
diff
changeset
|
82 wsClearWindow(&guiApp.videoWindow); |
23077 | 83 } |
84 | |
33555 | 85 void uiPause(void) |
23077 | 86 { |
33555 | 87 if (!guiInfo.Playing) |
32881 | 88 return; |
89 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
90 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 91 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
92 cmd->id = MP_CMD_PAUSE; | |
93 cmd->name = strdup("pause"); | |
94 mp_input_queue_cmd(cmd); | |
95 } else | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
96 guiInfo.Playing = GUI_PLAY; |
23077 | 97 } |
98 | |
33555 | 99 void uiState(void) |
32881 | 100 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
101 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 102 btnSet(evPlaySwitchToPause, btnReleased); |
103 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 104 } else { |
33978 | 105 btnSet(evPlaySwitchToPause, btnDisabled); |
106 btnSet(evPauseSwitchToPlay, btnReleased); | |
32881 | 107 } |
23077 | 108 } |
109 | |
33555 | 110 void uiRelSeek(float sec) |
32881 | 111 { |
32971 | 112 rel_seek_secs = sec; |
32881 | 113 abs_seek_pos = 0; |
114 } | |
115 | |
33555 | 116 void uiAbsSeek(float percent) |
32881 | 117 { |
32971 | 118 rel_seek_secs = percent / 100.0; |
32881 | 119 abs_seek_pos = 3; |
23077 | 120 } |
121 | |
33555 | 122 void uiChangeSkin(char *name) |
23077 | 123 { |
32893 | 124 int prev, bprev; |
32881 | 125 |
33555 | 126 prev = guiApp.menuIsPresent; |
127 bprev = guiApp.playbarIsPresent; | |
32881 | 128 |
129 mainVisible = 0; | |
130 | |
32893 | 131 if (skinRead(name) != 0) { |
132 if (skinRead(skinName) != 0) { | |
32894 | 133 mainVisible = 1; |
134 return; | |
32893 | 135 } |
32881 | 136 } |
137 | |
34684 | 138 /* reload menu window */ |
23077 | 139 |
33555 | 140 if (prev && guiApp.menuIsPresent) { |
141 free(menuDrawBuffer); | |
142 menuDrawBuffer = calloc(1, guiApp.menu.Bitmap.ImageSize); | |
32881 | 143 |
33555 | 144 if (!menuDrawBuffer) { |
33530 | 145 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 146 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 147 } |
23077 | 148 |
33555 | 149 wsResizeWindow(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); |
150 wsResizeImage(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); | |
151 wsSetShape(&guiApp.menuWindow, guiApp.menu.Mask.Image); | |
152 wsVisibleWindow(&guiApp.menuWindow, wsHideWindow); | |
32881 | 153 } else |
33555 | 154 uiMenuInit(); |
32881 | 155 |
34697 | 156 /* reload video window */ |
23077 | 157 |
34697 | 158 if (guiApp.video.Bitmap.Image) |
159 wsResizeImage(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); | |
32881 | 160 |
34697 | 161 if (!guiApp.videoWindow.isFullScreen && !guiInfo.Playing) { |
162 wsResizeWindow(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); | |
163 wsMoveWindow(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
32881 | 164 } |
165 | |
34697 | 166 if (guiApp.video.Bitmap.Image) |
167 wsConvert(&guiApp.videoWindow, guiApp.video.Bitmap.Image); | |
23077 | 168 |
33555 | 169 if (!guiInfo.Playing) { |
34697 | 170 uiVideoRender = 1; |
171 wsSetBackgroundRGB(&guiApp.videoWindow, guiApp.video.R, guiApp.video.G, guiApp.video.B); | |
35357
80fe9ad7f318
Pass guiApp's wsTWindow parameters always by reference (if possible).
ib
parents:
34697
diff
changeset
|
172 wsClearWindow(&guiApp.videoWindow); |
34697 | 173 wsPostRedisplay(&guiApp.videoWindow); |
32881 | 174 } |
175 | |
34684 | 176 /* reload playbar */ |
32881 | 177 |
178 if (bprev) | |
33555 | 179 wsDestroyWindow(&guiApp.playbarWindow); |
32881 | 180 |
33555 | 181 uiPlaybarInit(); |
23077 | 182 |
34684 | 183 /* reload main window */ |
32881 | 184 |
33555 | 185 free(mainDrawBuffer); |
186 mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize); | |
23077 | 187 |
33555 | 188 if (!mainDrawBuffer) { |
33530 | 189 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 190 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 191 } |
23077 | 192 |
33555 | 193 wsDestroyWindow(&guiApp.mainWindow); |
32881 | 194 |
33555 | 195 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); |
196 wsCreateImage(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height); | |
197 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
198 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); | |
23077 | 199 |
33555 | 200 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
201 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
202 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
203 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
32881 | 204 |
33555 | 205 wsXDNDMakeAwareness(&guiApp.mainWindow); |
23077 | 206 |
33555 | 207 if (!guiApp.mainDecoration) |
208 wsWindowDecoration(&guiApp.mainWindow, 0); | |
32881 | 209 |
33555 | 210 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
32881 | 211 mainVisible = 1; |
212 | |
33555 | 213 btnModify(evSetVolume, guiInfo.Volume); |
214 btnModify(evSetBalance, guiInfo.Balance); | |
215 btnModify(evSetMoviePosition, guiInfo.Position); | |
34697 | 216 btnSet(evFullScreen, (guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 217 |
34697 | 218 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
219 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); | |
32881 | 220 } |
221 | |
33555 | 222 void uiSetFileName(char *dir, char *name, int type) |
32881 | 223 { |
224 if (!name) | |
225 return; | |
23077 | 226 |
32881 | 227 if (!dir) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
228 setdup(&guiInfo.Filename, name); |
32881 | 229 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
230 setddup(&guiInfo.Filename, dir, name); |
23077 | 231 |
34064 | 232 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
233 |
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
234 if (type != SAME_STREAMTYPE) |
34400 | 235 guiInfo.StreamType = type; |
34064 | 236 |
33897 | 237 nfree(guiInfo.AudioFilename); |
238 nfree(guiInfo.SubtitleFilename); | |
23077 | 239 } |
240 | |
33555 | 241 void uiCurr(void) |
23077 | 242 { |
32881 | 243 plItem *curr; |
23077 | 244 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
245 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 246 return; |
23077 | 247 |
33555 | 248 switch (guiInfo.StreamType) { |
34387 | 249 case STREAMTYPE_CDDA: |
34077 | 250 case STREAMTYPE_VCD: |
251 case STREAMTYPE_DVD: | |
32881 | 252 break; |
253 | |
254 default: | |
255 | |
34663 | 256 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
32881 | 257 |
258 if (curr) { | |
33555 | 259 uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE); |
35374 | 260 uiProcessNextInPlaylist = 0; |
32881 | 261 break; |
262 } | |
263 | |
264 return; | |
265 } | |
266 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
267 if (guiInfo.Playing == GUI_PLAY) |
33555 | 268 uiEventHandling(evPlay, 0); |
23077 | 269 } |
270 | |
33555 | 271 void uiPrev(void) |
23077 | 272 { |
32881 | 273 plItem *prev; |
274 int stop = 0; | |
275 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
276 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 277 return; |
278 | |
33555 | 279 switch (guiInfo.StreamType) { |
34387 | 280 case STREAMTYPE_CDDA: |
281 if (--guiInfo.Track == 0) { | |
282 guiInfo.Track = 1; | |
283 stop = 1; | |
284 } | |
285 break; | |
286 | |
34077 | 287 case STREAMTYPE_VCD: |
288 if (--guiInfo.Track == 1) { | |
289 guiInfo.Track = 2; | |
290 stop = 1; | |
291 } | |
292 break; | |
293 | |
32881 | 294 case STREAMTYPE_DVD: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
295 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
296 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
297 guiInfo.Chapter = 1; |
32881 | 298 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
299 if (--guiInfo.Track <= 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
300 guiInfo.Track = 1; |
32881 | 301 stop = 1; |
302 } | |
303 } | |
304 | |
305 break; | |
306 | |
307 default: | |
308 | |
34663 | 309 prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); |
32881 | 310 |
311 if (prev) { | |
33555 | 312 uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE); |
35374 | 313 uiProcessNextInPlaylist = (guiInfo.Playing ? 0 : 1); |
33898 | 314 guiInfo.Track--; |
32881 | 315 break; |
316 } | |
317 | |
318 return; | |
319 } | |
320 | |
321 if (stop) | |
33555 | 322 uiEventHandling(evStop, 0); |
32881 | 323 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
324 if (guiInfo.Playing == GUI_PLAY) |
33555 | 325 uiEventHandling(evPlay, 0); |
23077 | 326 } |
327 | |
33555 | 328 void uiNext(void) |
23077 | 329 { |
32881 | 330 int stop = 0; |
331 plItem *next; | |
23077 | 332 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
333 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 334 return; |
335 | |
33555 | 336 switch (guiInfo.StreamType) { |
34387 | 337 case STREAMTYPE_CDDA: |
338 | |
339 if (++guiInfo.Track > guiInfo.Tracks) { | |
340 guiInfo.Track = guiInfo.Tracks; | |
341 stop = 1; | |
342 } | |
343 | |
344 break; | |
345 | |
34077 | 346 case STREAMTYPE_VCD: |
347 | |
348 if (++guiInfo.Track >= guiInfo.Tracks) { | |
349 stop = (guiInfo.Track > guiInfo.Tracks); | |
350 guiInfo.Track = FFMAX(2, guiInfo.Tracks); | |
351 } | |
352 | |
353 break; | |
354 | |
32881 | 355 case STREAMTYPE_DVD: |
356 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
357 if (guiInfo.Chapter++ == guiInfo.Chapters) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
358 guiInfo.Chapter = 1; |
32881 | 359 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
360 if (++guiInfo.Track > guiInfo.Tracks) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
361 guiInfo.Track = guiInfo.Tracks; |
32881 | 362 stop = 1; |
363 } | |
364 } | |
365 | |
366 break; | |
367 | |
368 default: | |
369 | |
34663 | 370 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
32881 | 371 |
372 if (next) { | |
33555 | 373 uiSetFileName(next->path, next->name, STREAMTYPE_FILE); |
35374 | 374 uiProcessNextInPlaylist = (guiInfo.Playing ? 0 : 1); |
33898 | 375 guiInfo.Track++; |
32881 | 376 break; |
377 } | |
378 | |
379 return; | |
380 } | |
381 | |
382 if (stop) | |
33555 | 383 uiEventHandling(evStop, 0); |
32881 | 384 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
385 if (guiInfo.Playing == GUI_PLAY) |
33555 | 386 uiEventHandling(evPlay, 0); |
23077 | 387 } |