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