Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 33761:16286ee1fc71
Fix Win32 GUI compilation problems.
Add #includes to provide prototypes and change
some declarations to comply with the prototypes.
Reported by Stephen Sheldon, sfsheldo gmail com.
author | ib |
---|---|
date | Fri, 08 Jul 2011 09:52:02 +0000 |
parents | 6cea6d268f97 |
children | 6134493605c6 |
rev | line source |
---|---|
23077 | 1 /* |
23079 | 2 * MPlayer GUI for Win32 |
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
26457 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23079 | 22 */ |
23077 | 23 |
24 #include <windows.h> | |
33358 | 25 |
26 #if defined(__CYGWIN__) | |
27 #define _beginthreadex CreateThread | |
28 #else | |
29 #include <process.h> | |
30 #endif | |
31 | |
30901 | 32 #include "path.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
33 #include "gui/interface.h" |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "m_option.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mixer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "codec-cfg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "libmpdemux/demuxer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "libmpdemux/stheader.h" |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
42 #ifdef CONFIG_DVDREAD |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
43 #include "stream/stream_dvd.h" |
23077 | 44 #endif |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
45 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
46 #include "libvo/video_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
47 #include "libao2/audio_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
48 #include "access_mpcontext.h" |
30558 | 49 #include "libmpcodecs/vd.h" |
31425
2392ad3cec9c
Move af_cfg extern variable declaration to dec_audio.h.
diego
parents:
31312
diff
changeset
|
50 #include "libmpcodecs/dec_audio.h" |
33761 | 51 #include "gui/ui/actions.h" |
33557 | 52 #include "gui/ui/gmplayer.h" |
33761 | 53 #include "gui/util/list.h" |
54 #include "gui/util/string.h" | |
30558 | 55 #include "mp_core.h" |
32093 | 56 #include "mpcommon.h" |
23077 | 57 #include "gui.h" |
58 #include "dialogs.h" | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
59 #ifdef CONFIG_LIBCDIO |
23077 | 60 #include <cdio/cdio.h> |
61 #endif | |
62 | |
63 int guiWinID = 0; | |
64 | |
65 char *skinName = NULL; | |
66 char *codecname = NULL; | |
33555 | 67 int uiGotoTheNext = 1; |
23077 | 68 static gui_t *mygui = NULL; |
69 static int update_subwindow(void); | |
70 static RECT old_rect; | |
71 static DWORD style; | |
24992 | 72 static HANDLE hThread; |
73 static unsigned threadId; | |
25765
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
74 const ao_functions_t *audio_out = NULL; |
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
75 const vo_functions_t *video_out = NULL; |
23077 | 76 mixer_t *mixer = NULL; |
77 | |
78 /* test for playlist files, no need to specify -playlist on the commandline. | |
79 * add any conceivable playlist extensions here. | |
80 * - Erik | |
81 */ | |
82 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
83 { | |
84 if(clear) | |
85 mygui->playlist->clear_playlist(mygui->playlist); | |
86 | |
87 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
88 { | |
89 playtree = parse_playlist_file(file); | |
33752 | 90 guiPlaylistAdd(playtree, mconfig); |
23077 | 91 return 1; |
92 } | |
93 return 0; | |
94 } | |
95 | |
33737 | 96 char *gstrdup(const char *str) |
97 { | |
98 if (!str) return NULL; | |
99 return strdup(str); | |
100 } | |
101 | |
33761 | 102 void setdup (char **old, const char *str) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
103 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
104 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
105 *old = gstrdup(str); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
106 } |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
107 |
33761 | 108 void setddup (char **old, const char *dir, const char *name) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
109 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
110 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
111 *old = malloc(strlen(dir) + strlen(name) + 2); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
112 if (*old) sprintf(*old, "%s/%s", dir, name); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
113 } |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
114 |
23077 | 115 /** |
116 * \brief this actually creates a new list containing only one element... | |
117 */ | |
118 void gaddlist( char ***list, const char *entry) | |
119 { | |
120 int i; | |
121 | |
122 if (*list) | |
123 { | |
124 for (i=0; (*list)[i]; i++) free((*list)[i]); | |
125 free(*list); | |
126 } | |
127 | |
128 *list = malloc(2 * sizeof(char **)); | |
129 (*list)[0] = gstrdup(entry); | |
130 (*list)[1] = NULL; | |
131 } | |
132 | |
133 /** | |
134 * \brief this replaces a string starting with search by replace. | |
135 * If not found, replace is appended. | |
136 */ | |
33761 | 137 void greplace(char ***list, const char *search, const char *replace) |
23077 | 138 { |
139 int i = 0; | |
140 int len = (search) ? strlen(search) : 0; | |
141 | |
142 if (*list) | |
143 { | |
144 for (i = 0; (*list)[i]; i++) | |
145 { | |
146 if (search && (!strncmp((*list)[i], search, len))) | |
147 { | |
148 free((*list)[i]); | |
149 (*list)[i] = gstrdup(replace); | |
150 return; | |
151 } | |
152 } | |
153 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
154 } | |
155 else | |
156 *list = malloc(2 * sizeof(char *)); | |
157 | |
158 (*list)[i] = gstrdup(replace); | |
159 (*list)[i + 1] = NULL; | |
160 } | |
161 | |
162 /* this function gets called by the gui to update mplayer */ | |
163 static void guiSetEvent(int event) | |
164 { | |
33555 | 165 if(guiInfo.mpcontext) |
166 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
23077 | 167 |
168 switch(event) | |
169 { | |
170 case evPlay: | |
171 case evPlaySwitchToPause: | |
23148
71efd1fc20c8
add missing case value, fixes functionality when using some skins.
vayne
parents:
23147
diff
changeset
|
172 case evPauseSwitchToPlay: |
33555 | 173 uiPlay(); |
23077 | 174 break; |
175 case evPause: | |
33555 | 176 uiPause(); |
23077 | 177 break; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
178 #ifdef CONFIG_DVDREAD |
23077 | 179 case evPlayDVD: |
180 { | |
181 static char dvdname[MAX_PATH]; | |
33555 | 182 guiInfo.DVD.current_title = dvd_title; |
183 guiInfo.DVD.current_chapter = dvd_chapter; | |
184 guiInfo.DVD.current_angle = dvd_angle; | |
185 guiInfo.DiskChanged = 1; | |
23077 | 186 |
33555 | 187 uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); |
23077 | 188 dvdname[0] = 0; |
189 strcat(dvdname, "DVD Movie"); | |
190 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
191 capitalize(dvdname); | |
192 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
193 gui(GUI_PREPARE, (void *) STREAMTYPE_DVD); |
23077 | 194 mygui->playlist->clear_playlist(mygui->playlist); |
195 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
196 mygui->startplay(mygui); | |
197 break; | |
198 } | |
199 #endif | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
200 #ifdef CONFIG_LIBCDIO |
23077 | 201 case evPlayCD: |
202 { | |
203 int i; | |
204 char track[10]; | |
205 char trackname[10]; | |
206 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
207 track_t i_tracks; | |
208 | |
209 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
210 i_tracks = cdio_get_num_tracks(p_cdio); | |
211 | |
212 mygui->playlist->clear_playlist(mygui->playlist); | |
213 for(i=0;i<i_tracks;i++) | |
214 { | |
215 sprintf(track, "cdda://%d", i+1); | |
216 sprintf(trackname, "Track %d", i+1); | |
217 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
218 } | |
219 cdio_destroy(p_cdio); | |
220 mygui->startplay(mygui); | |
221 break; | |
222 } | |
223 #endif | |
224 case evFullScreen: | |
225 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
226 break; | |
227 case evExit: | |
228 { | |
229 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
230 this should be the only safe way to quit */ | |
231 mygui->activewidget = NULL; | |
232 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
233 break; | |
234 } | |
235 case evStop: | |
33555 | 236 if(guiInfo.Playing) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
237 gui(GUI_SET_STATE, (void *) GUI_STOP); |
23077 | 238 break; |
239 case evSetMoviePosition: | |
240 { | |
33555 | 241 rel_seek_secs = guiInfo.Position / 100.0f; |
23077 | 242 abs_seek_pos = 3; |
243 break; | |
244 } | |
245 case evForward10sec: | |
246 { | |
247 rel_seek_secs = 10.0f; | |
248 abs_seek_pos = 0; | |
249 break; | |
250 } | |
251 case evBackward10sec: | |
252 { | |
253 rel_seek_secs = -10.0f; | |
254 abs_seek_pos = 0; | |
255 break; | |
256 } | |
257 case evSetBalance: | |
258 case evSetVolume: | |
259 { | |
260 float l,r; | |
261 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
262 if (guiInfo.Playing == GUI_STOP) |
23077 | 263 break; |
264 | |
33555 | 265 if (guiInfo.Balance == 50.0f) |
266 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
23077 | 267 |
33555 | 268 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
269 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
23077 | 270 |
33555 | 271 if (l > guiInfo.Volume) l=guiInfo.Volume; |
272 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
23077 | 273 mixer_setvolume(mixer, l, r); |
274 /* Check for balance support on mixer - there is a better way ?? */ | |
275 if (r != l) | |
276 { | |
277 mixer_getvolume(mixer, &l, &r); | |
278 if (r == l) | |
279 { | |
280 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
33555 | 281 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
282 guiInfo.Balance = 50.0f; | |
23077 | 283 } |
284 } | |
285 break; | |
286 } | |
287 case evMute: | |
288 { | |
289 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
290 cmd->id=MP_CMD_MUTE; | |
291 cmd->name=strdup("mute"); | |
292 mp_input_queue_cmd(cmd); | |
293 break; | |
294 } | |
295 case evDropFile: | |
296 case evLoadPlay: | |
297 { | |
33555 | 298 switch(guiInfo.StreamType) |
23077 | 299 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
300 #ifdef CONFIG_DVDREAD |
23077 | 301 case STREAMTYPE_DVD: |
302 { | |
33555 | 303 guiInfo.Title = guiInfo.DVD.current_title; |
304 guiInfo.Chapter = guiInfo.DVD.current_chapter; | |
305 guiInfo.Angle = guiInfo.DVD.current_angle; | |
306 guiInfo.DiskChanged = 1; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
307 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 308 break; |
309 } | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
310 #endif |
23077 | 311 default: |
312 { | |
33555 | 313 guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
23077 | 314 update_playlistwindow(); |
33555 | 315 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
316 gui(GUI_SET_STATE, (void *) GUI_STOP); |
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
317 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 318 break; |
319 } | |
320 } | |
321 break; | |
322 } | |
323 case evNext: | |
33555 | 324 uiNext(); |
23077 | 325 break; |
326 case evPrev: | |
33555 | 327 uiPrev(); |
23077 | 328 break; |
329 } | |
330 } | |
331 | |
33555 | 332 void uiPlay( void ) |
23077 | 333 { |
33555 | 334 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
23077 | 335 return; |
336 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
337 if(guiInfo.Playing > GUI_STOP) |
23077 | 338 { |
33555 | 339 uiPause(); |
23077 | 340 return; |
341 } | |
33555 | 342 guiInfo.NewPlay = 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
343 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 344 } |
345 | |
33555 | 346 void uiPause( void ) |
23077 | 347 { |
33555 | 348 if(!guiInfo.Playing) return; |
23077 | 349 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
350 if(guiInfo.Playing == GUI_PLAY) |
23077 | 351 { |
352 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
353 cmd->id=MP_CMD_PAUSE; | |
354 cmd->name=strdup("pause"); | |
355 mp_input_queue_cmd(cmd); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
356 } else guiInfo.Playing = GUI_PLAY; |
23077 | 357 } |
358 | |
33555 | 359 void uiNext(void) |
23077 | 360 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
361 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 362 switch(guiInfo.StreamType) |
23077 | 363 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
364 #ifdef CONFIG_DVDREAD |
23077 | 365 case STREAMTYPE_DVD: |
33555 | 366 if(guiInfo.DVD.current_chapter == (guiInfo.DVD.chapters - 1)) |
23077 | 367 return; |
33555 | 368 guiInfo.DVD.current_chapter++; |
23077 | 369 break; |
370 #endif | |
371 default: | |
372 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
373 return; | |
33555 | 374 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
23077 | 375 STREAMTYPE_STREAM); |
376 break; | |
377 } | |
378 mygui->startplay(mygui); | |
379 } | |
380 | |
33555 | 381 void uiPrev(void) |
23077 | 382 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
383 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 384 switch(guiInfo.StreamType) |
23077 | 385 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
386 #ifdef CONFIG_DVDREAD |
23077 | 387 case STREAMTYPE_DVD: |
33555 | 388 if(guiInfo.DVD.current_chapter == 1) |
23077 | 389 return; |
33555 | 390 guiInfo.DVD.current_chapter--; |
23077 | 391 break; |
392 #endif | |
393 default: | |
394 if(mygui->playlist->current == 0) | |
395 return; | |
33555 | 396 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
23077 | 397 STREAMTYPE_STREAM); |
398 break; | |
399 } | |
400 mygui->startplay(mygui); | |
401 } | |
402 | |
33555 | 403 void uiSetFileName(char *dir, char *name, int type) |
23077 | 404 { |
405 if(!name) return; | |
406 if(!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
407 setdup(&guiInfo.Filename, name); |
23077 | 408 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
409 setddup(&guiInfo.Filename, dir, name); |
23077 | 410 |
33555 | 411 guiInfo.StreamType = type; |
412 free(guiInfo.AudioFile); | |
413 guiInfo.AudioFile = NULL; | |
414 free(guiInfo.Subtitlename); | |
415 guiInfo.Subtitlename = NULL; | |
23077 | 416 } |
417 | |
33555 | 418 void uiFullScreen( void ) |
23077 | 419 { |
33555 | 420 if(!guiInfo.sh_video) return; |
23077 | 421 |
422 if(sub_window) | |
423 { | |
424 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
425 GetWindowRect(mygui->subwindow, &old_rect); | |
426 | |
427 if(fullscreen) | |
428 { | |
429 fullscreen = 0; | |
430 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
431 } else { | |
432 fullscreen = 1; | |
433 style = WS_VISIBLE | WS_POPUP; | |
434 } | |
435 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
436 update_subwindow(); | |
437 } | |
438 video_out->control(VOCTRL_FULLSCREEN, 0); | |
439 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
440 } | |
441 | |
24992 | 442 static unsigned __stdcall GuiThread(void* param) |
23077 | 443 { |
444 MSG msg; | |
445 | |
446 if(!skinName) skinName = strdup("Blue"); | |
447 if(!mygui) mygui = create_gui(get_path("skins"), skinName, guiSetEvent); | |
30558 | 448 if(!mygui) exit_player(EXIT_ERROR); |
23077 | 449 |
450 if(autosync && autosync != gtkAutoSync) | |
451 { | |
452 gtkAutoSyncOn = 1; | |
453 gtkAutoSync = autosync; | |
454 } | |
455 | |
24992 | 456 while(GetMessage(&msg, NULL, 0, 0)) |
23077 | 457 { |
458 TranslateMessage(&msg); | |
459 DispatchMessage(&msg); | |
460 } | |
23078 | 461 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
23077 | 462 fflush(stderr); |
463 return 0; | |
464 } | |
465 | |
466 void guiInit(void) | |
467 { | |
33555 | 468 memset(&guiInfo, 0, sizeof(guiInfo)); |
23077 | 469 /* Create The gui thread */ |
470 if (!mygui) | |
471 { | |
33358 | 472 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
23077 | 473 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
474 } | |
475 | |
476 /* Wait until the gui is created */ | |
477 while(!mygui) Sleep(100); | |
23078 | 478 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
23077 | 479 } |
480 | |
481 void guiDone(void) | |
482 { | |
483 if(mygui) | |
484 { | |
485 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
486 fflush(stderr); | |
24992 | 487 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
488 WaitForSingleObject(hThread, INFINITE); | |
489 CloseHandle(hThread); | |
23077 | 490 mygui->uninit(mygui); |
491 free(mygui); | |
492 mygui = NULL; | |
493 } | |
494 /* Remove tray icon */ | |
495 Shell_NotifyIcon(NIM_DELETE, &nid); | |
496 cfg_write(); | |
497 } | |
498 | |
499 /* this function gets called by mplayer to update the gui */ | |
33726 | 500 int gui(int what, void *arg) |
23077 | 501 { |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
502 stream_t *stream = arg; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
503 #ifdef CONFIG_DVDREAD |
33730 | 504 dvd_priv_t *dvdp; |
23077 | 505 #endif |
506 if(!mygui || !mygui->skin) return 0; | |
507 | |
33555 | 508 if(guiInfo.mpcontext) |
23077 | 509 { |
33555 | 510 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
511 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
512 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
513 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
23077 | 514 } |
515 | |
33726 | 516 switch (what) |
23077 | 517 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
518 case GUI_PREPARE: |
23077 | 519 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
520 gui(GUI_SET_FILE, 0); |
33555 | 521 guiInfo.DiskChanged = 0; |
522 guiInfo.FilenameChanged = 0; | |
523 guiInfo.NewPlay = 0; | |
524 switch(guiInfo.StreamType) | |
23077 | 525 { |
526 case STREAMTYPE_PLAYLIST: | |
527 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
528 #ifdef CONFIG_DVDREAD |
23077 | 529 case STREAMTYPE_DVD: |
530 { | |
531 char tmp[512]; | |
33555 | 532 dvd_title = guiInfo.DVD.current_title; |
533 dvd_chapter = guiInfo.DVD.current_chapter; | |
534 dvd_angle = guiInfo.DVD.current_angle; | |
535 sprintf(tmp,"dvd://%d", guiInfo.Title); | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
536 setdup(&guiInfo.Filename, tmp); |
23077 | 537 break; |
538 } | |
539 #endif | |
540 } | |
33555 | 541 if(guiInfo.Filename) |
542 filename = strdup(guiInfo.Filename); | |
23077 | 543 else if(filename) |
33555 | 544 strcpy(guiInfo.Filename, filename); |
23077 | 545 break; |
546 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
547 case GUI_SET_AUDIO: |
23077 | 548 { |
33679 | 549 guiInfo.MovieWindow = (arg && !guiInfo.sh_video); |
33661 | 550 // NOTE: This type doesn't mean (and never meant) that we have |
551 // *just* audio, so there probably should be a check before | |
552 // hiding (see gui/interface.c). | |
23077 | 553 if(IsWindowVisible(mygui->subwindow)) |
554 ShowWindow(mygui->subwindow, SW_HIDE); | |
555 break; | |
556 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
557 case GUI_SET_CONTEXT: |
33555 | 558 guiInfo.mpcontext = arg; |
23077 | 559 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
560 case GUI_SET_VIDEO: |
23077 | 561 { |
33555 | 562 guiInfo.sh_video = arg; |
23077 | 563 if (arg) |
564 { | |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
565 sh_video_t *sh = arg; |
23077 | 566 codecname = sh->codec->name; |
33555 | 567 guiInfo.FPS = sh->fps; |
23077 | 568 |
569 /* we have video, show the subwindow */ | |
570 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
571 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
572 if(WinID == -1) | |
573 update_subwindow(); | |
574 | |
575 } | |
576 break; | |
577 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
578 case GUI_SETUP_VIDEO_WINDOW: |
23077 | 579 { |
33555 | 580 guiInfo.MovieWidth = vo_dwidth; |
581 guiInfo.MovieHeight = vo_dheight; | |
23077 | 582 |
33555 | 583 sub_aspect = (float)guiInfo.MovieWidth/guiInfo.MovieHeight; |
23077 | 584 if(WinID != -1) |
585 update_subwindow(); | |
586 break; | |
587 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
588 case GUI_SET_STREAM: |
23077 | 589 { |
33555 | 590 guiInfo.StreamType = stream->type; |
23077 | 591 switch(stream->type) |
592 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
593 #ifdef CONFIG_DVDREAD |
23077 | 594 case STREAMTYPE_DVD: |
33730 | 595 dvdp = stream->priv; |
596 guiInfo.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
597 guiInfo.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
598 guiInfo.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
599 guiInfo.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
600 memcpy(guiInfo.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
601 guiInfo.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
602 memcpy(guiInfo.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
603 guiInfo.DVD.current_title = dvd_title + 1; | |
604 guiInfo.DVD.current_chapter = dvd_chapter + 1; | |
605 guiInfo.DVD.current_angle = dvd_angle + 1; | |
606 guiInfo.Track = dvd_title + 1; | |
23077 | 607 break; |
608 #endif | |
609 } | |
610 break; | |
611 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
612 case GUI_REDRAW: |
23077 | 613 mygui->updatedisplay(mygui, mygui->mainwindow); |
614 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
615 case GUI_SET_AFILTER: |
33555 | 616 guiInfo.afilter = arg; |
23077 | 617 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
618 case GUI_SET_STATE: |
23077 | 619 { |
33555 | 620 guiInfo.Playing = (int) arg; |
621 switch (guiInfo.Playing) | |
23077 | 622 { |
33614 | 623 case GUI_PLAY: |
23077 | 624 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
625 guiInfo.Playing = GUI_PLAY; |
23077 | 626 break; |
627 } | |
33614 | 628 case GUI_STOP: |
23077 | 629 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
630 guiInfo.Playing = GUI_STOP; |
23077 | 631 if(movie_aspect >= 0) |
632 movie_aspect = -1; | |
633 update_subwindow(); | |
634 break; | |
635 } | |
33614 | 636 case GUI_PAUSE: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
637 guiInfo.Playing = GUI_PAUSE; |
23077 | 638 break; |
639 } | |
640 break; | |
641 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
642 case GUI_RUN_COMMAND: |
23077 | 643 { |
644 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg); | |
645 /* MPlayer asks us to quit */ | |
646 switch((int) arg) | |
647 { | |
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
648 case MP_CMD_VO_FULLSCREEN: |
33555 | 649 uiFullScreen(); |
23077 | 650 break; |
651 case MP_CMD_QUIT: | |
652 { | |
653 mygui->uninit(mygui); | |
654 free(mygui); | |
655 mygui = NULL; | |
30558 | 656 exit_player(EXIT_QUIT); |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
657 return 1; |
23077 | 658 } |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
659 case MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
660 guiSetEvent(evNext); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
661 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
662 case -MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
663 guiSetEvent(evPrev); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
664 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
665 case MP_CMD_STOP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
666 guiSetEvent(evStop); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
667 break; |
23077 | 668 default: |
669 break; | |
670 } | |
671 break; | |
672 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
673 case GUI_SET_FILE: |
23077 | 674 { |
675 audio_id = -1; | |
676 video_id = -1; | |
677 dvdsub_id = -1; | |
678 vobsub_id = -1; | |
679 stream_cache_size = -1; | |
680 autosync = 0; | |
681 dvd_title = 0; | |
682 force_fps = 0; | |
683 if(!mygui->playlist->tracks) return 0; | |
33555 | 684 filename = guiInfo.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename; |
685 guiInfo.Track = mygui->playlist->current + 1; | |
23077 | 686 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
687 if(gtkAOExtraStereo) | |
688 { | |
689 char *name = malloc(12 + 20 + 1); | |
690 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
691 name[12 + 20] = 0; | |
692 greplace(&af_cfg.list, "extrastereo", name); | |
693 free(name); | |
694 } | |
695 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
696 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
697 break; | |
698 } | |
33732 | 699 case GUI_HANDLE_EVENTS: |
700 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
701 case GUI_SET_MIXER: |
23077 | 702 { |
703 if(audio_out) | |
704 { | |
705 /* Some audio_out drivers do not support balance e.g. dsound */ | |
706 /* FIXME this algo is not correct */ | |
707 float l, r; | |
708 mixer_getvolume(mixer, &l, &r); | |
33555 | 709 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
23077 | 710 if (r != l) |
33555 | 711 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
23077 | 712 else |
33555 | 713 guiInfo.Balance = 50.0f; |
23077 | 714 } |
715 break; | |
716 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
717 case GUI_END_FILE: |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
718 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
719 if(!uiGotoTheNext && guiInfo.Playing) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
720 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
721 uiGotoTheNext = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
722 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
723 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
724 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
725 if(uiGotoTheNext && guiInfo.Playing && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
726 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
727 guiInfo.StreamType != STREAMTYPE_DVD && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
728 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
729 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
730 /* we've finished this file, reset the aspect */ |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
731 if(movie_aspect >= 0) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
732 movie_aspect = -1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
733 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
734 uiGotoTheNext = guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
735 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
736 //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
737 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
738 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
739 if(guiInfo.FilenameChanged && guiInfo.NewPlay) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
740 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
741 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
742 guiInfo.TimeSec = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
743 guiInfo.Position = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
744 guiInfo.AudioChannels = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
745 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
746 #ifdef CONFIG_DVDREAD |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
747 guiInfo.DVD.current_title = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
748 guiInfo.DVD.current_chapter = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
749 guiInfo.DVD.current_angle = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
750 #endif |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
751 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
752 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
753 mygui->playlist->current = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
754 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
755 fullscreen = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
756 if(style == WS_VISIBLE | WS_POPUP) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
757 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
758 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
759 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
760 } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
761 gui(GUI_SET_STATE, (void *) GUI_STOP); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
762 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
763 } |
23077 | 764 default: |
33726 | 765 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
23077 | 766 } |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
767 return 1; |
23077 | 768 } |
769 | |
770 /* This function adds/inserts one file into the gui playlist */ | |
33579 | 771 static int import_file_into_gui(char *pathname, int insert) |
23077 | 772 { |
773 char filename[MAX_PATH]; | |
774 char *filepart = filename; | |
775 | |
776 if (strstr(pathname, "://")) | |
777 { | |
778 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
779 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
780 return 1; | |
781 } | |
782 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
783 { | |
784 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
785 { | |
786 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
787 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
788 return 1; | |
789 } | |
790 else | |
791 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
792 } | |
793 | |
794 return 0; | |
795 } | |
796 | |
797 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
798 by either: | |
799 - overwriting gui pl (enqueue=0) */ | |
800 | |
33752 | 801 int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
23077 | 802 { |
803 play_tree_iter_t *my_pt_iter = NULL; | |
804 int result = 0; | |
805 | |
806 if(!mygui) guiInit(); | |
807 | |
808 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
809 { | |
810 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
811 { | |
812 if (parse_filename(filename, my_playtree, config, 0)) | |
813 result = 1; | |
814 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
815 result = 1; | |
816 } | |
817 } | |
33555 | 818 uiGotoTheNext = 1; |
23077 | 819 |
820 if (result) | |
821 { | |
822 mygui->playlist->current = 0; | |
823 filename = mygui->playlist->tracks[0]->filename; | |
824 } | |
825 return result; | |
826 } | |
827 | |
828 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
829 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
830 The file which contained the playlist is thereby replaced with it's contents. */ | |
831 | |
33752 | 832 int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config) |
23077 | 833 { |
834 play_tree_iter_t *my_pt_iter = NULL; | |
835 int result = 0; | |
836 | |
837 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
838 { | |
839 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
840 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
841 result = 1; | |
842 pt_iter_destroy(&my_pt_iter); | |
843 } | |
844 filename = NULL; | |
845 return result; | |
846 } | |
847 | |
33579 | 848 static inline void gtkMessageBox(int type, const char *str) |
23077 | 849 { |
850 if (type & GTK_MB_FATAL) | |
851 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR); | |
852 | |
853 fprintf(stderr, "[GUI] MessageBox: %s\n", str); | |
854 fflush(stderr); | |
855 } | |
856 | |
857 static int update_subwindow(void) | |
858 { | |
859 int x,y; | |
860 RECT rd; | |
861 WINDOWPOS wp; | |
862 | |
863 if(!sub_window) | |
864 { | |
33567 | 865 WinID = -1; |
23077 | 866 |
33555 | 867 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
23077 | 868 { |
869 ShowWindow(mygui->subwindow, SW_HIDE); | |
870 return 0; | |
871 } | |
33679 | 872 else if(!guiInfo.MovieWindow) |
23077 | 873 return 0; |
874 else ShowWindow(mygui->subwindow, SW_SHOW); | |
875 } | |
876 | |
877 /* we've come out of fullscreen at the end of file */ | |
33679 | 878 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.MovieWindow) |
23077 | 879 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
880 | |
881 /* get our current window coordinates */ | |
882 GetWindowRect(mygui->subwindow, &rd); | |
883 | |
884 x = rd.left; | |
885 y = rd.top; | |
886 | |
887 /* restore sub window position when coming out of fullscreen */ | |
888 if(x <= 0) x = old_rect.left; | |
889 if(y <= 0) y = old_rect.top; | |
890 | |
33555 | 891 if(!guiInfo.Playing) |
23077 | 892 { |
893 window *desc = NULL; | |
894 int i; | |
895 | |
896 for (i=0; i<mygui->skin->windowcount; i++) | |
897 if(mygui->skin->windows[i]->type == wiSub) | |
898 desc = mygui->skin->windows[i]; | |
899 | |
900 rd.right = rd.left+desc->base->bitmap[0]->width; | |
901 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
902 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
903 } | |
904 else | |
905 { | |
33555 | 906 rd.right = rd.left+guiInfo.MovieWidth; |
907 rd.bottom = rd.top+guiInfo.MovieHeight; | |
23077 | 908 |
909 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
910 sub_aspect = movie_aspect; | |
911 } | |
912 | |
913 | |
914 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
915 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
916 | |
917 wp.hwnd = mygui->subwindow; | |
918 wp.x = rd.left; | |
919 wp.y = rd.top; | |
920 wp.cx = rd.right-rd.left; | |
921 wp.cy = rd.bottom-rd.top; | |
922 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
923 | |
924 /* erase the bitmap image if there's video */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
925 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
23077 | 926 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
927 | |
928 /* reset the window aspect */ | |
929 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
930 return 0; | |
931 } |