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