Mercurial > mplayer.hg
annotate gui/mplayer/mw.c @ 33006:66d908462d76
Initialize guiIntfStruct.VCDTracks.
The check for stream->priv has become unnecessary.
The initialization also provides for a stream_control() failure.
author | ib |
---|---|
date | Mon, 21 Mar 2011 19:33:22 +0000 |
parents | 676e1222fb21 |
children | eda3df3e4a9d |
rev | line source |
---|---|
26458 | 1 /* |
2 * main window | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
23077 | 20 |
21 #include <stdlib.h> | |
22 #include <stdio.h> | |
23 #include <inttypes.h> | |
24 #include <sys/stat.h> | |
25 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23154
diff
changeset
|
26 #include <string.h> |
23077 | 27 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
28 #include "config.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
29 #include "gmplayer.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
32 #include "gui/skin/skin.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
33 #include "gui/wm/ws.h" |
32896 | 34 #include "gui/wm/wskeys.h" |
23077 | 35 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
36 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
37 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/fastmemcpy.h" |
23077 | 39 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
40 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
41 #include "stream/url.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
42 #include "mixer.h" |
32467 | 43 #include "sub/sub.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
44 #include "access_mpcontext.h" |
23077 | 45 |
30537
7bebe34b6ad2
Move movie_aspect extern declaration to libmpcodecs/vd.h.
diego
parents:
30516
diff
changeset
|
46 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
47 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
48 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
49 #include "codec-cfg.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
50 #include "m_option.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
51 #include "m_property.h" |
30516 | 52 #include "mp_core.h" |
32043
f6249bc89c38
Move extern declarations used by both mplayer.c and mencoder.c to mpcommon.h.
diego
parents:
32041
diff
changeset
|
53 #include "mpcommon.h" |
23077 | 54 |
55 #define GUI_REDRAW_WAIT 375 | |
56 | |
57 #include "play.h" | |
58 #include "widgets.h" | |
59 | |
28051 | 60 unsigned int GetTimerMS( void ); |
23077 | 61 |
62 unsigned char * mplDrawBuffer = NULL; | |
63 int mplMainRender = 1; | |
64 | |
65 int mplMainAutoPlay = 0; | |
66 int mplMiddleMenu = 0; | |
67 | |
68 int mainVisible = 1; | |
69 | |
70 int boxMoved = 0; | |
71 int sx = 0,sy = 0; | |
72 int i,pot = 0; | |
73 | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
24113
diff
changeset
|
74 #include "gui_common.h" |
23077 | 75 |
76 void mplMainDraw( void ) | |
77 { | |
78 | |
30516 | 79 if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( EXIT_QUIT ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
80 |
23077 | 81 if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible || |
82 !mainVisible ) return; | |
83 // !appMPlayer.mainWindow.Mapped ) return; | |
84 | |
85 if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose ) | |
86 { | |
87 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
88 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
89 | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23305
diff
changeset
|
90 fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize ); |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
91 Render( &appMPlayer.mainWindow,appMPlayer.mainItems,appMPlayer.IndexOfMainItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); |
23077 | 92 mplMainRender=0; |
93 } | |
94 wsPutImage( &appMPlayer.mainWindow ); | |
95 // XFlush( wsDisplay ); | |
96 } | |
97 | |
98 static unsigned last_redraw_time = 0; | |
99 | |
100 void mplEventHandling( int msg,float param ) | |
101 { | |
102 int iparam = (int)param; | |
103 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
104 | |
105 switch( msg ) | |
106 { | |
107 // --- user events | |
108 case evExit: | |
30516 | 109 exit_player( EXIT_QUIT ); |
23077 | 110 break; |
111 | |
112 case evPlayNetwork: | |
113 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
114 gfree( (void **)&guiIntfStruct.AudioFile ); | |
115 guiIntfStruct.StreamType=STREAMTYPE_STREAM; | |
116 goto play; | |
117 case evSetURL: | |
118 gtkShow( evPlayNetwork,NULL ); | |
119 break; | |
120 | |
121 case evSetAudio: | |
122 if ( !guiIntfStruct.demuxer || audio_id == iparam ) break; | |
123 audio_id=iparam; | |
124 goto play; | |
125 | |
126 case evSetVideo: | |
127 if ( !guiIntfStruct.demuxer || video_id == iparam ) break; | |
128 video_id=iparam; | |
129 goto play; | |
130 | |
131 case evSetSubtitle: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
132 mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext); |
23077 | 133 break; |
134 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
135 #ifdef CONFIG_VCD |
23077 | 136 case evSetVCDTrack: |
137 guiIntfStruct.Track=iparam; | |
138 case evPlayVCD: | |
139 gtkSet( gtkClearStruct,0,(void *)guiALL ); | |
140 guiIntfStruct.StreamType=STREAMTYPE_VCD; | |
141 goto play; | |
142 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
143 #ifdef CONFIG_DVDREAD |
23077 | 144 case evPlayDVD: |
145 guiIntfStruct.DVD.current_title=1; | |
146 guiIntfStruct.DVD.current_chapter=1; | |
147 guiIntfStruct.DVD.current_angle=1; | |
148 play_dvd_2: | |
149 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) ); | |
150 guiIntfStruct.StreamType=STREAMTYPE_DVD; | |
151 goto play; | |
152 #endif | |
153 case evPlay: | |
154 case evPlaySwitchToPause: | |
155 play: | |
156 | |
157 if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause; | |
158 | |
159 if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) ) | |
160 { | |
161 plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL ); | |
162 plLastPlayed=next; | |
163 mplSetFileName( next->path,next->name,STREAMTYPE_FILE ); | |
164 } | |
165 | |
166 switch ( guiIntfStruct.StreamType ) | |
167 { | |
168 case STREAMTYPE_STREAM: | |
169 case STREAMTYPE_FILE: | |
170 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) ); | |
171 break; | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
172 #ifdef CONFIG_VCD |
23077 | 173 case STREAMTYPE_VCD: |
174 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) ); | |
175 if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE ); | |
176 mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD ); | |
177 if ( guiIntfStruct.Playing != 2 ) | |
178 { | |
179 if ( !guiIntfStruct.Track ) | |
33002
676e1222fb21
Start vcd:// with first title when hitting play button.
ib
parents:
32931
diff
changeset
|
180 guiIntfStruct.Track=1; |
23077 | 181 guiIntfStruct.DiskChanged=1; |
182 } | |
183 break; | |
184 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
185 #ifdef CONFIG_DVDREAD |
23077 | 186 case STREAMTYPE_DVD: |
187 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); | |
188 if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); | |
189 mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); | |
190 if ( guiIntfStruct.Playing != 2 ) | |
191 { | |
192 guiIntfStruct.Title=guiIntfStruct.DVD.current_title; | |
193 guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; | |
194 guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; | |
195 guiIntfStruct.DiskChanged=1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
196 } |
23077 | 197 break; |
198 #endif | |
199 } | |
200 guiIntfStruct.NewPlay=1; | |
201 mplPlay(); | |
202 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
203 #ifdef CONFIG_DVDREAD |
23077 | 204 case evSetDVDSubtitle: |
205 dvdsub_id=iparam; | |
206 goto play_dvd_2; | |
207 break; | |
208 case evSetDVDAudio: | |
209 audio_id=iparam; | |
210 goto play_dvd_2; | |
211 break; | |
212 case evSetDVDChapter: | |
213 guiIntfStruct.DVD.current_chapter=iparam; | |
214 goto play_dvd_2; | |
215 break; | |
216 case evSetDVDTitle: | |
217 guiIntfStruct.DVD.current_title=iparam; | |
218 guiIntfStruct.DVD.current_chapter=1; | |
219 guiIntfStruct.DVD.current_angle=1; | |
220 goto play_dvd_2; | |
221 break; | |
222 #endif | |
223 | |
224 case evPause: | |
225 case evPauseSwitchToPlay: | |
226 NoPause: | |
227 mplPause(); | |
228 break; | |
229 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
230 case evStop: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
231 guiIntfStruct.Playing=guiSetStop; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
232 mplState(); |
23077 | 233 guiIntfStruct.NoWindow=False; |
234 break; | |
235 | |
236 case evLoadPlay: | |
237 mplMainAutoPlay=1; | |
238 // guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
239 case evLoad: | |
240 gtkSet( gtkDelPl,0,NULL ); | |
241 gtkShow( evLoad,NULL ); | |
242 break; | |
243 case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; | |
244 case evDropSubtitle: | |
245 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
246 guiLoadSubtitle( NULL ); | |
247 break; | |
248 case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; | |
249 case evPrev: mplPrev(); break; | |
250 case evNext: mplNext(); break; | |
251 | |
252 case evPlayList: gtkShow( evPlayList,NULL ); break; | |
253 case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; | |
254 case evAbout: gtkShow( evAbout,NULL ); break; | |
255 case evPreferences: gtkShow( evPreferences,NULL ); break; | |
256 case evEqualizer: gtkShow( evEqualizer,NULL ); break; | |
257 | |
258 case evForward10min: mplRelSeek( 600 ); break; | |
259 case evBackward10min: mplRelSeek( -600 );break; | |
260 case evForward1min: mplRelSeek( 60 ); break; | |
261 case evBackward1min: mplRelSeek( -60 ); break; | |
262 case evForward10sec: mplRelSeek( 10 ); break; | |
263 case evBackward10sec: mplRelSeek( -10 ); break; | |
264 case evSetMoviePosition: mplAbsSeek( param ); break; | |
265 | |
266 case evIncVolume: vo_x11_putkey( wsGrayMul ); break; | |
267 case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; | |
268 case evMute: mixer_mute( mixer ); break; | |
269 | |
270 case evSetVolume: | |
271 guiIntfStruct.Volume=param; | |
272 goto set_volume; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
273 case evSetBalance: |
23077 | 274 guiIntfStruct.Balance=param; |
275 set_volume: | |
276 { | |
277 float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); | |
278 float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); | |
279 if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; | |
280 if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; | |
281 // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); | |
282 mixer_setvolume( mixer,l,r ); | |
283 } | |
284 if ( osd_level ) | |
285 { | |
286 osd_visible=(GetTimerMS() + 1000) | 1; | |
287 vo_osd_progbar_type=OSD_VOLUME; | |
288 vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; | |
289 vo_osd_changed( OSDTYPE_PROGBAR ); | |
290 } | |
291 break; | |
292 | |
293 | |
294 case evIconify: | |
295 switch ( iparam ) | |
296 { | |
297 case 0: wsIconify( appMPlayer.mainWindow ); break; | |
298 case 1: wsIconify( appMPlayer.subWindow ); break; | |
299 } | |
300 break; | |
301 case evHalfSize: | |
302 btnSet( evFullScreen,btnReleased ); | |
303 if ( guiIntfStruct.Playing ) | |
304 { | |
305 if ( appMPlayer.subWindow.isFullScreen ) | |
306 { | |
307 mplFullScreen(); | |
308 } | |
309 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); | |
310 wsMoveWindow( &appMPlayer.subWindow, 0, | |
311 ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, | |
312 ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); | |
313 } | |
314 break; | |
315 case evDoubleSize: | |
316 btnSet( evFullScreen,btnReleased ); | |
317 if ( guiIntfStruct.Playing ) | |
318 { | |
319 if ( appMPlayer.subWindow.isFullScreen ) | |
320 { | |
321 mplFullScreen(); | |
322 } | |
323 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); | |
324 wsMoveWindow( &appMPlayer.subWindow, 0, | |
325 ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, | |
326 ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); | |
327 } | |
328 break; | |
329 case evNormalSize: | |
330 btnSet( evFullScreen,btnReleased ); | |
331 if ( guiIntfStruct.Playing ) | |
332 { | |
333 if ( appMPlayer.subWindow.isFullScreen ) | |
334 { | |
335 mplFullScreen(); | |
336 } | |
337 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight ); | |
338 wsMoveWindow( &appMPlayer.subWindow, 0, | |
339 ( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX, | |
340 ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY ); | |
341 break; | |
342 } else if ( !appMPlayer.subWindow.isFullScreen ) break; | |
343 case evFullScreen: | |
344 if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break; | |
345 mplFullScreen(); | |
346 if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); | |
347 else btnSet( evFullScreen,btnReleased ); | |
348 break; | |
349 | |
350 case evSetAspect: | |
351 switch ( iparam ) | |
352 { | |
353 case 2: movie_aspect=16.0f / 9.0f; break; | |
354 case 3: movie_aspect=4.0f / 3.0f; break; | |
355 case 4: movie_aspect=2.35; break; | |
356 case 1: | |
357 default: movie_aspect=-1; | |
358 } | |
359 wsClearWindow( appMPlayer.subWindow ); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
360 #ifdef CONFIG_DVDREAD |
23077 | 361 if ( guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_VCD ) goto play_dvd_2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
362 else |
23077 | 363 #endif |
364 guiIntfStruct.NewPlay=1; | |
365 break; | |
366 | |
367 // --- timer events | |
368 case evRedraw: | |
369 { | |
370 unsigned now = GetTimerMS(); | |
371 if ((now > last_redraw_time) && | |
372 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
373 !mplPBFade) | |
374 break; | |
375 last_redraw_time = now; | |
376 } | |
377 mplMainRender=1; | |
378 wsPostRedisplay( &appMPlayer.mainWindow ); | |
379 wsPostRedisplay( &appMPlayer.barWindow ); | |
380 break; | |
381 // --- system events | |
382 #ifdef MP_DEBUG | |
383 case evNone: | |
384 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" ); | |
385 break; | |
386 default: | |
387 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param ); | |
388 break; | |
389 #endif | |
390 } | |
391 } | |
392 | |
393 void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY ) | |
394 { | |
395 static int itemtype = 0; | |
396 int i; | |
397 wItem * item = NULL; | |
398 float value = 0.0f; | |
399 | |
400 static int SelectedItem = -1; | |
401 int currentselected = -1; | |
402 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
403 for ( i=0;i <= appMPlayer.IndexOfMainItems;i++ ) |
32912 | 404 if ( ( appMPlayer.mainItems[i].pressed != btnDisabled )&& |
405 ( wgIsRect( X,Y,appMPlayer.mainItems[i].x,appMPlayer.mainItems[i].y,appMPlayer.mainItems[i].x+appMPlayer.mainItems[i].width,appMPlayer.mainItems[i].y+appMPlayer.mainItems[i].height ) ) ) | |
23077 | 406 { currentselected=i; break; } |
407 | |
408 switch ( Button ) | |
409 { | |
410 case wsPMMouseButton: | |
411 gtkShow( evHidePopUpMenu,NULL ); | |
412 mplShowMenu( RX,RY ); | |
413 itemtype=itPRMButton; | |
414 break; | |
415 case wsRMMouseButton: | |
416 mplHideMenu( RX,RY,0 ); | |
417 break; | |
418 | |
419 case wsPLMouseButton: | |
420 gtkShow( evHidePopUpMenu,NULL ); | |
421 sx=X; sy=Y; boxMoved=1; itemtype=itPLMButton; | |
422 SelectedItem=currentselected; | |
423 if ( SelectedItem == -1 ) break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
424 boxMoved=0; |
32912 | 425 item=&appMPlayer.mainItems[SelectedItem]; |
23077 | 426 itemtype=item->type; |
427 item->pressed=btnPressed; | |
428 switch( item->type ) | |
429 { | |
430 case itButton: | |
431 if ( ( SelectedItem > -1 ) && | |
32911 | 432 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
433 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 434 { item->pressed=btnDisabled; } |
435 break; | |
436 } | |
437 break; | |
438 case wsRLMouseButton: | |
439 boxMoved=0; | |
32912 | 440 item=&appMPlayer.mainItems[SelectedItem]; |
23077 | 441 item->pressed=btnReleased; |
442 SelectedItem=-1; | |
443 if ( currentselected == - 1 ) { itemtype=0; break; } | |
444 value=0; | |
445 switch( itemtype ) | |
446 { | |
447 case itPotmeter: | |
448 case itHPotmeter: | |
32911 | 449 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
450 mplEventHandling( item->message,item->value ); | |
23077 | 451 value=item->value; |
452 break; | |
453 case itVPotmeter: | |
32911 | 454 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
455 mplEventHandling( item->message,item->value ); | |
23077 | 456 value=item->value; |
457 break; | |
458 } | |
32911 | 459 mplEventHandling( item->message,value ); |
23077 | 460 itemtype=0; |
461 break; | |
462 | |
463 case wsRRMouseButton: | |
464 gtkShow( evShowPopUpMenu,NULL ); | |
465 break; | |
466 | |
467 // --- rolled mouse ... de szar :))) | |
468 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
469 case wsP4MouseButton: value= 2.5f; | |
470 rollerhandled: | |
32912 | 471 item=&appMPlayer.mainItems[currentselected]; |
23077 | 472 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) |
473 { | |
474 item->value+=value; | |
32911 | 475 btnModify( item->message,item->value ); |
476 mplEventHandling( item->message,item->value ); | |
23077 | 477 } |
478 break; | |
479 | |
480 // --- moving | |
481 case wsMoveMouse: | |
32912 | 482 item=&appMPlayer.mainItems[SelectedItem]; |
23077 | 483 switch ( itemtype ) |
484 { | |
485 case itPLMButton: | |
486 wsMoveWindow( &appMPlayer.mainWindow,False,RX - abs( sx ),RY - abs( sy ) ); | |
487 mplMainRender=0; | |
488 break; | |
489 case itPRMButton: | |
490 mplMenuMouseHandle( X,Y,RX,RY ); | |
491 break; | |
492 case itPotmeter: | |
493 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
494 goto potihandled; | |
495 case itVPotmeter: | |
496 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
497 goto potihandled; | |
498 case itHPotmeter: | |
499 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
500 potihandled: | |
501 if ( item->value > 100.0f ) item->value=100.0f; | |
502 if ( item->value < 0.0f ) item->value=0.0f; | |
32911 | 503 mplEventHandling( item->message,item->value ); |
23077 | 504 break; |
505 } | |
506 break; | |
507 } | |
508 } | |
509 | |
510 int keyPressed = 0; | |
511 | |
512 void mplMainKeyHandle( int KeyCode,int Type,int Key ) | |
513 { | |
514 int msg = evNone; | |
515 | |
516 if ( Type != wsKeyPressed ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
517 |
23077 | 518 if ( !Key ) |
519 { | |
520 switch ( KeyCode ) | |
521 { | |
522 case wsXFMMPrev: msg=evPrev; break; | |
523 case wsXFMMStop: msg=evStop; break; | |
524 case wsXFMMPlay: msg=evPlaySwitchToPause; break; | |
525 case wsXFMMNext: msg=evNext; break; | |
526 case wsXFMMVolUp: msg=evIncVolume; break; | |
527 case wsXFMMVolDown: msg=evDecVolume; break; | |
528 case wsXFMMMute: msg=evMute; break; | |
529 } | |
530 } | |
531 else | |
532 { | |
533 switch ( Key ) | |
534 { | |
535 case wsEnter: msg=evPlay; break; | |
536 case wsXF86LowerVolume: msg=evDecVolume; break; | |
537 case wsXF86RaiseVolume: msg=evIncVolume; break; | |
538 case wsXF86Mute: msg=evMute; break; | |
539 case wsXF86Play: msg=evPlaySwitchToPause; break; | |
540 case wsXF86Stop: msg=evStop; break; | |
541 case wsXF86Prev: msg=evPrev; break; | |
542 case wsXF86Next: msg=evNext; break; | |
543 case wsXF86Media: msg=evLoad; break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
544 case wsEscape: |
23077 | 545 if ( appMPlayer.subWindow.isFullScreen ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
546 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
547 if ( guiIntfStruct.event_struct ) ((XEvent *)guiIntfStruct.event_struct)->type=None; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
548 mplEventHandling( evNormalSize,0 ); |
23077 | 549 return; |
550 } | |
551 default: vo_x11_putkey( Key ); return; | |
552 } | |
553 } | |
554 if ( msg != evNone ) mplEventHandling( msg,0 ); | |
555 } | |
556 | |
557 /* this will be used to handle Drag&Drop files */ | |
558 void mplDandDHandler(int num,char** files) | |
559 { | |
560 struct stat buf; | |
561 int f = 0; | |
562 | |
563 char* subtitles = NULL; | |
564 char* filename = NULL; | |
565 | |
566 if (num <= 0) | |
567 return; | |
568 | |
569 | |
570 /* now fill it with new items */ | |
571 for(f=0; f < num; f++){ | |
572 char* str = strdup( files[f] ); | |
573 plItem* item; | |
574 | |
24086
f5b32d12b691
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
iive
parents:
23457
diff
changeset
|
575 url_unescape_string(str, files[f]); |
23077 | 576 |
577 if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { | |
578 /* this is not a directory so try to play it */ | |
579 mp_msg( MSGT_GPLAYER,MSGL_V,"Received D&D %s\n",str ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
580 |
23077 | 581 /* check if it is a subtitle file */ |
582 { | |
583 char* ext = strrchr(str,'.'); | |
584 if (ext) { | |
585 static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/"; | |
586 char* type; | |
587 int len; | |
588 if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\ | |
589 (type-supported)%4 == 0 && *(type+len) == '/'){ | |
590 /* handle subtitle file */ | |
591 gfree((void**)&subtitles); | |
592 subtitles = str; | |
593 continue; | |
594 } | |
595 } | |
596 } | |
597 | |
598 /* clear playlist */ | |
599 if (filename == NULL) { | |
600 filename = files[f]; | |
601 gtkSet(gtkDelPl,0,NULL); | |
602 } | |
603 | |
604 item = calloc(1,sizeof(plItem)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
605 |
23077 | 606 /* FIXME: decompose file name ? */ |
607 /* yes -- Pontscho */ | |
608 if ( strrchr( str,'/' ) ) { | |
609 char * s = strrchr( str,'/' ); *s=0; s++; | |
610 item->name = gstrdup( s ); | |
611 item->path = gstrdup( str ); | |
612 } else { | |
613 item->name = strdup(str); | |
614 item->path = strdup(""); | |
615 } | |
616 gtkSet(gtkAddPlItem,0,(void*)item); | |
617 } else { | |
618 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str ); | |
619 } | |
620 free( str ); | |
621 } | |
622 | |
623 if (filename) { | |
624 mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
625 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 ); | |
626 mplEventHandling( evPlay,0 ); | |
627 } | |
628 if (subtitles) { | |
629 gfree((void**)&guiIntfStruct.Subtitlename); | |
630 guiIntfStruct.Subtitlename = subtitles; | |
631 guiLoadSubtitle(guiIntfStruct.Subtitlename); | |
632 } | |
633 } |