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