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