Mercurial > mplayer.hg
annotate gui/interface.c @ 23651:604f56414432
Lots of cosmetics for gl2
author | reimar |
---|---|
date | Tue, 26 Jun 2007 16:33:43 +0000 |
parents | c1221a031ab7 |
children | 1cb14b091f46 |
rev | line source |
---|---|
23077 | 1 |
2 #include <inttypes.h> | |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
5 #include <string.h> | |
6 #include <sys/types.h> | |
7 | |
8 #include "wm/ws.h" | |
9 #include "wm/wsxdnd.h" | |
10 #include "interface.h" | |
11 #include "skin/skin.h" | |
12 | |
13 #include "mplayer/gtk/eq.h" | |
14 #include "mplayer/widgets.h" | |
15 #include "mplayer/gmplayer.h" | |
16 #include "mplayer/play.h" | |
17 | |
18 #include "mplayer.h" | |
19 #include "access_mpcontext.h" | |
20 #include "app.h" | |
21 #include "cfg.h" | |
22 #include "help_mp.h" | |
23 #include "subreader.h" | |
24 #include "libvo/x11_common.h" | |
25 #include "libvo/video_out.h" | |
26 #include "libvo/font_load.h" | |
27 #include "libvo/sub.h" | |
28 #include "input/input.h" | |
29 #include "libao2/audio_out.h" | |
30 #include "mixer.h" | |
31 #include "libaf/af.h" | |
32 #include "libaf/equalizer.h" | |
33 | |
34 extern af_cfg_t af_cfg; | |
35 | |
36 #ifdef USE_ICONV | |
37 #include <iconv.h> | |
38 #endif | |
39 | |
40 #include "stream/stream.h" | |
41 #include "libmpdemux/demuxer.h" | |
42 #include "libmpdemux/stheader.h" | |
43 #include "libmpcodecs/dec_video.h" | |
44 | |
45 #ifdef USE_DVDREAD | |
46 #include "stream/stream_dvd.h" | |
47 #endif | |
48 | |
23603
c1221a031ab7
Add a (almost correct) prototype for vcd_seek_to_track
reimar
parents:
23341
diff
changeset
|
49 int vcd_seek_to_track(void *vcd, int track); |
23077 | 50 |
51 #include "m_config.h" | |
52 #include "m_option.h" | |
53 | |
54 | |
55 guiInterface_t guiIntfStruct; | |
56 int guiWinID=-1; | |
57 | |
58 char * gstrcat( char ** dest,const char * src ) | |
59 { | |
60 char * tmp = NULL; | |
61 | |
62 if ( !src ) return NULL; | |
63 | |
64 if ( *dest ) | |
65 { | |
66 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
67 | |
68 if ( tmp ) /* TODO: advanced error handling */ | |
69 { | |
70 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
71 } | |
72 } | |
73 else | |
74 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
75 *dest=tmp; | |
76 return tmp; | |
77 } | |
78 | |
79 int gstrcmp( const char * a,const char * b ) | |
80 { | |
81 if ( !a && !b ) return 0; | |
82 if ( !a || !b ) return -1; | |
83 return strcmp( a,b ); | |
84 } | |
85 | |
86 int gstrncmp( const char * a,const char * b,int size ) | |
87 { | |
88 if ( !a && !b ) return 0; | |
89 if ( !a || !b ) return -1; | |
90 return strncmp( a,b,size ); | |
91 } | |
92 | |
93 char * gstrdup( const char * str ) | |
94 { | |
95 if ( !str ) return NULL; | |
96 return strdup( str ); | |
97 } | |
98 | |
99 char * gstrchr( char * str,int c ) | |
100 { | |
101 if ( !str ) return NULL; | |
102 return strchr( str,c ); | |
103 } | |
104 | |
105 void gfree( void ** p ) | |
106 { | |
107 if ( *p == NULL ) return; | |
108 free( *p ); *p=NULL; | |
109 } | |
110 | |
111 void gset( char ** str, const char * what ) | |
112 { | |
113 if ( *str ) { if ( !strstr( *str,what ) ) { gstrcat( str,"," ); gstrcat( str,what ); }} | |
114 else gstrcat( str,what ); | |
115 } | |
116 | |
117 /** | |
118 * \brief this actually creates a new list containing only one element... | |
119 */ | |
120 void gaddlist( char *** list,const char * entry ) | |
121 { | |
122 int i; | |
123 | |
124 if ( (*list) ) | |
125 { | |
126 for ( i=0;(*list)[i];i++ ) free( (*list)[i] ); | |
127 free( (*list) ); | |
128 } | |
129 | |
130 (*list)=malloc( 2 * sizeof(char **) ); | |
131 (*list)[0]=gstrdup( entry ); | |
132 (*list)[1]=NULL; | |
133 } | |
134 | |
135 /** | |
136 * \brief this replaces a string starting with search by replace. | |
137 * If not found, replace is appended. | |
138 */ | |
139 void greplace(char ***list, const char *search, const char *replace) | |
140 { | |
141 int i = 0; | |
142 int len = (search) ? strlen(search) : 0; | |
143 | |
144 if (*list) { | |
145 for (i = 0; (*list)[i]; i++) { | |
146 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
147 free((*list)[i]); | |
148 (*list)[i] = gstrdup(replace); | |
149 return; | |
150 } | |
151 } | |
152 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
153 } | |
154 else | |
155 *list = malloc(2 * sizeof(char *)); | |
156 | |
157 (*list)[i] = gstrdup(replace); | |
158 (*list)[i + 1] = NULL; | |
159 } | |
160 | |
161 #ifdef USE_ICONV | |
162 char * gconvert_uri_to_filename( char * str ) | |
163 { | |
164 iconv_t d; | |
165 char * out = strdup( str ); | |
166 char * tmp = NULL; | |
167 char * ize; | |
168 size_t inb,outb; | |
169 char * charset = "ISO8859-1"; | |
170 char * cs; | |
171 | |
172 if ( !strchr( str,'%' ) ) return str; | |
173 | |
174 { | |
175 char * t = calloc( 1,strlen( out ) ); | |
176 int i,c = 0; | |
177 for ( i=0;i < (int)strlen( out );i++ ) | |
178 if ( out[i] != '%' ) t[c++]=out[i]; | |
179 else | |
180 { | |
181 char tmp[5] = "0xXX"; | |
182 // if ( out[++i] == '%' ) { t[c++]='%'; continue; }; | |
183 tmp[2]=out[++i]; tmp[3]=out[++i]; | |
184 t[c++]=(char)strtol( tmp,(char **)NULL,0 ); | |
185 } | |
186 free( out ); | |
187 out=t; | |
188 } | |
189 | |
190 if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs; | |
191 | |
192 inb=outb=strlen( out ); | |
193 tmp=calloc( 1,outb + 1 ); | |
194 ize=tmp; | |
195 d=iconv_open( charset,"UTF-8" ); | |
196 if ( (iconv_t)(-1) == d ) return str; | |
197 iconv( d,&out,&inb,&tmp,&outb ); | |
198 iconv_close( d ); | |
199 free( out ); | |
200 return ize; | |
201 } | |
202 #endif | |
203 | |
204 void guiInit( void ) | |
205 { | |
206 int i; | |
207 | |
208 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); | |
209 guiIntfStruct.Balance=50.0f; | |
210 guiIntfStruct.StreamType=-1; | |
211 | |
212 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); | |
213 #ifdef HAVE_DXR3 | |
214 if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" ); | |
215 #endif | |
216 if ( stream_cache_size > 0 ) { gtkCacheOn=1; gtkCacheSize=stream_cache_size; } | |
217 else if ( stream_cache_size == 0 ) gtkCacheOn = 0; | |
218 if ( autosync && autosync != gtkAutoSync ) { gtkAutoSyncOn=1; gtkAutoSync=autosync; } | |
219 | |
220 #ifdef USE_ASS | |
221 gtkASS.enabled = ass_enabled; | |
222 gtkASS.use_margins = ass_use_margins; | |
223 gtkASS.top_margin = ass_top_margin; | |
224 gtkASS.bottom_margin = ass_bottom_margin; | |
225 #endif | |
226 | |
227 gtkInit(); | |
228 // --- initialize X | |
229 wsXInit( (void *)mDisplay ); | |
230 // --- load skin | |
231 skinDirInHome=get_path("skins"); | |
232 skinDirInHome_obsolete=get_path("Skin"); | |
233 skinMPlayerDir=MPLAYER_DATADIR "/skins"; | |
234 skinMPlayerDir_obsolete=MPLAYER_DATADIR "/Skin"; | |
235 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1: '%s'\n",skinDirInHome); | |
236 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1 (obsolete): '%s'\n",skinDirInHome_obsolete); | |
237 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2: '%s'\n",skinMPlayerDir); | |
238 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2 (obsolete): '%s'\n",skinMPlayerDir_obsolete); | |
239 if ( !skinName ) skinName=strdup( "default" ); | |
240 i = skinRead( skinName ); | |
241 if ((i == -1) && strcmp(skinName,"default")) | |
242 { | |
243 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
244 skinName=strdup( "default" ); | |
245 i = skinRead( skinName ); | |
246 } | |
247 switch (i) { | |
248 case -1: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinNotFound,skinName ); exit( 0 ); | |
249 case -2: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinCfgReadError,skinName ); exit( 0 ); | |
250 } | |
251 // --- initialize windows | |
252 if ( ( mplDrawBuffer = malloc( appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) | |
253 { | |
254 fprintf( stderr,MSGTR_NEMDB ); | |
255 exit( 0 ); | |
256 } | |
257 | |
258 if ( gui_save_pos ) | |
259 { | |
260 appMPlayer.main.x = gui_main_pos_x; | |
261 appMPlayer.main.y = gui_main_pos_y; | |
262 appMPlayer.sub.x = gui_sub_pos_x; | |
263 appMPlayer.sub.y = gui_sub_pos_y; | |
264 } | |
265 | |
266 if (WinID>0) | |
267 { | |
268 appMPlayer.subWindow.Parent=WinID; | |
269 appMPlayer.sub.x=0; | |
270 appMPlayer.sub.y=0; | |
271 } | |
272 if (guiWinID>=0) appMPlayer.mainWindow.Parent=guiWinID; | |
273 | |
274 wsCreateWindow( &appMPlayer.subWindow, | |
275 appMPlayer.sub.x,appMPlayer.sub.y,appMPlayer.sub.width,appMPlayer.sub.height, | |
276 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsHideWindow,"MPlayer - Video" ); | |
277 | |
278 wsDestroyImage( &appMPlayer.subWindow ); | |
279 wsCreateImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height ); | |
280 wsXDNDMakeAwareness(&appMPlayer.subWindow); | |
281 | |
282 mplMenuInit(); | |
283 mplPBInit(); | |
284 | |
285 vo_setwindow( appMPlayer.subWindow.WindowID, appMPlayer.subWindow.wGC ); | |
286 | |
287 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
288 // if ( appMPlayer.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; | |
289 i=wsShowFrame|wsMaxSize|wsHideWindow; | |
290 wsCreateWindow( &appMPlayer.mainWindow, | |
291 appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height, | |
292 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,i,"MPlayer" ); | |
293 | |
294 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
295 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
296 | |
297 #ifdef DEBUG | |
298 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] depth on screen: %d\n",wsDepthOnScreen ); | |
299 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] parent: 0x%x\n",(int)appMPlayer.mainWindow.WindowID ); | |
300 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] sub: 0x%x\n",(int)appMPlayer.subWindow.WindowID ); | |
301 #endif | |
302 | |
303 appMPlayer.mainWindow.ReDraw=(void *)mplMainDraw; | |
304 appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle; | |
305 appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle; | |
306 appMPlayer.mainWindow.DandDHandler=mplDandDHandler; | |
307 | |
308 appMPlayer.subWindow.ReDraw=(void *)mplSubDraw; | |
309 appMPlayer.subWindow.MouseHandler=mplSubMouseHandle; | |
310 appMPlayer.subWindow.KeyHandler=mplMainKeyHandle; | |
311 appMPlayer.subWindow.DandDHandler=mplDandDHandler; | |
312 | |
313 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B ); | |
314 wsClearWindow( appMPlayer.subWindow ); | |
315 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); | |
316 | |
317 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
318 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
319 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
320 | |
321 wsSetIcon( wsDisplay,appMPlayer.mainWindow.WindowID,guiIcon,guiIconMask ); | |
322 wsSetIcon( wsDisplay,appMPlayer.subWindow.WindowID,guiIcon,guiIconMask ); | |
323 | |
324 guiIntfStruct.Playing=0; | |
325 | |
326 if ( !appMPlayer.mainDecoration ) wsWindowDecoration( &appMPlayer.mainWindow,0 ); | |
327 | |
328 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
329 #if 0 | |
330 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
331 | |
332 { | |
333 XEvent xev; | |
334 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
335 appMPlayer.subWindow.Mapped=wsMapped; | |
336 } | |
337 | |
338 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
339 if ( fullscreen ) | |
340 { | |
341 mplFullScreen(); | |
342 btnModify( evFullScreen,btnPressed ); | |
343 } | |
344 #else | |
345 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
346 if ( gtkShowVideoWindow ) | |
347 { | |
348 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
349 { | |
350 XEvent xev; | |
351 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
352 appMPlayer.subWindow.Mapped=wsMapped; | |
353 } | |
354 | |
355 if ( fullscreen ) | |
356 { | |
357 mplFullScreen(); | |
358 btnModify( evFullScreen,btnPressed ); | |
359 } | |
360 } | |
361 else | |
362 { | |
363 if ( fullscreen ) | |
364 { | |
365 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
366 { | |
367 XEvent xev; | |
368 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
369 appMPlayer.subWindow.Mapped=wsMapped; | |
370 } | |
371 wsVisibleWindow( &appMPlayer.subWindow, wsShowWindow ); | |
372 | |
373 mplFullScreen(); | |
374 btnModify( evFullScreen,btnPressed ); | |
375 } | |
376 } | |
377 #endif | |
378 mplSubRender=1; | |
379 // --- | |
380 | |
381 if ( filename ) mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
382 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); | |
383 if ( subdata ) guiSetFilename( guiIntfStruct.Subtitlename, subdata->filename ); | |
384 guiLoadFont(); | |
385 } | |
386 | |
387 void guiDone( void ) | |
388 { | |
389 mplMainRender=0; | |
390 mp_msg( MSGT_GPLAYER,MSGL_V,"[GUI] done.\n" ); | |
391 | |
392 if ( gui_save_pos ) | |
393 { | |
394 gui_main_pos_x=appMPlayer.mainWindow.X; gui_main_pos_y=appMPlayer.mainWindow.Y; | |
395 gui_sub_pos_x=appMPlayer.subWindow.X; gui_sub_pos_y=appMPlayer.subWindow.Y; | |
396 } | |
397 | |
398 #ifdef USE_ASS | |
399 ass_enabled = gtkASS.enabled; | |
400 ass_use_margins = gtkASS.use_margins; | |
401 ass_top_margin = gtkASS.top_margin; | |
402 ass_bottom_margin = gtkASS.bottom_margin; | |
403 #endif | |
404 | |
405 cfg_write(); | |
406 wsXDone(); | |
407 } | |
408 | |
409 int guiCMDArray[] = | |
410 { | |
411 evLoadPlay, | |
412 evLoadSubtitle, | |
413 evAbout, | |
414 evPlay, | |
415 evStop, | |
416 evPlayList, | |
417 evPreferences, | |
418 evFullScreen, | |
419 evSkinBrowser | |
420 }; | |
421 | |
422 extern int frame_dropping; | |
423 extern int stream_dump_type; | |
424 extern int vcd_track; | |
425 extern m_obj_settings_t * vf_settings; | |
426 | |
427 void guiLoadFont( void ) | |
428 { | |
429 #ifdef HAVE_FREETYPE | |
23341
74f5109611e2
missed part of gui code change while introducing -subfont option (patch by Piotr Kaczuba)
ben
parents:
23158
diff
changeset
|
430 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name); |
23077 | 431 #else |
432 if ( vo_font ) | |
433 { | |
434 int i; | |
435 if ( vo_font->name ) free( vo_font->name ); | |
436 if ( vo_font->fpath ) free( vo_font->fpath ); | |
437 for ( i=0;i<16;i++ ) | |
438 if ( vo_font->pic_a[i] ) | |
439 { | |
440 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
441 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
442 } | |
443 for ( i=0;i<16;i++ ) | |
444 if ( vo_font->pic_b[i] ) | |
445 { | |
446 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
447 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
448 } | |
449 free( vo_font ); vo_font=NULL; | |
450 } | |
451 if ( font_name ) | |
452 { | |
453 vo_font=read_font_desc( font_name,font_factor,0 ); | |
454 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); | |
455 } | |
456 else | |
457 { | |
458 font_name=gstrdup( get_path( "font/font.desc" ) ); | |
459 vo_font=read_font_desc( font_name,font_factor,0 ); | |
460 if ( !vo_font ) | |
461 { | |
462 gfree( (void **)&font_name ); font_name=gstrdup(MPLAYER_DATADIR "/font/font.desc" ); | |
463 vo_font=read_font_desc( font_name,font_factor,0 ); | |
464 } | |
465 } | |
466 #endif | |
467 } | |
468 | |
469 extern mp_osd_obj_t* vo_osd_list; | |
470 | |
471 extern char **sub_name; | |
472 | |
473 void guiLoadSubtitle( char * name ) | |
474 { | |
475 if ( guiIntfStruct.Playing == 0 ) | |
476 { | |
477 guiIntfStruct.SubtitleChanged=1; //what is this for? (mw) | |
478 return; | |
479 } | |
480 if ( subdata ) | |
481 { | |
482 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_DeletingSubtitles ); | |
483 sub_free( subdata ); | |
484 subdata=NULL; | |
485 vo_sub=NULL; | |
486 if ( vo_osd_list ) | |
487 { | |
488 int len; | |
489 mp_osd_obj_t * osd = vo_osd_list; | |
490 while ( osd ) | |
491 { | |
492 if ( osd->type == OSDTYPE_SUBTITLE ) break; | |
493 osd=osd->next; | |
494 } | |
495 if ( osd && osd->flags&OSDFLAG_VISIBLE ) | |
496 { | |
497 len=osd->stride * ( osd->bbox.y2 - osd->bbox.y1 ); | |
498 memset( osd->bitmap_buffer,0,len ); | |
499 memset( osd->alpha_buffer,0,len ); | |
500 } | |
501 } | |
502 } | |
503 if ( name ) | |
504 { | |
505 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_LoadingSubtitles,name ); | |
506 subdata=sub_read_file( name, guiIntfStruct.FPS ); | |
507 if ( !subdata ) mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_CantLoadSub,name ); | |
508 sub_name = (malloc(2 * sizeof(char*))); //when mplayer will be restarted | |
509 sub_name[0] = strdup(name); //sub_name[0] will be read | |
510 sub_name[1] = NULL; | |
511 } | |
512 update_set_of_subtitles(); | |
513 | |
514 } | |
515 | |
516 static void add_vf( char * str ) | |
517 { | |
518 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str ); | |
519 if ( vf_settings ) | |
520 { | |
521 int i = 0; | |
522 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; } | |
523 if ( i != -1 ) | |
524 { vf_settings=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ); vf_settings[i].name=strdup( str );vf_settings[i].attribs = NULL; vf_settings[i+1].name=NULL; } | |
525 } else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; } | |
526 } | |
527 | |
528 static void remove_vf( char * str ) | |
529 { | |
530 int n = 0; | |
531 | |
532 if ( !vf_settings ) return; | |
533 | |
534 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_RemovingVideoFilter,str ); | |
535 | |
536 while ( vf_settings[n++].name ); n--; | |
537 if ( n > -1 ) | |
538 { | |
539 int i = 0,m = -1; | |
540 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { m=i - 1; break; } | |
541 i--; | |
542 if ( m > -1 ) | |
543 { | |
544 if ( n == 1 ) { free( vf_settings[0].name );free( vf_settings[0].attribs ); free( vf_settings ); vf_settings=NULL; } | |
545 else { free( vf_settings[i].name );free( vf_settings[i].attribs ); memcpy( &vf_settings[i],&vf_settings[i + 1],( n - i ) * sizeof( m_obj_settings_t ) ); } | |
546 } | |
547 } | |
548 } | |
549 | |
550 int guiGetEvent( int type,char * arg ) | |
551 { | |
552 ao_functions_t *audio_out = NULL; | |
553 vo_functions_t *video_out = NULL; | |
554 mixer_t *mixer = NULL; | |
555 | |
556 stream_t * stream = (stream_t *) arg; | |
557 #ifdef USE_DVDREAD | |
558 dvd_priv_t * dvdp = (dvd_priv_t *) arg; | |
559 #endif | |
560 | |
561 if (guiIntfStruct.mpcontext) { | |
562 audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext); | |
563 video_out = mpctx_get_video_out(guiIntfStruct.mpcontext); | |
564 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
565 } | |
566 | |
567 switch ( type ) | |
568 { | |
569 case guiXEvent: | |
570 guiIntfStruct.event_struct=(void *)arg; | |
571 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
572 gtkEventHandling(); | |
573 break; | |
574 case guiCEvent: | |
575 switch ( (int)arg ) | |
576 { | |
577 case guiSetPlay: | |
578 guiIntfStruct.Playing=1; | |
579 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
580 break; | |
581 case guiSetStop: | |
582 guiIntfStruct.Playing=0; | |
583 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
584 break; | |
585 case guiSetPause: guiIntfStruct.Playing=2; break; | |
586 } | |
587 mplState(); | |
588 break; | |
589 case guiSetState: | |
590 mplState(); | |
591 break; | |
592 case guiSetFileName: | |
593 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
594 break; | |
595 case guiSetAudioOnly: | |
596 guiIntfStruct.AudioOnly=(int)arg; | |
597 if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } | |
598 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
599 break; | |
600 case guiSetContext: | |
601 guiIntfStruct.mpcontext=(void *)arg; | |
602 case guiSetDemuxer: | |
603 guiIntfStruct.demuxer=(void *)arg; | |
604 break; | |
605 case guiSetAfilter: | |
606 guiIntfStruct.afilter=(void *)arg; | |
607 break; | |
608 case guiSetShVideo: | |
609 { | |
610 if ( !appMPlayer.subWindow.isFullScreen ) | |
611 { | |
612 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
613 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
614 } | |
615 guiIntfStruct.MovieWidth=vo_dwidth; | |
616 guiIntfStruct.MovieHeight=vo_dheight; | |
617 if (guiWinID>=0) | |
618 wsMoveWindow( &appMPlayer.mainWindow,0,0, vo_dheight); | |
619 } | |
620 break; | |
621 #ifdef USE_DVDREAD | |
622 case guiSetDVD: | |
623 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
624 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
625 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
626 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
627 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
628 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
629 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
630 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
631 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
632 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
633 guiIntfStruct.Track=dvd_title + 1; | |
634 break; | |
635 #endif | |
636 case guiSetStream: | |
637 guiIntfStruct.StreamType=stream->type; | |
638 switch( stream->type ) | |
639 { | |
640 #ifdef USE_DVDREAD | |
641 case STREAMTYPE_DVD: | |
642 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
643 break; | |
644 #endif | |
645 #ifdef HAVE_VCD | |
646 case STREAMTYPE_VCD: | |
647 { | |
648 int i; | |
649 | |
650 if (!stream->priv) | |
651 { | |
652 guiIntfStruct.VCDTracks=0; | |
653 break; | |
654 } | |
655 for ( i=1;i < 100;i++ ) | |
656 if ( vcd_seek_to_track( stream->priv,i ) < 0 ) break; | |
657 vcd_seek_to_track( stream->priv,vcd_track ); | |
658 guiIntfStruct.VCDTracks=--i; | |
659 break; | |
660 } | |
661 #endif | |
662 default: break; | |
663 } | |
664 break; | |
665 case guiIEvent: | |
666 mp_msg( MSGT_GPLAYER,MSGL_V,"cmd: %d\n",(int)arg ); | |
667 switch( (int)arg ) | |
668 { | |
669 case MP_CMD_QUIT: | |
670 mplEventHandling( evExit,0 ); | |
671 break; | |
672 case MP_CMD_VO_FULLSCREEN: | |
673 mplEventHandling( evFullScreen,0 ); | |
674 break; | |
675 default: | |
676 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
677 } | |
678 break; | |
679 case guiReDraw: | |
680 mplEventHandling( evRedraw,0 ); | |
681 break; | |
682 case guiSetVolume: | |
683 if ( audio_out ) | |
684 { | |
685 float l,r; | |
686 mixer_getvolume( mixer,&l,&r ); | |
687 guiIntfStruct.Volume=(r>l?r:l); | |
688 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
689 else guiIntfStruct.Balance=50.0f; | |
690 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
691 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
692 } | |
693 break; | |
694 case guiSetFileFormat: | |
695 guiIntfStruct.FileFormat=(int)arg; | |
696 break; | |
697 case guiSetValues: | |
698 // -- video | |
699 guiIntfStruct.sh_video=arg; | |
700 if ( arg ) | |
701 { | |
702 sh_video_t * sh = (sh_video_t *)arg; | |
703 guiIntfStruct.FPS=sh->fps; | |
704 } | |
705 | |
706 if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
707 | |
708 if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) btnSet( evSetMoviePosition,btnDisabled ); | |
709 else btnSet( evSetMoviePosition,btnReleased ); | |
710 | |
711 // -- audio | |
712 if ( audio_out ) | |
713 { | |
714 float l,r; | |
715 mixer_getvolume( mixer,&l,&r ); | |
716 guiIntfStruct.Volume=(r>l?r:l); | |
717 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
718 else guiIntfStruct.Balance=50.0f; | |
719 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
720 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
721 } | |
722 | |
723 if ( gtkEnableAudioEqualizer ) | |
724 { | |
725 equalizer_t eq; | |
726 int i,j; | |
727 for ( i=0;i<6;i++ ) | |
728 for ( j=0;j<10;j++ ) | |
729 { | |
730 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
731 gtkSet( gtkSetEqualizer,0,&eq ); | |
732 } | |
733 } | |
734 // -- subtitle | |
735 #ifdef HAVE_DXR3 | |
736 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS | |
737 #ifdef USE_LIBAVCODEC | |
738 && !gtkVfLAVC | |
739 #endif | |
740 ) | |
741 { | |
742 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVC ); | |
743 guiIntfStruct.Playing=0; | |
744 return True; | |
745 } | |
746 #endif | |
747 break; | |
748 case guiSetDefaults: | |
749 // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) | |
750 if ( guiIntfStruct.FilenameChanged ) | |
751 { | |
752 audio_id=-1; | |
753 video_id=-1; | |
754 dvdsub_id=-1; | |
755 vobsub_id=-1; | |
756 stream_cache_size=-1; | |
757 autosync=0; | |
758 vcd_track=0; | |
759 dvd_title=0; | |
760 force_fps=0; | |
761 } | |
762 guiIntfStruct.demuxer=NULL; | |
763 guiIntfStruct.sh_video=NULL; | |
764 wsPostRedisplay( &appMPlayer.subWindow ); | |
765 break; | |
766 case guiSetParameters: | |
767 guiGetEvent( guiSetDefaults,NULL ); | |
768 switch ( guiIntfStruct.StreamType ) | |
769 { | |
770 case STREAMTYPE_PLAYLIST: | |
771 break; | |
772 #ifdef HAVE_VCD | |
773 case STREAMTYPE_VCD: | |
774 { | |
775 char tmp[512]; | |
776 sprintf( tmp,"vcd://%d",guiIntfStruct.Track + 1 ); | |
777 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
778 } | |
779 break; | |
780 #endif | |
781 #ifdef USE_DVDREAD | |
782 case STREAMTYPE_DVD: | |
783 { | |
784 char tmp[512]; | |
785 sprintf( tmp,"dvd://%d",guiIntfStruct.Title ); | |
786 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
787 } | |
788 dvd_chapter=guiIntfStruct.Chapter; | |
789 dvd_angle=guiIntfStruct.Angle; | |
790 break; | |
791 #endif | |
792 } | |
793 //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! | |
794 { | |
795 if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename ); | |
796 else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename ); | |
797 } | |
798 // --- video opts | |
799 | |
800 if ( !video_driver_list ) | |
801 { | |
802 int i = 0; | |
803 while ( video_out_drivers[i++] ) | |
804 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
805 { | |
806 gaddlist( &video_driver_list,(char *)video_out_drivers[i - 1]->info->short_name ); | |
807 break; | |
808 } | |
809 } | |
810 | |
811 if ( !video_driver_list && !video_driver_list[0] ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } | |
812 | |
813 { | |
814 int i = 0; | |
815 guiIntfStruct.NoWindow=False; | |
816 while ( video_out_drivers[i++] ) | |
817 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
818 { | |
819 if ( ( video_driver_list && !gstrcmp( video_driver_list[0],(char *)video_out_drivers[i - 1]->info->short_name ) )&&( video_out_drivers[i - 1]->control( VOCTRL_GUI_NOWINDOW,NULL ) == VO_TRUE ) ) | |
820 { guiIntfStruct.NoWindow=True; break; } | |
821 } | |
822 } | |
823 | |
824 #ifdef HAVE_DXR3 | |
825 #ifdef USE_LIBAVCODEC | |
826 remove_vf( "lavc" ); | |
827 #endif | |
828 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) ) | |
829 { | |
830 if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) | |
831 { | |
832 #ifdef USE_LIBAVCODEC | |
833 if ( gtkVfLAVC ) add_vf( "lavc" ); | |
834 #endif | |
835 } | |
836 } | |
837 #endif | |
838 // --- | |
839 if ( gtkVfPP ) add_vf( "pp" ); | |
840 else remove_vf( "pp" ); | |
841 | |
842 // --- audio opts | |
843 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
844 if (gtkAONorm) | |
845 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
846 if (gtkEnableAudioEqualizer) | |
847 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
848 if ( gtkAOExtraStereo ) | |
849 { | |
850 char *name = malloc(12 + 20 + 1); | |
851 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
852 name[12 + 20] = 0; | |
853 greplace(&af_cfg.list, "extrastereo", name); | |
854 free(name); | |
855 } | |
856 #ifdef USE_OSS_AUDIO | |
857 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"oss",3 ) ) | |
858 { | |
859 char *tmp; | |
860 mixer_device = gtkAOOSSMixer; | |
861 mixer_channel = gtkAOOSSMixerChannel; | |
862 if (gtkAOOSSDevice) { | |
863 tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 7 ); | |
864 sprintf( tmp,"oss:%s",gtkAOOSSDevice ); | |
865 } else | |
866 tmp = strdup("oss"); | |
867 gaddlist( &audio_driver_list,tmp ); | |
868 free(tmp); | |
869 } | |
870 #endif | |
871 #if defined(HAVE_ALSA9) || defined (HAVE_ALSA1X) | |
872 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"alsa",4 ) ) | |
873 { | |
874 char *tmp; | |
875 mixer_device = gtkAOALSAMixer; | |
876 mixer_channel = gtkAOALSAMixerChannel; | |
877 if (gtkAOALSADevice) { | |
878 tmp = calloc( 1,strlen( gtkAOALSADevice ) + 14 ); | |
879 sprintf( tmp,"alsa:device=%s",gtkAOALSADevice ); | |
880 } else | |
881 tmp = strdup("alsa"); | |
882 gaddlist( &audio_driver_list,tmp ); | |
883 free(tmp); | |
884 } | |
885 #endif | |
886 #ifdef HAVE_SDL | |
887 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"sdl",3 ) ) | |
888 { | |
889 char *tmp; | |
890 if (gtkAOSDLDriver) { | |
891 tmp = calloc( 1,strlen( gtkAOSDLDriver ) + 10 ); | |
892 sprintf( tmp,"sdl:%s",gtkAOSDLDriver ); | |
893 } else | |
894 tmp = strdup("sdl"); | |
895 gaddlist( &audio_driver_list,tmp ); | |
896 free(tmp); | |
897 } | |
898 #endif | |
899 #ifdef USE_ESD | |
900 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"esd",3 ) ) | |
901 { | |
902 char *tmp; | |
903 if (gtkAOESDDevice) { | |
904 tmp = calloc( 1,strlen( gtkAOESDDevice ) + 10 ); | |
905 sprintf( tmp,"esd:%s",gtkAOESDDevice ); | |
906 } else | |
907 tmp = strdup("esd"); | |
908 gaddlist( &audio_driver_list,tmp ); | |
909 free(tmp); | |
910 } | |
911 #endif | |
912 // -- subtitle | |
913 //subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); | |
914 stream_dump_type=0; | |
915 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
916 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
917 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
918 guiLoadFont(); | |
919 | |
920 // --- misc | |
921 if ( gtkCacheOn ) stream_cache_size=gtkCacheSize; | |
922 if ( gtkAutoSyncOn ) autosync=gtkAutoSync; | |
923 | |
924 if ( guiIntfStruct.AudioFile ) audio_stream=gstrdup( guiIntfStruct.AudioFile ); | |
925 else if ( guiIntfStruct.FilenameChanged ) gfree( (void**)&audio_stream ); | |
926 //audio_stream=NULL; | |
927 | |
928 guiIntfStruct.DiskChanged=0; | |
929 guiIntfStruct.FilenameChanged=0; | |
930 guiIntfStruct.NewPlay=0; | |
931 | |
932 #ifdef USE_ASS | |
933 ass_enabled = gtkASS.enabled; | |
934 ass_use_margins = gtkASS.use_margins; | |
935 ass_top_margin = gtkASS.top_margin; | |
936 ass_bottom_margin = gtkASS.bottom_margin; | |
937 #endif | |
938 | |
939 break; | |
940 } | |
941 return False; | |
942 } | |
943 | |
944 void guiEventHandling( void ) | |
945 { | |
946 if ( !guiIntfStruct.Playing || guiIntfStruct.NoWindow ) wsHandleEvents(); | |
947 gtkEventHandling(); | |
948 } | |
949 | |
950 // --- | |
951 | |
952 float gtkEquChannels[6][10]; | |
953 | |
954 plItem * plCurrent = NULL; | |
955 plItem * plList = NULL; | |
956 plItem * plLastPlayed = NULL; | |
957 | |
958 URLItem *URLList = NULL; | |
959 | |
960 char *fsHistory[fsPersistant_MaxPos] = { NULL,NULL,NULL,NULL,NULL }; | |
961 | |
962 #if defined( MP_DEBUG ) && 0 | |
963 void list( void ) | |
964 { | |
965 plItem * next = plList; | |
966 printf( "--- list ---\n" ); | |
967 while( next || next->next ) | |
968 { | |
969 printf( "item: %s/%s\n",next->path,next->name ); | |
970 if ( next->next ) next=next->next; else break; | |
971 } | |
972 printf( "--- end of list ---\n" ); | |
973 } | |
974 #else | |
975 #define list(); | |
976 #endif | |
977 | |
978 void * gtkSet( int cmd,float fparam, void * vparam ) | |
979 { | |
980 equalizer_t * eq = (equalizer_t *)vparam; | |
981 plItem * item = (plItem *)vparam; | |
982 | |
983 URLItem * url_item = (URLItem *)vparam; | |
984 int is_added = True; | |
985 | |
986 switch ( cmd ) | |
987 { | |
988 // --- handle playlist | |
989 case gtkAddPlItem: // add item to playlist | |
990 if ( plList ) | |
991 { | |
992 plItem * next = plList; | |
993 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
994 next->next=item; item->prev=next; | |
995 } else { item->prev=item->next=NULL; plCurrent=plList=item; } | |
996 list(); | |
997 return NULL; | |
998 case gtkInsertPlItem: // add item into playlist after current | |
999 if ( plCurrent ) | |
1000 { | |
1001 plItem * curr = plCurrent; | |
1002 item->next=curr->next; | |
1003 if (item->next) | |
1004 item->next->prev=item; | |
1005 item->prev=curr; | |
1006 curr->next=item; | |
1007 plCurrent=plCurrent->next; | |
1008 return plCurrent; | |
1009 } | |
1010 else | |
1011 return gtkSet(gtkAddPlItem,0,(void*)item); | |
1012 return NULL; | |
1013 case gtkGetNextPlItem: // get current item from playlist | |
1014 if ( plCurrent && plCurrent->next) | |
1015 { | |
1016 plCurrent=plCurrent->next; | |
1017 /*if ( !plCurrent && plList ) | |
1018 { | |
1019 plItem * next = plList; | |
1020 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
1021 plCurrent=next; | |
1022 }*/ | |
1023 return plCurrent; | |
1024 } | |
1025 return NULL; | |
1026 case gtkGetPrevPlItem: | |
1027 if ( plCurrent && plCurrent->prev) | |
1028 { | |
1029 plCurrent=plCurrent->prev; | |
1030 //if ( !plCurrent && plList ) plCurrent=plList; | |
1031 return plCurrent; | |
1032 } | |
1033 return NULL; | |
1034 case gtkSetCurrPlItem: // set current item | |
1035 plCurrent=item; | |
1036 return plCurrent; | |
1037 case gtkGetCurrPlItem: // get current item | |
1038 return plCurrent; | |
1039 case gtkDelCurrPlItem: // delete current item | |
1040 { | |
1041 plItem * curr = plCurrent; | |
1042 | |
1043 if (!curr) | |
1044 return NULL; | |
1045 if (curr->prev) | |
1046 curr->prev->next=curr->next; | |
1047 if (curr->next) | |
1048 curr->next->prev=curr->prev; | |
1049 if (curr==plList) | |
1050 plList=curr->next; | |
1051 plCurrent=curr->next; | |
1052 // Free it | |
1053 if ( curr->path ) free( curr->path ); | |
1054 if ( curr->name ) free( curr->name ); | |
1055 free( curr ); | |
1056 } | |
1057 mplCurr(); // Instead of using mplNext && mplPrev | |
1058 | |
1059 return plCurrent; | |
1060 case gtkDelPl: // delete list | |
1061 { | |
1062 plItem * curr = plList; | |
1063 plItem * next; | |
1064 if ( !plList ) return NULL; | |
1065 if ( !curr->next ) | |
1066 { | |
1067 if ( curr->path ) free( curr->path ); | |
1068 if ( curr->name ) free( curr->name ); | |
1069 free( curr ); | |
1070 } | |
1071 else | |
1072 { | |
1073 while ( curr->next ) | |
1074 { | |
1075 next=curr->next; | |
1076 if ( curr->path ) free( curr->path ); | |
1077 if ( curr->name ) free( curr->name ); | |
1078 free( curr ); | |
1079 curr=next; | |
1080 } | |
1081 } | |
1082 plList=NULL; plCurrent=NULL; | |
1083 } | |
1084 return NULL; | |
1085 // ----- Handle url | |
1086 case gtkAddURLItem: | |
1087 if ( URLList ) | |
1088 { | |
1089 URLItem * next_url = URLList; | |
1090 is_added = False; | |
1091 while ( next_url->next ) | |
1092 { | |
1093 if ( !gstrcmp( next_url->url,url_item->url ) ) | |
1094 { | |
1095 is_added=True; | |
1096 break; | |
1097 } | |
1098 next_url=next_url->next; | |
1099 } | |
1100 if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item; | |
1101 } else { url_item->next=NULL; URLList=url_item; } | |
1102 return NULL; | |
1103 // --- subtitle | |
1104 #ifndef HAVE_FREETYPE | |
1105 case gtkSetFontFactor: | |
1106 font_factor=fparam; | |
1107 guiLoadFont(); | |
1108 return NULL; | |
1109 #else | |
1110 case gtkSetFontOutLine: | |
1111 subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; | |
1112 guiLoadFont(); | |
1113 return NULL; | |
1114 case gtkSetFontBlur: | |
1115 subtitle_font_radius=( 8.0f / 100.0f ) * fparam; | |
1116 guiLoadFont(); | |
1117 return NULL; | |
1118 case gtkSetFontTextScale: | |
1119 text_font_scale_factor=fparam; | |
1120 guiLoadFont(); | |
1121 return NULL; | |
1122 case gtkSetFontOSDScale: | |
1123 osd_font_scale_factor=fparam; | |
1124 guiLoadFont(); | |
1125 return NULL; | |
1126 case gtkSetFontEncoding: | |
1127 gfree( (void **)&subtitle_font_encoding ); | |
1128 subtitle_font_encoding=gstrdup( (char *)vparam ); | |
1129 guiLoadFont(); | |
1130 return NULL; | |
1131 case gtkSetFontAutoScale: | |
1132 subtitle_autoscale=(int)fparam; | |
1133 guiLoadFont(); | |
1134 return NULL; | |
1135 #endif | |
1136 #ifdef USE_ICONV | |
1137 case gtkSetSubEncoding: | |
1138 gfree( (void **)&sub_cp ); | |
1139 sub_cp=gstrdup( (char *)vparam ); | |
1140 break; | |
1141 #endif | |
1142 // --- misc | |
1143 case gtkClearStruct: | |
1144 if ( (unsigned int)vparam & guiFilenames ) | |
1145 { | |
1146 gfree( (void **)&guiIntfStruct.Filename ); | |
1147 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
1148 gfree( (void **)&guiIntfStruct.AudioFile ); | |
1149 gtkSet( gtkDelPl,0,NULL ); | |
1150 } | |
1151 #ifdef USE_DVDREAD | |
1152 if ( (unsigned int)vparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
1153 #endif | |
1154 #ifdef HAVE_VCD | |
1155 if ( (unsigned int)vparam & guiVCD ) guiIntfStruct.VCDTracks=0; | |
1156 #endif | |
1157 return NULL; | |
1158 case gtkSetExtraStereo: | |
1159 gtkAOExtraStereoMul=fparam; | |
1160 if (guiIntfStruct.afilter) | |
1161 af_control_any_rev(guiIntfStruct.afilter, | |
1162 AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
1163 return NULL; | |
1164 case gtkSetPanscan: | |
1165 { | |
1166 mp_cmd_t * mp_cmd; | |
1167 mp_cmd=calloc( 1,sizeof( *mp_cmd ) ); | |
1168 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
1169 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
1170 mp_input_queue_cmd( mp_cmd ); | |
1171 } | |
1172 return NULL; | |
1173 case gtkSetAutoq: | |
1174 auto_quality=(int)fparam; | |
1175 return NULL; | |
1176 // --- set equalizers | |
1177 case gtkSetContrast: | |
1178 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"contrast",(int)fparam ); | |
1179 return NULL; | |
1180 case gtkSetBrightness: | |
1181 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"brightness",(int)fparam ); | |
1182 return NULL; | |
1183 case gtkSetHue: | |
1184 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"hue",(int)fparam ); | |
1185 return NULL; | |
1186 case gtkSetSaturation: | |
1187 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"saturation",(int)fparam ); | |
1188 return NULL; | |
1189 case gtkSetEqualizer: | |
1190 { | |
1191 af_control_ext_t tmp; | |
1192 if ( eq ) | |
1193 { | |
1194 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
1195 tmp.ch = eq->channel; | |
1196 tmp.arg = gtkEquChannels[eq->channel]; | |
1197 if (guiIntfStruct.afilter) | |
1198 af_control_any_rev(guiIntfStruct.afilter, | |
1199 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1200 } | |
1201 else | |
1202 { | |
1203 int i; | |
1204 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
1205 if (guiIntfStruct.afilter) | |
1206 for ( i=0;i<6;i++ ) | |
1207 { | |
1208 tmp.ch = i; | |
1209 tmp.arg = gtkEquChannels[i]; | |
1210 af_control_any_rev(guiIntfStruct.afilter, | |
1211 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
1212 } | |
1213 } | |
1214 return NULL; | |
1215 } | |
1216 } | |
1217 return NULL; | |
1218 } | |
1219 | |
1220 #define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1)) | |
1221 | |
1222 #include "playtree.h" | |
1223 | |
1224 //This function adds/inserts one file into the gui playlist | |
1225 | |
1226 int import_file_into_gui(char* temp, int insert) | |
1227 { | |
1228 char *filename, *pathname; | |
1229 plItem * item; | |
1230 | |
1231 filename = strdup(mp_basename(temp)); | |
1232 pathname = strdup(temp); | |
1233 if (strlen(pathname)-strlen(filename)>0) | |
1234 pathname[strlen(pathname)-strlen(filename)-1]='\0'; // We have some path so remove / at end | |
1235 else | |
1236 pathname[strlen(pathname)-strlen(filename)]='\0'; | |
1237 mp_msg(MSGT_PLAYTREE,MSGL_V, "Adding filename %s && pathname %s\n",filename,pathname); //FIXME: Change to MSGL_DBG2 ? | |
1238 item=calloc( 1,sizeof( plItem ) ); | |
1239 if (!item) | |
1240 return 0; | |
1241 item->name=filename; | |
1242 item->path=pathname; | |
1243 if (insert) | |
1244 gtkSet( gtkInsertPlItem,0,(void*)item ); // Inserts the item after current, and makes current=item | |
1245 else | |
1246 gtkSet( gtkAddPlItem,0,(void*)item ); | |
1247 return 1; | |
1248 } | |
1249 | |
1250 | |
1251 // This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
1252 // by either: | |
1253 // - overwriting gui pl (enqueue=0) | |
1254 // - appending it to gui pl (enqueue=1) | |
1255 | |
1256 int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* config, int enqueue) | |
1257 { | |
1258 play_tree_iter_t* my_pt_iter=NULL; | |
1259 int result=0; | |
1260 | |
1261 if (!enqueue) // Delete playlist before "appending" | |
1262 gtkSet(gtkDelPl,0,0); | |
1263 | |
1264 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
1265 { | |
1266 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
1267 { | |
1268 if (import_file_into_gui(filename, 0)) // Add it to end of list | |
1269 result=1; | |
1270 } | |
1271 } | |
1272 | |
1273 mplCurr(); // Update filename | |
1274 mplGotoTheNext=1; | |
1275 | |
1276 if (!enqueue) | |
1277 filename=guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline, | |
1278 // gmplayer does directly start in Play-Mode. | |
1279 else | |
1280 filename=NULL; | |
1281 | |
1282 return result; | |
1283 } | |
1284 | |
1285 // This function imports and inserts an playtree, that is created "on the fly", for example by | |
1286 // parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
1287 // | |
1288 // The file which contained the playlist is thereby replaced with it's contents. | |
1289 | |
1290 int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config) | |
1291 { | |
1292 play_tree_iter_t* my_pt_iter=NULL; | |
1293 int result=0; | |
1294 plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item | |
1295 | |
1296 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
1297 { | |
1298 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
1299 { | |
1300 if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item | |
1301 result=1; | |
1302 } | |
1303 pt_iter_destroy(&my_pt_iter); | |
1304 } | |
1305 | |
1306 if (save) | |
1307 gtkSet(gtkSetCurrPlItem, 0, (void*)save); | |
1308 else | |
1309 gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before | |
1310 | |
1311 if (save && result) | |
1312 gtkSet(gtkDelCurrPlItem, 0, 0); | |
1313 | |
1314 mplCurr(); // Update filename | |
1315 filename=NULL; | |
1316 | |
1317 return result; | |
1318 } | |
1319 | |
1320 // wrapper function for mp_msg to display a message box for errors and warnings. | |
1321 | |
1322 void guiMessageBox(int level, char * str) { | |
1323 switch(level) { | |
1324 case MSGL_FATAL: | |
1325 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, str); | |
1326 break; | |
1327 case MSGL_ERR: | |
1328 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, str); | |
1329 break; | |
1330 #if 0 | |
1331 // WARNING! Do NOT enable this! There are too many non-critical messages with | |
1332 // MSGL_WARN, for example: broken SPU packets, codec's bit error messages, | |
1333 // etc etc, they should not raise up a new window every time. | |
1334 case MSGL_WARN: | |
1335 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, str); | |
1336 break; | |
1337 #endif | |
1338 } | |
1339 } |