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