Mercurial > mplayer.hg
annotate gui/mplayer/mw.c @ 33296:ac194a26317b
Revise keyboard control section of German man page translation.
author | ib |
---|---|
date | Fri, 06 May 2011 08:17:05 +0000 |
parents | 5f527a9a9521 |
children | 7d5fd12b86e7 |
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 <sys/stat.h> | |
24 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23154
diff
changeset
|
25 #include <string.h> |
23077 | 26 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "config.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
28 #include "gmplayer.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
29 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/skin/skin.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
32 #include "gui/wm/ws.h" |
32896 | 33 #include "gui/wm/wskeys.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 | |
33263 | 78 if ( appMPlayer.mainWindow.State == wsWindowClosed ) guiExit( 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 ); |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
90 Render( &appMPlayer.mainWindow,appMPlayer.mainItems,appMPlayer.IndexOfMainItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); |
23077 | 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: | |
33263 | 108 guiExit( 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 ) | |
33002
676e1222fb21
Start vcd:// with first title when hitting play button.
ib
parents:
32931
diff
changeset
|
179 guiIntfStruct.Track=1; |
23077 | 180 guiIntfStruct.DiskChanged=1; |
181 } | |
182 break; | |
183 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
184 #ifdef CONFIG_DVDREAD |
23077 | 185 case STREAMTYPE_DVD: |
186 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); | |
187 if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); | |
188 mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); | |
189 if ( guiIntfStruct.Playing != 2 ) | |
190 { | |
191 guiIntfStruct.Title=guiIntfStruct.DVD.current_title; | |
192 guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; | |
193 guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; | |
194 guiIntfStruct.DiskChanged=1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
195 } |
23077 | 196 break; |
197 #endif | |
198 } | |
199 guiIntfStruct.NewPlay=1; | |
200 mplPlay(); | |
201 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
202 #ifdef CONFIG_DVDREAD |
23077 | 203 case evSetDVDSubtitle: |
204 dvdsub_id=iparam; | |
205 goto play_dvd_2; | |
206 break; | |
207 case evSetDVDAudio: | |
208 audio_id=iparam; | |
209 goto play_dvd_2; | |
210 break; | |
211 case evSetDVDChapter: | |
212 guiIntfStruct.DVD.current_chapter=iparam; | |
213 goto play_dvd_2; | |
214 break; | |
215 case evSetDVDTitle: | |
216 guiIntfStruct.DVD.current_title=iparam; | |
217 guiIntfStruct.DVD.current_chapter=1; | |
218 guiIntfStruct.DVD.current_angle=1; | |
219 goto play_dvd_2; | |
220 break; | |
221 #endif | |
222 | |
223 case evPause: | |
224 case evPauseSwitchToPlay: | |
225 NoPause: | |
226 mplPause(); | |
227 break; | |
228 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
229 case evStop: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
230 guiIntfStruct.Playing=guiSetStop; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
231 mplState(); |
23077 | 232 guiIntfStruct.NoWindow=False; |
233 break; | |
234 | |
235 case evLoadPlay: | |
236 mplMainAutoPlay=1; | |
237 // guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
238 case evLoad: | |
239 gtkSet( gtkDelPl,0,NULL ); | |
240 gtkShow( evLoad,NULL ); | |
241 break; | |
242 case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; | |
243 case evDropSubtitle: | |
244 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
245 guiLoadSubtitle( NULL ); | |
246 break; | |
247 case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; | |
248 case evPrev: mplPrev(); break; | |
249 case evNext: mplNext(); break; | |
250 | |
251 case evPlayList: gtkShow( evPlayList,NULL ); break; | |
252 case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; | |
253 case evAbout: gtkShow( evAbout,NULL ); break; | |
254 case evPreferences: gtkShow( evPreferences,NULL ); break; | |
255 case evEqualizer: gtkShow( evEqualizer,NULL ); break; | |
256 | |
257 case evForward10min: mplRelSeek( 600 ); break; | |
258 case evBackward10min: mplRelSeek( -600 );break; | |
259 case evForward1min: mplRelSeek( 60 ); break; | |
260 case evBackward1min: mplRelSeek( -60 ); break; | |
261 case evForward10sec: mplRelSeek( 10 ); break; | |
262 case evBackward10sec: mplRelSeek( -10 ); break; | |
263 case evSetMoviePosition: mplAbsSeek( param ); break; | |
264 | |
265 case evIncVolume: vo_x11_putkey( wsGrayMul ); break; | |
266 case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; | |
267 case evMute: mixer_mute( mixer ); break; | |
268 | |
269 case evSetVolume: | |
270 guiIntfStruct.Volume=param; | |
271 goto set_volume; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
272 case evSetBalance: |
23077 | 273 guiIntfStruct.Balance=param; |
274 set_volume: | |
275 { | |
276 float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); | |
277 float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); | |
278 if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; | |
279 if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; | |
280 // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); | |
281 mixer_setvolume( mixer,l,r ); | |
282 } | |
283 if ( osd_level ) | |
284 { | |
285 osd_visible=(GetTimerMS() + 1000) | 1; | |
286 vo_osd_progbar_type=OSD_VOLUME; | |
287 vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; | |
288 vo_osd_changed( OSDTYPE_PROGBAR ); | |
289 } | |
290 break; | |
291 | |
292 | |
293 case evIconify: | |
294 switch ( iparam ) | |
295 { | |
296 case 0: wsIconify( appMPlayer.mainWindow ); break; | |
297 case 1: wsIconify( appMPlayer.subWindow ); break; | |
298 } | |
299 break; | |
300 case evHalfSize: | |
301 btnSet( evFullScreen,btnReleased ); | |
302 if ( guiIntfStruct.Playing ) | |
303 { | |
304 if ( appMPlayer.subWindow.isFullScreen ) | |
305 { | |
306 mplFullScreen(); | |
307 } | |
308 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); | |
309 wsMoveWindow( &appMPlayer.subWindow, 0, | |
310 ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, | |
311 ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); | |
312 } | |
313 break; | |
314 case evDoubleSize: | |
315 btnSet( evFullScreen,btnReleased ); | |
316 if ( guiIntfStruct.Playing ) | |
317 { | |
318 if ( appMPlayer.subWindow.isFullScreen ) | |
319 { | |
320 mplFullScreen(); | |
321 } | |
322 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); | |
323 wsMoveWindow( &appMPlayer.subWindow, 0, | |
324 ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, | |
325 ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); | |
326 } | |
327 break; | |
328 case evNormalSize: | |
329 btnSet( evFullScreen,btnReleased ); | |
330 if ( guiIntfStruct.Playing ) | |
331 { | |
332 if ( appMPlayer.subWindow.isFullScreen ) | |
333 { | |
334 mplFullScreen(); | |
335 } | |
336 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight ); | |
337 wsMoveWindow( &appMPlayer.subWindow, 0, | |
338 ( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX, | |
339 ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY ); | |
340 break; | |
341 } else if ( !appMPlayer.subWindow.isFullScreen ) break; | |
342 case evFullScreen: | |
343 if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break; | |
344 mplFullScreen(); | |
345 if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); | |
346 else btnSet( evFullScreen,btnReleased ); | |
347 break; | |
348 | |
349 case evSetAspect: | |
350 switch ( iparam ) | |
351 { | |
352 case 2: movie_aspect=16.0f / 9.0f; break; | |
353 case 3: movie_aspect=4.0f / 3.0f; break; | |
354 case 4: movie_aspect=2.35; break; | |
355 case 1: | |
356 default: movie_aspect=-1; | |
357 } | |
358 wsClearWindow( appMPlayer.subWindow ); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
359 #ifdef CONFIG_DVDREAD |
23077 | 360 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
|
361 else |
23077 | 362 #endif |
363 guiIntfStruct.NewPlay=1; | |
364 break; | |
365 | |
366 // --- timer events | |
367 case evRedraw: | |
368 { | |
369 unsigned now = GetTimerMS(); | |
370 if ((now > last_redraw_time) && | |
371 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
372 !mplPBFade) | |
373 break; | |
374 last_redraw_time = now; | |
375 } | |
376 mplMainRender=1; | |
377 wsPostRedisplay( &appMPlayer.mainWindow ); | |
378 wsPostRedisplay( &appMPlayer.barWindow ); | |
379 break; | |
380 // --- system events | |
381 #ifdef MP_DEBUG | |
382 case evNone: | |
383 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" ); | |
384 break; | |
385 default: | |
386 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param ); | |
387 break; | |
388 #endif | |
389 } | |
390 } | |
391 | |
392 void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY ) | |
393 { | |
394 static int itemtype = 0; | |
395 int i; | |
396 wItem * item = NULL; | |
397 float value = 0.0f; | |
398 | |
399 static int SelectedItem = -1; | |
400 int currentselected = -1; | |
401 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
402 for ( i=0;i <= appMPlayer.IndexOfMainItems;i++ ) |
32912 | 403 if ( ( appMPlayer.mainItems[i].pressed != btnDisabled )&& |
404 ( 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 | 405 { currentselected=i; break; } |
406 | |
407 switch ( Button ) | |
408 { | |
409 case wsPMMouseButton: | |
410 gtkShow( evHidePopUpMenu,NULL ); | |
411 mplShowMenu( RX,RY ); | |
412 itemtype=itPRMButton; | |
413 break; | |
414 case wsRMMouseButton: | |
415 mplHideMenu( RX,RY,0 ); | |
416 break; | |
417 | |
418 case wsPLMouseButton: | |
419 gtkShow( evHidePopUpMenu,NULL ); | |
420 sx=X; sy=Y; boxMoved=1; itemtype=itPLMButton; | |
421 SelectedItem=currentselected; | |
422 if ( SelectedItem == -1 ) break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
423 boxMoved=0; |
32912 | 424 item=&appMPlayer.mainItems[SelectedItem]; |
23077 | 425 itemtype=item->type; |
426 item->pressed=btnPressed; | |
427 switch( item->type ) | |
428 { | |
429 case itButton: | |
430 if ( ( SelectedItem > -1 ) && | |
32911 | 431 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
432 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 433 { item->pressed=btnDisabled; } |
434 break; | |
435 } | |
436 break; | |
437 case wsRLMouseButton: | |
438 boxMoved=0; | |
33107 | 439 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
440 { | |
33108 | 441 item=&appMPlayer.mainItems[SelectedItem]; |
442 item->pressed=btnReleased; | |
33107 | 443 } |
23077 | 444 SelectedItem=-1; |
445 if ( currentselected == - 1 ) { itemtype=0; break; } | |
446 value=0; | |
447 switch( itemtype ) | |
448 { | |
449 case itPotmeter: | |
450 case itHPotmeter: | |
32911 | 451 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
452 mplEventHandling( item->message,item->value ); | |
23077 | 453 value=item->value; |
454 break; | |
455 case itVPotmeter: | |
32911 | 456 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
457 mplEventHandling( item->message,item->value ); | |
23077 | 458 value=item->value; |
459 break; | |
460 } | |
32911 | 461 mplEventHandling( item->message,value ); |
23077 | 462 itemtype=0; |
463 break; | |
464 | |
465 case wsRRMouseButton: | |
466 gtkShow( evShowPopUpMenu,NULL ); | |
467 break; | |
468 | |
469 // --- rolled mouse ... de szar :))) | |
470 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
471 case wsP4MouseButton: value= 2.5f; | |
472 rollerhandled: | |
32912 | 473 item=&appMPlayer.mainItems[currentselected]; |
23077 | 474 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) |
475 { | |
476 item->value+=value; | |
32911 | 477 btnModify( item->message,item->value ); |
478 mplEventHandling( item->message,item->value ); | |
23077 | 479 } |
480 break; | |
481 | |
482 // --- moving | |
483 case wsMoveMouse: | |
32912 | 484 item=&appMPlayer.mainItems[SelectedItem]; |
23077 | 485 switch ( itemtype ) |
486 { | |
487 case itPLMButton: | |
488 wsMoveWindow( &appMPlayer.mainWindow,False,RX - abs( sx ),RY - abs( sy ) ); | |
489 mplMainRender=0; | |
490 break; | |
491 case itPRMButton: | |
492 mplMenuMouseHandle( X,Y,RX,RY ); | |
493 break; | |
494 case itPotmeter: | |
495 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
496 goto potihandled; | |
497 case itVPotmeter: | |
498 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
499 goto potihandled; | |
500 case itHPotmeter: | |
501 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
502 potihandled: | |
503 if ( item->value > 100.0f ) item->value=100.0f; | |
504 if ( item->value < 0.0f ) item->value=0.0f; | |
32911 | 505 mplEventHandling( item->message,item->value ); |
23077 | 506 break; |
507 } | |
508 break; | |
509 } | |
510 } | |
511 | |
512 int keyPressed = 0; | |
513 | |
514 void mplMainKeyHandle( int KeyCode,int Type,int Key ) | |
515 { | |
516 int msg = evNone; | |
517 | |
518 if ( Type != wsKeyPressed ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
519 |
23077 | 520 if ( !Key ) |
521 { | |
522 switch ( KeyCode ) | |
523 { | |
524 case wsXFMMPrev: msg=evPrev; break; | |
525 case wsXFMMStop: msg=evStop; break; | |
526 case wsXFMMPlay: msg=evPlaySwitchToPause; break; | |
527 case wsXFMMNext: msg=evNext; break; | |
528 case wsXFMMVolUp: msg=evIncVolume; break; | |
529 case wsXFMMVolDown: msg=evDecVolume; break; | |
530 case wsXFMMMute: msg=evMute; break; | |
531 } | |
532 } | |
533 else | |
534 { | |
535 switch ( Key ) | |
536 { | |
537 case wsEnter: msg=evPlay; break; | |
538 case wsXF86LowerVolume: msg=evDecVolume; break; | |
539 case wsXF86RaiseVolume: msg=evIncVolume; break; | |
540 case wsXF86Mute: msg=evMute; break; | |
541 case wsXF86Play: msg=evPlaySwitchToPause; break; | |
542 case wsXF86Stop: msg=evStop; break; | |
543 case wsXF86Prev: msg=evPrev; break; | |
544 case wsXF86Next: msg=evNext; break; | |
545 case wsXF86Media: msg=evLoad; break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
546 case wsEscape: |
23077 | 547 if ( appMPlayer.subWindow.isFullScreen ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
548 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
549 if ( guiIntfStruct.event_struct ) ((XEvent *)guiIntfStruct.event_struct)->type=None; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
550 mplEventHandling( evNormalSize,0 ); |
23077 | 551 return; |
552 } | |
553 default: vo_x11_putkey( Key ); return; | |
554 } | |
555 } | |
556 if ( msg != evNone ) mplEventHandling( msg,0 ); | |
557 } | |
558 | |
559 /* this will be used to handle Drag&Drop files */ | |
560 void mplDandDHandler(int num,char** files) | |
561 { | |
562 struct stat buf; | |
563 int f = 0; | |
564 | |
565 char* subtitles = NULL; | |
566 char* filename = NULL; | |
567 | |
568 if (num <= 0) | |
569 return; | |
570 | |
571 | |
572 /* now fill it with new items */ | |
573 for(f=0; f < num; f++){ | |
574 char* str = strdup( files[f] ); | |
575 plItem* item; | |
576 | |
24086
f5b32d12b691
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
iive
parents:
23457
diff
changeset
|
577 url_unescape_string(str, files[f]); |
23077 | 578 |
579 if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { | |
580 /* this is not a directory so try to play it */ | |
581 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
|
582 |
23077 | 583 /* check if it is a subtitle file */ |
584 { | |
585 char* ext = strrchr(str,'.'); | |
586 if (ext) { | |
587 static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/"; | |
588 char* type; | |
589 int len; | |
590 if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\ | |
591 (type-supported)%4 == 0 && *(type+len) == '/'){ | |
592 /* handle subtitle file */ | |
593 gfree((void**)&subtitles); | |
594 subtitles = str; | |
595 continue; | |
596 } | |
597 } | |
598 } | |
599 | |
600 /* clear playlist */ | |
601 if (filename == NULL) { | |
602 filename = files[f]; | |
603 gtkSet(gtkDelPl,0,NULL); | |
604 } | |
605 | |
606 item = calloc(1,sizeof(plItem)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
607 |
23077 | 608 /* FIXME: decompose file name ? */ |
609 /* yes -- Pontscho */ | |
610 if ( strrchr( str,'/' ) ) { | |
611 char * s = strrchr( str,'/' ); *s=0; s++; | |
612 item->name = gstrdup( s ); | |
613 item->path = gstrdup( str ); | |
614 } else { | |
615 item->name = strdup(str); | |
616 item->path = strdup(""); | |
617 } | |
618 gtkSet(gtkAddPlItem,0,(void*)item); | |
619 } else { | |
620 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str ); | |
621 } | |
622 free( str ); | |
623 } | |
624 | |
625 if (filename) { | |
626 mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
627 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 ); | |
628 mplEventHandling( evPlay,0 ); | |
629 } | |
630 if (subtitles) { | |
631 gfree((void**)&guiIntfStruct.Subtitlename); | |
632 guiIntfStruct.Subtitlename = subtitles; | |
633 guiLoadSubtitle(guiIntfStruct.Subtitlename); | |
634 } | |
635 } |