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