Mercurial > mplayer.hg
annotate gui/mplayer/mw.c @ 32847:12ae3b893c59
Remove support for skins directories using the obsolete name 'Skin'.
author | ib |
---|---|
date | Sat, 19 Feb 2011 22:02:34 +0000 |
parents | fbe5c829c69b |
children | c39348b4064a |
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" |
32467 | 42 #include "sub/sub.h" |
26382
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" |
32043
f6249bc89c38
Move extern declarations used by both mplayer.c and mencoder.c to mpcommon.h.
diego
parents:
32041
diff
changeset
|
52 #include "mpcommon.h" |
23077 | 53 |
54 #define GUI_REDRAW_WAIT 375 | |
55 | |
56 #include "play.h" | |
57 #include "widgets.h" | |
58 | |
28051 | 59 unsigned int GetTimerMS( void ); |
23077 | 60 |
61 unsigned char * mplDrawBuffer = NULL; | |
62 int mplMainRender = 1; | |
63 | |
64 int mplMainAutoPlay = 0; | |
65 int mplMiddleMenu = 0; | |
66 | |
67 int mainVisible = 1; | |
68 | |
69 int boxMoved = 0; | |
70 int sx = 0,sy = 0; | |
71 int i,pot = 0; | |
72 | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
24113
diff
changeset
|
73 #include "gui_common.h" |
23077 | 74 |
75 void mplMainDraw( void ) | |
76 { | |
77 | |
30516 | 78 if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( EXIT_QUIT ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
79 |
23077 | 80 if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible || |
81 !mainVisible ) return; | |
82 // !appMPlayer.mainWindow.Mapped ) return; | |
83 | |
84 if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose ) | |
85 { | |
86 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
87 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
88 | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23305
diff
changeset
|
89 fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize ); |
23077 | 90 Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); |
91 mplMainRender=0; | |
92 } | |
93 wsPutImage( &appMPlayer.mainWindow ); | |
94 // XFlush( wsDisplay ); | |
95 } | |
96 | |
97 static unsigned last_redraw_time = 0; | |
98 | |
99 void mplEventHandling( int msg,float param ) | |
100 { | |
101 int iparam = (int)param; | |
102 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
103 | |
104 switch( msg ) | |
105 { | |
106 // --- user events | |
107 case evExit: | |
30516 | 108 exit_player( EXIT_QUIT ); |
23077 | 109 break; |
110 | |
111 case evPlayNetwork: | |
112 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
113 gfree( (void **)&guiIntfStruct.AudioFile ); | |
114 guiIntfStruct.StreamType=STREAMTYPE_STREAM; | |
115 goto play; | |
116 case evSetURL: | |
117 gtkShow( evPlayNetwork,NULL ); | |
118 break; | |
119 | |
120 case evSetAudio: | |
121 if ( !guiIntfStruct.demuxer || audio_id == iparam ) break; | |
122 audio_id=iparam; | |
123 goto play; | |
124 | |
125 case evSetVideo: | |
126 if ( !guiIntfStruct.demuxer || video_id == iparam ) break; | |
127 video_id=iparam; | |
128 goto play; | |
129 | |
130 case evSetSubtitle: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
131 mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext); |
23077 | 132 break; |
133 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
134 #ifdef CONFIG_VCD |
23077 | 135 case evSetVCDTrack: |
136 guiIntfStruct.Track=iparam; | |
137 case evPlayVCD: | |
138 gtkSet( gtkClearStruct,0,(void *)guiALL ); | |
139 guiIntfStruct.StreamType=STREAMTYPE_VCD; | |
140 goto play; | |
141 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
142 #ifdef CONFIG_DVDREAD |
23077 | 143 case evPlayDVD: |
144 guiIntfStruct.DVD.current_title=1; | |
145 guiIntfStruct.DVD.current_chapter=1; | |
146 guiIntfStruct.DVD.current_angle=1; | |
147 play_dvd_2: | |
148 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) ); | |
149 guiIntfStruct.StreamType=STREAMTYPE_DVD; | |
150 goto play; | |
151 #endif | |
152 case evPlay: | |
153 case evPlaySwitchToPause: | |
154 play: | |
155 | |
156 if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause; | |
157 | |
158 if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) ) | |
159 { | |
160 plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL ); | |
161 plLastPlayed=next; | |
162 mplSetFileName( next->path,next->name,STREAMTYPE_FILE ); | |
163 } | |
164 | |
165 switch ( guiIntfStruct.StreamType ) | |
166 { | |
167 case STREAMTYPE_STREAM: | |
168 case STREAMTYPE_FILE: | |
169 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) ); | |
170 break; | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
171 #ifdef CONFIG_VCD |
23077 | 172 case STREAMTYPE_VCD: |
173 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) ); | |
174 if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE ); | |
175 mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD ); | |
176 if ( guiIntfStruct.Playing != 2 ) | |
177 { | |
178 if ( !guiIntfStruct.Track ) | |
179 { | |
180 if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2; | |
181 else guiIntfStruct.Track=1; | |
182 } | |
183 guiIntfStruct.DiskChanged=1; | |
184 } | |
185 break; | |
186 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
187 #ifdef CONFIG_DVDREAD |
23077 | 188 case STREAMTYPE_DVD: |
189 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); | |
190 if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); | |
191 mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); | |
192 if ( guiIntfStruct.Playing != 2 ) | |
193 { | |
194 guiIntfStruct.Title=guiIntfStruct.DVD.current_title; | |
195 guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; | |
196 guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; | |
197 guiIntfStruct.DiskChanged=1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
198 } |
23077 | 199 break; |
200 #endif | |
201 } | |
202 guiIntfStruct.NewPlay=1; | |
203 mplPlay(); | |
204 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
205 #ifdef CONFIG_DVDREAD |
23077 | 206 case evSetDVDSubtitle: |
207 dvdsub_id=iparam; | |
208 goto play_dvd_2; | |
209 break; | |
210 case evSetDVDAudio: | |
211 audio_id=iparam; | |
212 goto play_dvd_2; | |
213 break; | |
214 case evSetDVDChapter: | |
215 guiIntfStruct.DVD.current_chapter=iparam; | |
216 goto play_dvd_2; | |
217 break; | |
218 case evSetDVDTitle: | |
219 guiIntfStruct.DVD.current_title=iparam; | |
220 guiIntfStruct.DVD.current_chapter=1; | |
221 guiIntfStruct.DVD.current_angle=1; | |
222 goto play_dvd_2; | |
223 break; | |
224 #endif | |
225 | |
226 case evPause: | |
227 case evPauseSwitchToPlay: | |
228 NoPause: | |
229 mplPause(); | |
230 break; | |
231 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
232 case evStop: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
233 guiIntfStruct.Playing=guiSetStop; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
234 mplState(); |
23077 | 235 guiIntfStruct.NoWindow=False; |
236 break; | |
237 | |
238 case evLoadPlay: | |
239 mplMainAutoPlay=1; | |
240 // guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
241 case evLoad: | |
242 gtkSet( gtkDelPl,0,NULL ); | |
243 gtkShow( evLoad,NULL ); | |
244 break; | |
245 case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; | |
246 case evDropSubtitle: | |
247 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
248 guiLoadSubtitle( NULL ); | |
249 break; | |
250 case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; | |
251 case evPrev: mplPrev(); break; | |
252 case evNext: mplNext(); break; | |
253 | |
254 case evPlayList: gtkShow( evPlayList,NULL ); break; | |
255 case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; | |
256 case evAbout: gtkShow( evAbout,NULL ); break; | |
257 case evPreferences: gtkShow( evPreferences,NULL ); break; | |
258 case evEqualizer: gtkShow( evEqualizer,NULL ); break; | |
259 | |
260 case evForward10min: mplRelSeek( 600 ); break; | |
261 case evBackward10min: mplRelSeek( -600 );break; | |
262 case evForward1min: mplRelSeek( 60 ); break; | |
263 case evBackward1min: mplRelSeek( -60 ); break; | |
264 case evForward10sec: mplRelSeek( 10 ); break; | |
265 case evBackward10sec: mplRelSeek( -10 ); break; | |
266 case evSetMoviePosition: mplAbsSeek( param ); break; | |
267 | |
268 case evIncVolume: vo_x11_putkey( wsGrayMul ); break; | |
269 case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; | |
270 case evMute: mixer_mute( mixer ); break; | |
271 | |
272 case evSetVolume: | |
273 guiIntfStruct.Volume=param; | |
274 goto set_volume; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
275 case evSetBalance: |
23077 | 276 guiIntfStruct.Balance=param; |
277 set_volume: | |
278 { | |
279 float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); | |
280 float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); | |
281 if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; | |
282 if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; | |
283 // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); | |
284 mixer_setvolume( mixer,l,r ); | |
285 } | |
286 if ( osd_level ) | |
287 { | |
288 osd_visible=(GetTimerMS() + 1000) | 1; | |
289 vo_osd_progbar_type=OSD_VOLUME; | |
290 vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; | |
291 vo_osd_changed( OSDTYPE_PROGBAR ); | |
292 } | |
293 break; | |
294 | |
295 | |
296 case evIconify: | |
297 switch ( iparam ) | |
298 { | |
299 case 0: wsIconify( appMPlayer.mainWindow ); break; | |
300 case 1: wsIconify( appMPlayer.subWindow ); break; | |
301 } | |
302 break; | |
303 case evHalfSize: | |
304 btnSet( evFullScreen,btnReleased ); | |
305 if ( guiIntfStruct.Playing ) | |
306 { | |
307 if ( appMPlayer.subWindow.isFullScreen ) | |
308 { | |
309 mplFullScreen(); | |
310 } | |
311 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); | |
312 wsMoveWindow( &appMPlayer.subWindow, 0, | |
313 ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, | |
314 ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); | |
315 } | |
316 break; | |
317 case evDoubleSize: | |
318 btnSet( evFullScreen,btnReleased ); | |
319 if ( guiIntfStruct.Playing ) | |
320 { | |
321 if ( appMPlayer.subWindow.isFullScreen ) | |
322 { | |
323 mplFullScreen(); | |
324 } | |
325 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); | |
326 wsMoveWindow( &appMPlayer.subWindow, 0, | |
327 ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, | |
328 ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); | |
329 } | |
330 break; | |
331 case evNormalSize: | |
332 btnSet( evFullScreen,btnReleased ); | |
333 if ( guiIntfStruct.Playing ) | |
334 { | |
335 if ( appMPlayer.subWindow.isFullScreen ) | |
336 { | |
337 mplFullScreen(); | |
338 } | |
339 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight ); | |
340 wsMoveWindow( &appMPlayer.subWindow, 0, | |
341 ( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX, | |
342 ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY ); | |
343 break; | |
344 } else if ( !appMPlayer.subWindow.isFullScreen ) break; | |
345 case evFullScreen: | |
346 if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break; | |
347 mplFullScreen(); | |
348 if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); | |
349 else btnSet( evFullScreen,btnReleased ); | |
350 break; | |
351 | |
352 case evSetAspect: | |
353 switch ( iparam ) | |
354 { | |
355 case 2: movie_aspect=16.0f / 9.0f; break; | |
356 case 3: movie_aspect=4.0f / 3.0f; break; | |
357 case 4: movie_aspect=2.35; break; | |
358 case 1: | |
359 default: movie_aspect=-1; | |
360 } | |
361 wsClearWindow( appMPlayer.subWindow ); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
362 #ifdef CONFIG_DVDREAD |
23077 | 363 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
|
364 else |
23077 | 365 #endif |
366 guiIntfStruct.NewPlay=1; | |
367 break; | |
368 | |
369 // --- timer events | |
370 case evRedraw: | |
371 { | |
372 unsigned now = GetTimerMS(); | |
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 } |