Add GUI support for video hardware accelerators.
[vaapi:challenzhous-mplayer.git] / gui / mplayer / gtk / opts.c
1 /*
2  * This file is part of MPlayer.
3  *
4  * MPlayer is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * MPlayer is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include <stdlib.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <unistd.h>
23 #include <string.h>
24
25 #include <gdk/gdkkeysyms.h>
26 #include <gtk/gtk.h>
27
28 #include "config.h"
29 #include "help_mp.h"
30 #include "mixer.h"
31 #include "mpcommon.h"
32 #include "libao2/audio_out.h"
33 #include "sub/sub.h"
34 #include "libvo/video_out.h"
35 #include "libvo/x11_common.h"
36 #include "stream/stream.h"
37 #include "libmpdemux/demuxer.h"
38 #include "libmpdemux/stheader.h"
39 #include "libmpcodecs/dec_video.h"
40 #include "sub/font_load.h"
41
42 #include "gui/app.h"
43 #include "gui/cfg.h"
44 #include "gui/interface.h"
45 #include "gui/mplayer/gmplayer.h"
46 #include "gui/mplayer/widgets.h"
47 #include "opts.h"
48 #include "fs.h"
49 #include "gtk_common.h"
50
51 // for mpcodecs_[av]d_drivers:
52 #include "libmpcodecs/vd.h"
53 #include "libmpcodecs/ad.h"
54
55        GtkWidget * Preferences = NULL;
56 static GtkWidget * AConfig;
57 static GtkWidget * VConfig;
58 //static GtkWidget * BLoadSubtitle;
59 static GtkWidget * BLoadFont;
60 static GtkWidget * BOk;
61 static GtkWidget * BCancel;
62
63 static GtkWidget * CLADrivers;
64 static GtkWidget * CLVDrivers;
65
66 //static GtkWidget * ESubtitleName;
67        GtkWidget * prEFontName;
68        GtkWidget * prEDVDDevice;
69        GtkWidget * prECDRomDevice;
70 static GtkWidget * EVHW;
71 static GtkWidget * EVFM;
72 static GtkWidget * EAFM;
73
74 static GtkWidget * CBVHW;
75 static GtkWidget * CBVFM;
76 static GtkWidget * CBAFM;
77 static GtkWidget * CBAudioEqualizer;
78 //static GtkWidget * CBSurround;
79 static GtkWidget * CBExtraStereo;
80 static GtkWidget * CBNormalize;
81 static GtkWidget * CBSoftwareMixer;
82 static GtkWidget * CBDoubleBuffer;
83 static GtkWidget * CBDR;
84 static GtkWidget * CBFramedrop;
85 static GtkWidget * CBHFramedrop;
86 //static GtkWidget * CBFullScreen;
87 static GtkWidget * CBShowVideoWindow;
88 static GtkWidget * CBNonInterlaved;
89 static GtkWidget * CBIndex;
90 static GtkWidget * CBFlip;
91 static GtkWidget * CBNoAutoSub;
92 static GtkWidget * CBSubUnicode;
93 static GtkWidget * CBSubOverlap;
94 static GtkWidget * CBDumpMPSub;
95 static GtkWidget * CBDumpSrt;
96 static GtkWidget * CBUseASS;
97 static GtkWidget * CBASSUseMargins;
98 static GtkWidget * SBASSTopMargin;
99 static GtkWidget * SBASSBottomMargin;
100 static GtkWidget * CBPostprocess;
101 static GtkWidget * CBCache;
102 static GtkWidget * CBLoadFullscreen;
103 static GtkWidget * CBSaveWinPos;
104 static GtkWidget * CBStopXScreenSaver;
105 static GtkWidget * CBPlayBar;
106
107 static GtkWidget * SBCache;
108 static GtkAdjustment * SBCacheadj;
109
110 static GtkWidget * CBAutoSync;
111 static GtkWidget * SBAutoSync;
112 static GtkAdjustment * SBAutoSyncadj;
113
114 static GtkWidget * RBOSDNone;
115 static GtkWidget * RBOSDTandP;
116 static GtkWidget * RBOSDIndicator;
117 static GtkWidget * RBOSDTPTT;
118
119 static GtkWidget * HSAudioDelay;
120 static GtkWidget * HSExtraStereoMul;
121 static GtkWidget * HSPanscan;
122 static GtkWidget * HSSubDelay;
123 static GtkWidget * HSSubPosition;
124 static GtkWidget * HSSubFPS;
125 static GtkWidget * HSPPQuality;
126 static GtkWidget * HSFPS;
127
128 static GtkAdjustment * HSExtraStereoMuladj, * HSAudioDelayadj, * HSPanscanadj, * HSSubDelayadj;
129 static GtkAdjustment * HSSubPositionadj, * HSSubFPSadj, * HSPPQualityadj, * HSFPSadj;
130
131 #ifndef CONFIG_FREETYPE
132 static GtkWidget     * HSFontFactor;
133 static GtkAdjustment * HSFontFactoradj;
134 #else
135 static GtkWidget     * HSFontBlur, * HSFontOutLine, * HSFontTextScale, * HSFontOSDScale;
136 static GtkAdjustment * HSFontBluradj, * HSFontOutLineadj, * HSFontTextScaleadj, * HSFontOSDScaleadj;
137 static GtkWidget     * CBFontEncoding, * EFontEncoding;
138 static GtkWidget     * RBFontNoAutoScale, * RBFontAutoScaleWidth, * RBFontAutoScaleHeight, * RBFontAutoScaleDiagonal;
139 //static GtkWidget     * AutoScale;
140 #endif
141
142 #ifdef CONFIG_ICONV
143 static GtkWidget     * CBSubEncoding, * ESubEncoding;
144 #endif
145
146 #if defined(CONFIG_FREETYPE) || defined(CONFIG_ICONV)
147 static struct
148 {
149  char * name;
150  char * comment;
151 } lEncoding[] =
152  {
153   { "unicode",     MSGTR_PREFERENCES_FontEncoding1 },
154   { "iso-8859-1",  MSGTR_PREFERENCES_FontEncoding2 },
155   { "iso-8859-15", MSGTR_PREFERENCES_FontEncoding3 },
156   { "iso-8859-2",  MSGTR_PREFERENCES_FontEncoding4 },
157   { "cp1250",      MSGTR_PREFERENCES_FontEncoding22},
158   { "iso-8859-3",  MSGTR_PREFERENCES_FontEncoding5 },
159   { "iso-8859-4",  MSGTR_PREFERENCES_FontEncoding6 },
160   { "iso-8859-5",  MSGTR_PREFERENCES_FontEncoding7 },
161   { "cp1251",      MSGTR_PREFERENCES_FontEncoding21},
162   { "iso-8859-6",  MSGTR_PREFERENCES_FontEncoding8 },
163   { "cp1256",      MSGTR_PREFERENCES_FontEncoding23 },
164   { "iso-8859-7",  MSGTR_PREFERENCES_FontEncoding9 },
165   { "iso-8859-9",  MSGTR_PREFERENCES_FontEncoding10 },
166   { "iso-8859-13", MSGTR_PREFERENCES_FontEncoding11 },
167   { "iso-8859-14", MSGTR_PREFERENCES_FontEncoding12 },
168   { "iso-8859-8",  MSGTR_PREFERENCES_FontEncoding13 },
169   { "koi8-r",      MSGTR_PREFERENCES_FontEncoding14 },
170   { "koi8-u/ru",   MSGTR_PREFERENCES_FontEncoding15 },
171   { "cp936",       MSGTR_PREFERENCES_FontEncoding16 },
172   { "big5",        MSGTR_PREFERENCES_FontEncoding17 },
173   { "shift-jis",   MSGTR_PREFERENCES_FontEncoding18 },
174   { "cp949",       MSGTR_PREFERENCES_FontEncoding19 },
175   { "cp874",       MSGTR_PREFERENCES_FontEncoding20 },
176   { NULL,NULL }
177  };
178 char * lCEncoding = NULL;
179 char * lSEncoding = NULL;
180 #endif
181
182 static int    old_audio_driver = 0;
183 static char * ao_driver[3];
184 static char * vo_driver[3];
185 static int    old_video_driver = 0;
186
187 #ifdef CONFIG_DXR3
188  void ShowDXR3Config( void );
189  void HideDXR3Config( void );
190 #endif
191  void ShowAudioConfig( void );
192  void HideAudioConfig( void );
193
194 static gboolean prHScaler( GtkWidget * widget,GdkEventMotion  * event,gpointer user_data );
195 static void prToggled( GtkToggleButton * togglebutton,gpointer user_data );
196 static void prCListRow( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data );
197 #if defined(CONFIG_FREETYPE) || defined(CONFIG_ICONV)
198 static void prEntry( GtkContainer * container,gpointer user_data );
199 #endif
200
201 void ShowPreferences( void )
202 {
203  if ( Preferences ) gtkActive( Preferences );
204    else Preferences=create_Preferences();
205
206 // -- 1. page
207  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBAudioEqualizer ),gtkEnableAudioEqualizer );
208 #if 0
209  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSurround ),gtkAOSurround );
210 #endif
211  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBExtraStereo ),gtkAOExtraStereo );
212  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBNormalize ),gtkAONorm );
213  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSoftwareMixer ),soft_vol );
214  gtk_adjustment_set_value( HSExtraStereoMuladj,gtkAOExtraStereoMul );
215  {
216   int    i = 0;
217   char * tmp[3]; tmp[2]="";
218   old_audio_driver=-1;
219   if ( CLADrivers ) gtk_clist_clear( GTK_CLIST( CLADrivers ) );
220   while ( audio_out_drivers[i] )
221    {
222     const ao_info_t *info = audio_out_drivers[i++]->info;
223     if ( !strcmp( info->short_name,"plugin" ) ) continue;
224     if ( audio_driver_list )
225      {
226       char * name = gstrdup( audio_driver_list[0] );
227       char * sep = gstrchr( audio_driver_list[0],':' );
228       if ( sep ) *sep=0;
229       if ( !gstrcmp( name,(char *)info->short_name ) ) old_audio_driver=i - 1;
230       free( name );
231      }
232     tmp[0]=(char *)info->short_name; tmp[1]=(char *)info->name; gtk_clist_append( GTK_CLIST( CLADrivers ),tmp );
233    }
234   if ( old_audio_driver > -1 )
235    {
236     gtk_clist_select_row( GTK_CLIST( CLADrivers ),old_audio_driver,0 );
237     gtk_clist_get_text( GTK_CLIST( CLADrivers ),old_audio_driver,0,(char **)&ao_driver );
238     gtk_widget_set_sensitive( AConfig,FALSE );
239     if ( !strncmp( ao_driver[0],"oss",3 ) ||
240          !strncmp( ao_driver[0],"alsa",4 ) ||
241          !strncmp( ao_driver[0],"esd",3 ) ||
242          !strncmp( ao_driver[0],"sdl",3 ) )
243       gtk_widget_set_sensitive( AConfig,TRUE );
244    }
245  }
246
247 // -- 2. page
248  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDoubleBuffer ),vo_doublebuffering );
249  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDR ),vo_directrendering );
250
251  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBFramedrop ),FALSE );
252  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBHFramedrop ),FALSE );
253  switch ( frame_dropping )
254   {
255    case 2: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBHFramedrop ),TRUE );
256    case 1: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBFramedrop ),TRUE );
257   }
258
259  if (flip != -1)
260     gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBFlip ),flip );
261  gtk_adjustment_set_value( HSPanscanadj,vo_panscan );
262
263  {
264   int i = 0, c = 0;
265   char * tmp[3]; tmp[2]="";
266   old_video_driver=0;
267   if ( CLVDrivers ) gtk_clist_clear( GTK_CLIST( CLVDrivers ) );
268   while ( video_out_drivers[i] )
269    if ( video_out_drivers[i++]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE )
270     {
271      if ( video_driver_list && !gstrcmp( video_driver_list[0],(char *)video_out_drivers[i - 1]->info->short_name ) ) old_video_driver=c; c++;
272      tmp[0]=(char *)video_out_drivers[i - 1]->info->short_name; tmp[1]=(char *)video_out_drivers[i - 1]->info->name;
273      gtk_clist_append( GTK_CLIST( CLVDrivers ),tmp );
274     }
275   gtk_clist_select_row( GTK_CLIST( CLVDrivers ),old_video_driver,0 );
276   gtk_clist_get_text( GTK_CLIST( CLVDrivers ),old_video_driver,0,(char **)&vo_driver );
277   gtk_widget_set_sensitive( VConfig,FALSE );
278 #ifdef CONFIG_DXR3
279   if ( !gstrcmp( vo_driver[0],"dxr3" ) ) gtk_widget_set_sensitive( VConfig,TRUE );
280 #endif
281  }
282
283   gtk_adjustment_set_value( HSFPSadj,force_fps );
284
285 // -- 3. page
286  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSubOverlap ),suboverlap_enabled );
287  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBNoAutoSub ),!sub_auto );
288  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDumpMPSub ),gtkSubDumpMPSub );
289  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDumpSrt ),gtkSubDumpSrt );
290  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSubUnicode ),sub_unicode );
291 #ifdef CONFIG_ASS
292  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBUseASS ),gtkASS.enabled );
293  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBASSUseMargins ),gtkASS.use_margins );
294  gtk_spin_button_set_value( (GtkSpinButton *)SBASSTopMargin,(gdouble)gtkASS.top_margin );
295  gtk_spin_button_set_value( (GtkSpinButton *)SBASSBottomMargin,(gdouble)gtkASS.bottom_margin );
296
297  if ( !gtkASS.enabled )
298   {
299    gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
300    gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
301    gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
302   }
303 #endif
304
305  gtk_adjustment_set_value( HSSubDelayadj,sub_delay );
306  gtk_adjustment_set_value( HSSubFPSadj,sub_fps );
307  gtk_adjustment_set_value( HSSubPositionadj,sub_pos );
308  switch ( osd_level )
309   {
310    case 0: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBOSDNone ),TRUE ); break;
311    case 1: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBOSDIndicator ),TRUE ); break;
312    case 2: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBOSDTandP ),TRUE ); break;
313    case 3: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBOSDTPTT ),TRUE ); break;
314   }
315 #if 0
316  if ( guiIntfStruct.Subtitlename ) gtk_entry_set_text( GTK_ENTRY( ESubtitleName ),guiIntfStruct.Subtitlename );
317 #endif
318
319 #ifdef CONFIG_ICONV
320  if ( sub_cp )
321   {
322    int i;
323    for ( i=0;lEncoding[i].name;i++ )
324     if ( !gstrcmp( sub_cp,lEncoding[i].name ) ) break;
325    if ( lEncoding[i].name ) lSEncoding=lEncoding[i].comment;
326    gtk_entry_set_text( GTK_ENTRY( ESubEncoding ),lSEncoding );
327   }
328 #endif
329
330 // --- 4. page
331  // font ...
332  if ( font_name ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name );
333 #ifndef CONFIG_FREETYPE
334  gtk_adjustment_set_value( HSFontFactoradj,font_factor );
335 #else
336  gtk_adjustment_set_value( HSFontBluradj,( subtitle_font_radius / 8.0f ) * 100.0f );
337  gtk_adjustment_set_value( HSFontOutLineadj,( subtitle_font_thickness / 8.0f ) * 100.0f );
338  gtk_adjustment_set_value( HSFontTextScaleadj,text_font_scale_factor );
339  gtk_adjustment_set_value( HSFontOSDScaleadj,osd_font_scale_factor );
340  if ( subtitle_font_encoding )
341   {
342    int i;
343    for ( i=0;lEncoding[i].name;i++ )
344     if ( !gstrcmp( subtitle_font_encoding,lEncoding[i].name ) ) break;
345    if ( lEncoding[i].name ) lCEncoding=lEncoding[i].comment;
346    gtk_entry_set_text( GTK_ENTRY( EFontEncoding ),lCEncoding );
347   }
348  switch ( subtitle_autoscale )
349   {
350    case 0: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBFontNoAutoScale ),TRUE ); break;
351    case 1: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleHeight ),TRUE ); break;
352    case 2: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleWidth ),TRUE ); break;
353    case 3: gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleDiagonal ),TRUE ); break;
354   }
355 #endif
356
357 // -- 5. page
358  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBNonInterlaved ),force_ni );
359  if ( index_mode == 1 ) gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBIndex ),1 );
360
361  {
362      int     i;
363      GList * Items = NULL;
364      char  * name  = NULL;
365
366      Items = g_list_append(Items, MSGTR_PREFERENCES_None);
367      for (i = 0; i < HWACCEL_COUNT; i++) {
368          const char *hwaccel_name = get_video_hwaccel_name(i);
369          if (!hwaccel_name)
370              continue;
371          Items = g_list_append(Items, hwaccel_name);
372          if (video_hwaccel_name && !gstrcmp(video_hwaccel_name, get_video_hwaccel_short_name(i) ) ) name = hwaccel_name;
373      }
374      gtk_combo_set_popdown_strings(GTK_COMBO(CBVHW), Items);
375      g_list_free(Items);
376      if (name)
377          gtk_entry_set_text(GTK_ENTRY(EVHW), name);
378  }
379
380  {
381   int     i;
382   GList * Items = NULL;
383   char  * name = NULL;
384
385   Items=g_list_append( Items,MSGTR_PREFERENCES_None );
386   for( i=0;mpcodecs_vd_drivers[i];i++ )
387    {
388     Items=g_list_append( Items,(char *)mpcodecs_vd_drivers[i]->info->name );
389     if ( video_fm_list && !gstrcmp( video_fm_list[0],(char *)mpcodecs_vd_drivers[i]->info->short_name ) ) name=(char *)mpcodecs_vd_drivers[i]->info->name;
390    }
391   gtk_combo_set_popdown_strings( GTK_COMBO( CBVFM ),Items );
392   g_list_free( Items );
393   if ( name ) gtk_entry_set_text( GTK_ENTRY( EVFM ),name );
394  }
395
396  {
397   int     i;
398   GList * Items = NULL;
399   char  * name = NULL;
400
401   Items=g_list_append( Items,MSGTR_PREFERENCES_None );
402   for( i=0;mpcodecs_ad_drivers[i];i++ )
403    {
404     Items=g_list_append( Items,(char *)mpcodecs_ad_drivers[i]->info->name );
405     if ( audio_fm_list && !gstrcmp( audio_fm_list[0],(char *)mpcodecs_ad_drivers[i]->info->short_name ) ) name=(char *)mpcodecs_ad_drivers[i]->info->name;
406    }
407   gtk_combo_set_popdown_strings( GTK_COMBO( CBAFM ),Items );
408   g_list_free( Items );
409   if ( name ) gtk_entry_set_text( GTK_ENTRY( EAFM ),name );
410  }
411
412 // --- 6. page
413  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBPostprocess ),gtkVfPP );
414  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ),gtkLoadFullscreen );
415  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBSaveWinPos ),gui_save_pos );
416  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBShowVideoWindow ),gtkShowVideoWindow );
417  if ( !gtkShowVideoWindow )
418   {
419    gtk_widget_set_sensitive( CBLoadFullscreen,FALSE );
420    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ),0 );
421   }
422  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBStopXScreenSaver ),stop_xscreensaver );
423  gtk_adjustment_set_value( HSPPQualityadj,auto_quality );
424
425  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBPlayBar ),gtkEnablePlayBar );
426  if ( !appMPlayer.barIsPresent )
427   {
428    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBPlayBar ),0 );
429    gtk_widget_set_sensitive( CBPlayBar,FALSE );
430   }
431
432  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBCache ),0 );
433  gtk_adjustment_set_value( SBCacheadj,(float)gtkCacheSize );
434  if ( !gtkCacheOn ) gtk_widget_set_sensitive( SBCache,FALSE );
435   else gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBCache ),TRUE );
436
437  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBAutoSync ),0 );
438  gtk_adjustment_set_value( SBAutoSyncadj,(float)gtkAutoSync );
439  if ( !gtkAutoSyncOn ) gtk_widget_set_sensitive( SBAutoSync,FALSE );
440   else gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBAutoSync ),TRUE );
441
442  if ( dvd_device ) gtk_entry_set_text( GTK_ENTRY( prEDVDDevice ),dvd_device );
443   else gtk_entry_set_text( GTK_ENTRY( prEDVDDevice ),DEFAULT_DVD_DEVICE );
444  if ( cdrom_device ) gtk_entry_set_text( GTK_ENTRY( prECDRomDevice ),cdrom_device );
445   else gtk_entry_set_text( GTK_ENTRY( prECDRomDevice ),DEFAULT_CDROM_DEVICE );
446
447 // -- disables
448 #ifndef CONFIG_ASS
449  gtk_widget_set_sensitive( CBUseASS,FALSE );
450  gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
451  gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
452  gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
453 #endif
454
455 // -- signals
456  gtk_signal_connect( GTK_OBJECT( CBExtraStereo ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)0 );
457  gtk_signal_connect( GTK_OBJECT( CBNormalize ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)1 );
458  gtk_signal_connect( GTK_OBJECT( CBSoftwareMixer ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)1 );
459  gtk_signal_connect( GTK_OBJECT( CBAudioEqualizer ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)2 );
460  gtk_signal_connect( GTK_OBJECT( CBShowVideoWindow ),"toggled",GTK_SIGNAL_FUNC( prToggled ), (void*)3 );
461 #ifdef CONFIG_FREETYPE
462  gtk_signal_connect( GTK_OBJECT( RBFontNoAutoScale ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)4 );
463  gtk_signal_connect( GTK_OBJECT( RBFontAutoScaleHeight ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)5 );
464  gtk_signal_connect( GTK_OBJECT( RBFontAutoScaleWidth ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)6 );
465  gtk_signal_connect( GTK_OBJECT( RBFontAutoScaleDiagonal ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)7 );
466 #endif
467  gtk_signal_connect( GTK_OBJECT( CBCache ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)8);
468  gtk_signal_connect( GTK_OBJECT( CBAutoSync ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)9);
469 #ifdef CONFIG_ASS
470  gtk_signal_connect( GTK_OBJECT( CBUseASS ),"toggled",GTK_SIGNAL_FUNC( prToggled ),(void*)10);
471 #endif
472
473  gtk_signal_connect( GTK_OBJECT( HSExtraStereoMul ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)0 );
474  gtk_signal_connect( GTK_OBJECT( HSAudioDelay ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)1 );
475  gtk_signal_connect( GTK_OBJECT( HSPanscan ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)2 );
476  gtk_signal_connect( GTK_OBJECT( HSSubDelay ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)3 );
477  gtk_signal_connect( GTK_OBJECT( HSSubPosition ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)4 );
478 #ifndef CONFIG_FREETYPE
479  gtk_signal_connect( GTK_OBJECT( HSFontFactor ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)5 );
480 #else
481  gtk_signal_connect( GTK_OBJECT( HSFontBlur ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)6 );
482  gtk_signal_connect( GTK_OBJECT( HSFontOutLine ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)7 );
483  gtk_signal_connect( GTK_OBJECT( HSFontTextScale ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)8 );
484  gtk_signal_connect( GTK_OBJECT( HSFontOSDScale ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)9 );
485  gtk_signal_connect( GTK_OBJECT( EFontEncoding ),"changed",GTK_SIGNAL_FUNC( prEntry ),(void *)0 );
486 #endif
487 #ifdef CONFIG_ICONV
488  gtk_signal_connect( GTK_OBJECT( ESubEncoding ),"changed",GTK_SIGNAL_FUNC( prEntry ),(void *)1 );
489 #endif
490  gtk_signal_connect( GTK_OBJECT( HSPPQuality ),"motion_notify_event",GTK_SIGNAL_FUNC( prHScaler ),(void*)10 );
491
492  gtk_signal_connect( GTK_OBJECT( CLADrivers ),"select_row",GTK_SIGNAL_FUNC( prCListRow ),(void*)0 );
493  gtk_signal_connect( GTK_OBJECT( CLVDrivers ),"select_row",GTK_SIGNAL_FUNC( prCListRow ),(void*)1 );
494
495  gtk_widget_show( Preferences );
496  gtkSetLayer( Preferences );
497  {
498   static int visible = 1;
499   if ( visible )
500    {
501     gtkMessageBox( GTK_MB_WARNING,MSGTR_PREFERENCES_Message );
502     visible=0;
503    }
504  }
505 }
506
507 static void HidePreferences( void )
508 {
509  if ( !Preferences ) return;
510  gtk_widget_hide( Preferences );
511  gtk_widget_destroy( Preferences );
512  Preferences=NULL;
513  HideAudioConfig();
514 #ifdef CONFIG_DXR3
515  HideDXR3Config();
516 #endif
517 }
518
519 #if defined(CONFIG_FREETYPE) || defined(CONFIG_ICONV)
520 static void prEntry( GtkContainer * container,gpointer user_data )
521 {
522  const char * comment;
523  int    i;
524
525  switch( (int)user_data )
526   {
527 #ifdef CONFIG_FREETYPE
528    case 0: // font encoding
529         comment=gtk_entry_get_text( GTK_ENTRY( EFontEncoding ) );
530         for ( i=0;lEncoding[i].name;i++ )
531           if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
532         if ( lEncoding[i].comment ) gtkSet( gtkSetFontEncoding,0,lEncoding[i].name );
533         break;
534 #endif
535 #ifdef CONFIG_ICONV
536    case 1: // sub encoding
537         comment=gtk_entry_get_text( GTK_ENTRY( ESubEncoding ) );
538         for ( i=0;lEncoding[i].name;i++ )
539           if ( !gstrcmp( lEncoding[i].comment,comment ) ) break;
540         if ( lEncoding[i].comment ) gtkSet( gtkSetSubEncoding,0,lEncoding[i].name );
541          else gtkSet( gtkSetSubEncoding,0,NULL );
542         break;
543 #endif
544   }
545 }
546 #endif
547
548 #define bAConfig   0
549 #define bVconfig   1
550 #define bOk        2
551 #define bCancel    3
552 #define bLSubtitle 4
553 #define bLFont     5
554
555 static void prButton( GtkButton * button, gpointer user_data )
556 {
557  switch ( (int)user_data )
558   {
559    case bOk:
560         // -- 1. page
561         gtkEnableAudioEqualizer=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBAudioEqualizer ) );
562         gtkAOExtraStereo=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBExtraStereo ) );
563         gtkAONorm=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBNormalize ) );
564         soft_vol=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSoftwareMixer ) );
565         gtkSet( gtkSetExtraStereo,HSExtraStereoMuladj->value,NULL );
566         audio_delay=HSAudioDelayadj->value;
567
568         gaddlist( &audio_driver_list,ao_driver[0] );
569         gaddlist( &video_driver_list,vo_driver[0] );
570
571         // -- 2. page
572         vo_doublebuffering=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDoubleBuffer ) );
573         vo_directrendering=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDR ) );
574
575         frame_dropping=0;
576         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBFramedrop ) ) == TRUE ) frame_dropping=1;
577         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBHFramedrop ) ) == TRUE ) frame_dropping=2;
578
579         flip=-1;
580         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBFlip ) ) ) flip=1;
581
582         force_fps=HSFPSadj->value;
583
584         // -- 3. page
585         suboverlap_enabled=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSubOverlap ) );
586         sub_auto=!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBNoAutoSub ) );
587         gtkSubDumpMPSub=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDumpMPSub ) );
588         gtkSubDumpSrt=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDumpSrt ) );
589         sub_unicode=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSubUnicode ) );
590 #ifdef CONFIG_ASS
591         gtkASS.enabled=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBUseASS ) );
592         gtkASS.use_margins=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBASSUseMargins ) );
593         gtkASS.top_margin=gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( SBASSTopMargin ) );
594         gtkASS.bottom_margin=gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( SBASSBottomMargin ) );
595 #endif
596         sub_delay=HSSubDelayadj->value;
597         sub_fps=HSSubFPSadj->value;
598         sub_pos=(int)HSSubPositionadj->value;
599         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDNone ) ) ) osd_level=0;
600         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDIndicator ) ) ) osd_level=1;
601         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDTandP ) ) ) osd_level=2;
602         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBOSDTPTT ) ) ) osd_level=3;
603
604
605         // --- 4. page
606         guiSetFilename( font_name,gtk_entry_get_text( GTK_ENTRY( prEFontName ) ) );
607 #ifndef CONFIG_FREETYPE
608         gtkSet( gtkSetFontFactor,HSFontFactoradj->value,NULL );
609 #else
610         gtkSet( gtkSetFontBlur,HSFontBluradj->value,NULL );
611         gtkSet( gtkSetFontOutLine,HSFontOutLineadj->value,NULL );
612         gtkSet( gtkSetFontTextScale,HSFontTextScaleadj->value,NULL );
613         gtkSet( gtkSetFontOSDScale,HSFontOSDScaleadj->value,NULL );
614         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontNoAutoScale ) ) ) gtkSet( gtkSetFontAutoScale,0,NULL );
615         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleHeight ) ) ) gtkSet( gtkSetFontAutoScale,1,NULL );
616         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleWidth ) ) ) gtkSet( gtkSetFontAutoScale,2,NULL );
617         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleDiagonal ) ) ) gtkSet( gtkSetFontAutoScale,3,NULL );
618 #endif
619
620         // -- 5. page
621         force_ni=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBNonInterlaved ) );
622         index_mode=-1;
623         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBIndex ) ) ) index_mode=1;
624
625         {
626             int i;
627             const char *tmp = gtk_entry_get_text(GTK_ENTRY(EVHW));
628             for (i = 0; i < HWACCEL_COUNT; i++) {
629                 if (!gstrcmp(tmp, get_video_hwaccel_name(i))) {
630                     video_hwaccel_name = get_video_hwaccel_short_name(i);
631                     break;
632                 }
633             }
634         }
635
636         {
637          int i;
638          const char * tmp = gtk_entry_get_text( GTK_ENTRY( EVFM ) );
639          for( i=0;mpcodecs_vd_drivers[i];i++ )
640           if ( !gstrcmp( tmp,(char *)mpcodecs_vd_drivers[i]->info->name ) )
641            { gaddlist( &video_fm_list,(char *)mpcodecs_vd_drivers[i]->info->short_name ); break; }
642         }
643
644         {
645          int i;
646          const char * tmp = gtk_entry_get_text( GTK_ENTRY( EAFM ) );
647          for( i=0;mpcodecs_ad_drivers[i];i++ )
648           if ( !gstrcmp( tmp,(char *)mpcodecs_ad_drivers[i]->info->name ) )
649            { gaddlist( &audio_fm_list,(char *)mpcodecs_ad_drivers[i]->info->short_name ); break; }
650         }
651
652         // --- 6. page
653         gtkVfPP=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBPostprocess ) );
654         gtkLoadFullscreen=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ) );
655         gui_save_pos=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSaveWinPos ) );
656         gtkShowVideoWindow=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBShowVideoWindow ) );
657         stop_xscreensaver=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBStopXScreenSaver ) );
658         gtkEnablePlayBar=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBPlayBar ) );
659         gtkSet( gtkSetAutoq,HSPPQualityadj->value,NULL );
660
661         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBCache ) ) ) { gtkCacheSize=(int)SBCacheadj->value; gtkCacheOn=1; }
662          else gtkCacheOn=0;
663
664         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBAutoSync ) ) ) { gtkAutoSync=(int)SBAutoSyncadj->value; gtkAutoSyncOn=1; }
665          else gtkAutoSyncOn=0;
666
667         guiSetFilename( dvd_device,gtk_entry_get_text( GTK_ENTRY( prEDVDDevice ) ) );
668         guiSetFilename( cdrom_device,gtk_entry_get_text( GTK_ENTRY( prECDRomDevice ) ) );
669
670    case bCancel:
671         HidePreferences();
672         break;
673    case bAConfig:
674         if ( !ao_driver[0] ) break;
675         gtk_widget_set_sensitive( AConfig,FALSE );
676         if ( !strncmp( ao_driver[0],"oss",3 ) ||
677              !strncmp( ao_driver[0],"alsa",4 ) ||
678              !strncmp( ao_driver[0],"esd",3 ) ||
679              !strncmp( ao_driver[0],"sdl",3 ) ) {
680           ShowAudioConfig();
681           gtk_widget_set_sensitive( AConfig,TRUE );
682         }
683         break;
684    case bVconfig:
685         if ( !vo_driver[0] ) break;
686         gtk_widget_set_sensitive( VConfig,FALSE );
687 #ifdef CONFIG_DXR3
688         if ( !gstrcmp( vo_driver[0],"dxr3" ) ) { ShowDXR3Config(); gtk_widget_set_sensitive( VConfig,TRUE ); }
689 #endif
690         break;
691 #if 0
692    case bLSubtitle:
693         break;
694 #endif
695    case bLFont:
696         ShowFileSelect( fsFontSelector,FALSE );
697         gtkSetLayer( fsFileSelect );
698         break;
699   }
700 }
701
702 static gboolean prHScaler( GtkWidget * widget,GdkEventMotion  * event,gpointer user_data )
703 {
704  switch ( (int)user_data )
705   {
706    case 0: // extra stereo coefficient
707         if ( !guiIntfStruct.Playing ) break;
708         gtkSet( gtkSetExtraStereo,HSExtraStereoMuladj->value,NULL );
709         break;
710    case 1: // audio delay
711         audio_delay=HSAudioDelayadj->value;
712         break;
713    case 2: // panscan
714         gtkSet( gtkSetPanscan,HSPanscanadj->value,NULL );
715         break;
716    case 3: // sub delay
717         sub_delay=HSSubDelayadj->value;
718         break;
719    case 4: // sub position
720         sub_pos=(int)HSSubPositionadj->value;
721         break;
722 #ifndef CONFIG_FREETYPE
723    case 5: // font factor
724         gtkSet( gtkSetFontFactor,HSFontFactoradj->value,NULL );
725         break;
726 #else
727    case 6: // font blur
728         gtkSet( gtkSetFontBlur,HSFontBluradj->value,NULL );
729         break;
730    case 7: // font outline
731         gtkSet( gtkSetFontOutLine,HSFontOutLineadj->value,NULL );
732         break;
733    case 8: // text scale
734         gtkSet( gtkSetFontTextScale,HSFontTextScaleadj->value,NULL );
735         break;
736    case 9: // osd scale
737         gtkSet( gtkSetFontOSDScale,HSFontOSDScaleadj->value,NULL );
738         break;
739 #endif
740    case 10: // auto quality
741         gtkSet( gtkSetAutoq,HSPPQualityadj->value,NULL );
742         break;
743   }
744  return FALSE;
745 }
746
747 static void prToggled( GtkToggleButton * togglebutton,gpointer user_data )
748 {
749  int window;
750  switch ( (int)user_data )
751   {
752    case 0: // extra stereo coefficient
753         if ( guiIntfStruct.Playing )
754         gtk_widget_set_sensitive( HSExtraStereoMul,gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBExtraStereo ) ) );
755         break;
756 //   case 1: // normalize
757 //   case 2: // equalizer
758 //      if ( guiIntfStruct.Playing ) gtkMessageBox( GTK_MB_WARNING,"Please remember, this function need restart the playing." );
759 //      break;
760    case 3:
761         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBShowVideoWindow ) ) ) gtk_widget_set_sensitive( CBLoadFullscreen,TRUE );
762          else
763           {
764            gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ),0 );
765            gtk_widget_set_sensitive( CBLoadFullscreen,FALSE );
766           }
767         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBShowVideoWindow ) ) )
768          {
769           window=wsShowWindow;
770           gtkActive( Preferences );
771          } else window=wsHideWindow;
772
773         if ( !guiIntfStruct.Playing ) wsVisibleWindow( &appMPlayer.subWindow,window );
774         break;
775    case 4:
776    case 5:
777    case 6:
778    case 7:
779         gtkSet( gtkSetFontAutoScale,(float)((int)user_data - 4 ),NULL );
780         break;
781    case 8:
782         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBCache ) ) ) gtk_widget_set_sensitive( SBCache,TRUE );
783          else gtk_widget_set_sensitive( SBCache,FALSE );
784         break;
785    case 9:
786         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBAutoSync ) ) ) gtk_widget_set_sensitive( SBAutoSync,TRUE );
787          else gtk_widget_set_sensitive( SBAutoSync,FALSE );
788         break;
789 #ifdef CONFIG_ASS
790    case 10:
791         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBUseASS ) ) )
792          {
793           gtk_widget_set_sensitive( CBASSUseMargins,TRUE );
794           gtk_widget_set_sensitive( SBASSTopMargin,TRUE );
795           gtk_widget_set_sensitive( SBASSBottomMargin,TRUE );
796          }
797         else
798          {
799           gtk_widget_set_sensitive( CBASSUseMargins,FALSE );
800           gtk_widget_set_sensitive( SBASSTopMargin,FALSE );
801           gtk_widget_set_sensitive( SBASSBottomMargin,FALSE );
802          }
803         break;
804 #endif
805   }
806 }
807
808 static void prCListRow( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data )
809 {
810  switch ( (int)user_data )
811   {
812    case 0: // audio driver
813         gtk_clist_get_text( GTK_CLIST( CLADrivers ),row,0,(char **)&ao_driver );
814         gtk_widget_set_sensitive( AConfig,FALSE );
815         if ( !strncmp( ao_driver[0],"oss",3 ) ||
816              !strncmp( ao_driver[0],"alsa",4 ) ||
817              !strncmp( ao_driver[0],"esd",3 ) ||
818              !strncmp( ao_driver[0],"sdl",3 ) )
819           gtk_widget_set_sensitive( AConfig,TRUE );
820 #ifndef CONFIG_GTK2
821         if ( !strncmp( ao_driver[0],"arts",4 ) )
822           gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, MSGTR_PREFERENCES_ArtsBroken);
823 #endif
824         break;
825    case 1: // video driver
826         gtk_clist_get_text( GTK_CLIST( CLVDrivers ),row,0,(char **)&vo_driver );
827         gtk_widget_set_sensitive( VConfig,FALSE );
828 #ifdef CONFIG_DXR3
829         if ( !gstrcmp( vo_driver[0],"dxr3" ) ) gtk_widget_set_sensitive( VConfig,TRUE );
830 #endif
831         break;
832   }
833 }
834
835 GtkWidget * create_Preferences( void )
836 {
837   GtkWidget * label;
838   GtkWidget * frame;
839
840   GtkWidget * vbox1;
841   GtkWidget * notebook1;
842   GtkWidget * hbox1;
843   GtkWidget * vbox2;
844   GtkWidget * scrolledwindow3;
845   GtkWidget * vbox3;
846   GtkWidget * hbox8;
847   GtkWidget * hbox2;
848   GtkWidget * vbox4;
849   GtkWidget * scrolledwindow2;
850   GtkWidget * hbuttonbox3;
851   GtkWidget * vbox5;
852   GtkWidget * vbox6;
853   GtkWidget * vbox600;
854   GSList    * OSD_group = NULL;
855 #ifdef CONFIG_ICONV
856   GSList    * Font_group = NULL;
857   GList     * CBFontEncoding_items = NULL;
858   GList     * CBSubEncoding_items = NULL;
859 #endif
860   GtkWidget * vbox7;
861   GtkWidget * vbox8;
862   GtkWidget * table1;
863   GtkWidget * vbox9;
864   GtkWidget * vbox603;
865   GtkWidget * hbox6;
866   GtkWidget * hbuttonbox5;
867 #ifndef CONFIG_FREETYPE
868   GtkWidget * hbox7;
869 #endif
870   GtkWidget * vbox601;
871   GtkWidget * vbox602;
872   GtkWidget * hbox5;
873   GtkWidget * hbuttonbox1;
874   GtkAccelGroup * accel_group;
875
876   GtkWidget * hbox9;
877   GtkWidget * hbox91;
878   GtkWidget * hbox92;
879
880   accel_group=gtk_accel_group_new();
881
882   Preferences=gtk_window_new( GTK_WINDOW_TOPLEVEL );
883   gtk_widget_set_name( Preferences,"Preferences" );
884   gtk_object_set_data( GTK_OBJECT( Preferences ),"Preferences",Preferences );
885   gtk_window_set_title( GTK_WINDOW( Preferences ),MSGTR_Preferences );
886   gtk_window_set_position( GTK_WINDOW( Preferences ),GTK_WIN_POS_CENTER );
887 //  gtk_window_set_policy( GTK_WINDOW( Preferences ),FALSE,FALSE,FALSE );
888   gtk_window_set_wmclass( GTK_WINDOW( Preferences ),"Preferences","MPlayer" );
889
890   gtk_widget_realize( Preferences );
891   gtkAddIcon( Preferences );
892
893   vbox1=AddVBox( AddDialogFrame( Preferences ),0 );
894   notebook1=gtk_notebook_new();
895   gtk_widget_set_name( notebook1,"notebook1" );
896   gtk_widget_show( notebook1 );
897   gtk_box_pack_start( GTK_BOX( vbox1 ),notebook1,TRUE,TRUE,0 );
898
899   hbox1=AddVBox( notebook1,0 );
900
901   frame=AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,hbox1,1 );
902   frame=AddFrame( NULL,GTK_SHADOW_NONE,frame,1 );
903
904 // --- 1. page
905
906   vbox2=AddVBox( frame,0 );
907
908   scrolledwindow3=gtk_scrolled_window_new( NULL,NULL );
909   gtk_widget_set_name( scrolledwindow3,"scrolledwindow3" );
910   gtk_widget_show( scrolledwindow3 );
911   gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 );
912   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC );
913
914   CLADrivers=gtk_clist_new( 2 );
915   gtk_widget_set_name( CLADrivers,"CLADrivers" );
916   gtk_widget_show( CLADrivers );
917   gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLADrivers );
918   gtk_clist_set_column_width( GTK_CLIST( CLADrivers ),0,50 );
919   gtk_clist_column_titles_show( GTK_CLIST( CLADrivers ) );
920   gtk_clist_set_shadow_type( GTK_CLIST( CLADrivers ),GTK_SHADOW_NONE );
921   gtk_widget_set_usize( CLADrivers,250,-2 );
922   gtk_clist_set_column_widget( GTK_CLIST( CLADrivers ),0,
923     AddLabel( MSGTR_PREFERENCES_AvailableDrivers,NULL ) );
924
925   AConfig=AddButton( MSGTR_ConfigDriver,
926     AddHButtonBox( vbox2 ) );
927
928   vbox3=AddVBox(
929     AddFrame( NULL,GTK_SHADOW_NONE,
930       AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,hbox1,0 ),1 ),0 );
931     gtk_widget_set_usize( vbox3,250,-2 );
932
933   CBNormalize=AddCheckButton( MSGTR_PREFERENCES_NormalizeSound,vbox3 );
934   CBAudioEqualizer=AddCheckButton( MSGTR_PREFERENCES_EnableEqualizer,vbox3 );
935   CBSoftwareMixer=AddCheckButton( MSGTR_PREFERENCES_SoftwareMixer,vbox3 );
936 #if 0
937   CBSurround=AddCheckButton( "Enable surround",vbox3 );
938 #endif
939
940   AddHSeparator( vbox3 );
941   CBExtraStereo=AddCheckButton( MSGTR_PREFERENCES_ExtraStereo,vbox3 );
942   hbox8=AddHBox( vbox3,1 );
943   label=AddLabel( MSGTR_PREFERENCES_Coefficient,hbox8 );
944 //    gtk_misc_set_padding( GTK_MISC( label ),20,0 );
945   HSExtraStereoMuladj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-10,10,0.1,0,0 ) );
946   HSExtraStereoMul=AddHScaler( HSExtraStereoMuladj,hbox8,1 );
947   AddHSeparator( vbox3 );
948
949   hbox8=AddHBox( vbox3,1 );
950   AddLabel( MSGTR_PREFERENCES_AudioDelay,hbox8 );
951
952   HSAudioDelayadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-10,10,0.01,0,0 ) );
953   HSAudioDelay=AddHScaler( HSAudioDelayadj,hbox8,2 );
954   label=AddLabel( MSGTR_PREFERENCES_Audio,NULL );
955     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),0 ),label );
956
957 // --- 2. page
958
959   hbox2=AddVBox( notebook1,0 );
960
961   vbox4=AddVBox(
962     AddFrame( NULL,GTK_SHADOW_NONE,
963       AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,hbox2,1 ),1 ),0 );
964
965   scrolledwindow2=gtk_scrolled_window_new( NULL,NULL );
966   gtk_widget_set_name( scrolledwindow2,"scrolledwindow2" );
967   gtk_widget_show( scrolledwindow2 );
968   gtk_box_pack_start( GTK_BOX( vbox4 ),scrolledwindow2,TRUE,TRUE,0 );
969   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC );
970
971   CLVDrivers=gtk_clist_new( 2 );
972   gtk_widget_set_name( CLVDrivers,"CLVDrivers" );
973   gtk_widget_show( CLVDrivers );
974   gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLVDrivers );
975   gtk_clist_set_column_width( GTK_CLIST( CLVDrivers ),0,50 );
976   gtk_clist_column_titles_show( GTK_CLIST( CLVDrivers ) );
977   gtk_clist_set_shadow_type( GTK_CLIST( CLVDrivers ),GTK_SHADOW_NONE );
978   gtk_widget_set_usize( CLVDrivers,250,-2 );
979
980   label=AddLabel( MSGTR_PREFERENCES_AvailableDrivers,NULL );
981     gtk_clist_set_column_widget( GTK_CLIST( CLVDrivers ),0,label );
982
983   hbuttonbox3=AddHButtonBox( vbox4 );
984   VConfig=AddButton( MSGTR_ConfigDriver,hbuttonbox3 );
985
986   vbox5=AddVBox(
987     AddFrame( NULL,GTK_SHADOW_NONE,
988       AddFrame( NULL,GTK_SHADOW_ETCHED_OUT,hbox2,0 ),1 ),0 );
989     gtk_widget_set_usize( vbox5,250,-2 );
990
991   CBDoubleBuffer=AddCheckButton( MSGTR_PREFERENCES_DoubleBuffer,vbox5 );
992   CBDR=AddCheckButton( MSGTR_PREFERENCES_DirectRender,vbox5 );
993   CBFramedrop=AddCheckButton( MSGTR_PREFERENCES_FrameDrop,vbox5 );
994   CBHFramedrop=AddCheckButton( MSGTR_PREFERENCES_HFrameDrop,vbox5 );
995   CBFlip=AddCheckButton( MSGTR_PREFERENCES_Flip,vbox5 );
996
997   table1=gtk_table_new( 3,2,FALSE );
998   gtk_widget_set_name( table1,"table1" );
999   gtk_widget_show( table1 );
1000   gtk_box_pack_start( GTK_BOX( vbox5 ),table1,FALSE,FALSE,0 );
1001
1002   label=AddLabel( MSGTR_PREFERENCES_Panscan,NULL );
1003     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1004
1005   label=AddLabel( MSGTR_PREFERENCES_FPS,NULL );
1006     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1007
1008   HSPanscanadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,1,0.001,0,0 ) );
1009   HSPanscan=AddHScaler( HSPanscanadj,NULL,1 );
1010     gtk_table_attach( GTK_TABLE( table1 ),HSPanscan,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1011
1012   HSFPSadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,1000,0.001,0,0 ) );
1013   HSFPS=gtk_spin_button_new( GTK_ADJUSTMENT( HSFPSadj ),1,3 );
1014     gtk_widget_set_name( HSFPS,"HSFPS" );
1015     gtk_widget_show( HSFPS );
1016     gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( HSFPS ),TRUE );
1017     gtk_table_attach( GTK_TABLE( table1 ),HSFPS,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1018
1019   label=AddLabel( MSGTR_PREFERENCES_Video,NULL );
1020     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),1 ),label );
1021
1022 // --- 3. page
1023
1024   vbox6=AddVBox( notebook1,0 );
1025
1026   vbox600=AddVBox(
1027     AddFrame( NULL,GTK_SHADOW_NONE,
1028       AddFrame( MSGTR_PREFERENCES_FRAME_OSD_Level,GTK_SHADOW_ETCHED_OUT,vbox6,0 ),1 ),0 );
1029
1030   RBOSDNone=AddRadioButton( MSGTR_PREFERENCES_None,&OSD_group,vbox600 );
1031   RBOSDTandP=AddRadioButton( MSGTR_PREFERENCES_OSDTimer,&OSD_group,vbox600 );
1032   RBOSDIndicator=AddRadioButton( MSGTR_PREFERENCES_OSDProgress,&OSD_group,vbox600 );
1033   RBOSDTPTT=AddRadioButton( MSGTR_PREFERENCES_OSDTimerPercentageTotalTime,&OSD_group,vbox600 );
1034
1035   vbox7=AddVBox(
1036     AddFrame( NULL,GTK_SHADOW_NONE,
1037       AddFrame( MSGTR_PREFERENCES_FRAME_Subtitle,GTK_SHADOW_ETCHED_OUT,vbox6,0 ),1 ),0 );
1038
1039 #if 0
1040   hbox4=AddHBox( vbox7,1 );
1041
1042   AddLabel( MSGTR_PREFERENCES_Subtitle,hbox4 );
1043
1044   ESubtitleName=gtk_entry_new();
1045   gtk_widget_set_name( ESubtitleName,"ESubtitleName" );
1046   gtk_widget_show( ESubtitleName );
1047   gtk_box_pack_start( GTK_BOX( hbox4 ),ESubtitleName,TRUE,TRUE,0 );
1048
1049   hbuttonbox4=AddHButtonBox( hbuttonbox4 );
1050     gtk_container_set_border_width( GTK_CONTAINER( hbuttonbox4 ),3 );
1051   BLoadSubtitle=AddButton( MSGTR_Browse,hbuttonbox4 );
1052 #endif
1053
1054   vbox8=AddVBox( vbox7,0 );
1055
1056   table1=gtk_table_new( 3,2,FALSE );
1057   gtk_widget_set_name( table1,"table1" );
1058   gtk_widget_show( table1 );
1059   gtk_box_pack_start( GTK_BOX( vbox8 ),table1,FALSE,FALSE,0 );
1060
1061   label=AddLabel( MSGTR_PREFERENCES_SUB_Delay,NULL );
1062     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1063
1064   label=AddLabel( MSGTR_PREFERENCES_SUB_POS,NULL );
1065     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1066
1067   label=AddLabel( MSGTR_PREFERENCES_SUB_FPS,NULL );
1068     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,2,3,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1069
1070 #ifdef CONFIG_ICONV
1071   label=AddLabel( MSGTR_PREFERENCES_FontEncoding,NULL );
1072     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1073 #endif
1074
1075   HSSubDelayadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-10.0,10,0.01,0,0 ) );
1076   HSSubDelay=AddHScaler( HSSubDelayadj,NULL,1 );
1077     gtk_table_attach( GTK_TABLE( table1 ),HSSubDelay,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1078
1079   HSSubPositionadj=GTK_ADJUSTMENT( gtk_adjustment_new( 100,0,100,1,0,0 ) );
1080   HSSubPosition=AddHScaler( HSSubPositionadj,NULL,0 );
1081     gtk_table_attach( GTK_TABLE( table1 ),HSSubPosition,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1082
1083   HSSubFPSadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0.01,0,0 ) );
1084   HSSubFPS=gtk_spin_button_new( GTK_ADJUSTMENT( HSSubFPSadj ),1,3 );
1085     gtk_widget_set_name( HSSubFPS,"HSSubFPS" );
1086     gtk_widget_show( HSSubFPS );
1087     gtk_widget_set_usize( HSSubFPS,60,-1 );
1088     gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( HSSubFPS ),TRUE );
1089     gtk_table_attach( GTK_TABLE( table1 ),HSSubFPS,1,2,2,3,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1090
1091 #ifdef CONFIG_ICONV
1092   CBSubEncoding=gtk_combo_new();
1093   gtk_widget_set_name( CBSubEncoding,"CBSubEncoding" );
1094   gtk_widget_show( CBSubEncoding );
1095   gtk_table_attach( GTK_TABLE( table1 ),CBSubEncoding,1,2,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1096   CBSubEncoding_items=g_list_append( CBSubEncoding_items,MSGTR_PREFERENCES_None );
1097   {
1098    int i;
1099    for ( i=0;lEncoding[i].name;i++ ) CBSubEncoding_items=g_list_append( CBSubEncoding_items,lEncoding[i].comment );
1100   }
1101   gtk_combo_set_popdown_strings( GTK_COMBO( CBSubEncoding ),CBSubEncoding_items );
1102   g_list_free( CBSubEncoding_items );
1103
1104   ESubEncoding=GTK_COMBO( CBSubEncoding )->entry;
1105   gtk_widget_set_name( ESubEncoding,"ESubEncoding" );
1106   gtk_entry_set_editable( GTK_ENTRY( ESubEncoding ),FALSE );
1107   gtk_widget_show( ESubEncoding );
1108 #endif
1109
1110   vbox9=AddVBox( vbox8,0 );
1111
1112   CBSubOverlap=AddCheckButton( MSGTR_PREFERENCES_SUB_Overlap,vbox9 );
1113   CBNoAutoSub=AddCheckButton( MSGTR_PREFERENCES_SUB_AutoLoad,vbox9 );
1114   CBSubUnicode=AddCheckButton( MSGTR_PREFERENCES_SUB_Unicode,vbox9 );
1115   CBDumpMPSub=AddCheckButton( MSGTR_PREFERENCES_SUB_MPSUB,vbox9 );
1116   CBDumpSrt=AddCheckButton( MSGTR_PREFERENCES_SUB_SRT,vbox9 );
1117
1118   AddHSeparator( vbox9 );
1119   CBUseASS=AddCheckButton( MSGTR_PREFERENCES_SUB_USE_ASS,vbox9 );
1120   hbox9=AddHBox( vbox9,0 );
1121   CBASSUseMargins=AddCheckButton( MSGTR_PREFERENCES_SUB_ASS_USE_MARGINS,hbox9 );
1122
1123   hbox91=gtk_hbox_new( FALSE,0 );
1124   gtk_widget_set_name( hbox91,"hbox91" );
1125   gtk_box_pack_start( GTK_BOX( hbox9 ),hbox91,TRUE,FALSE,0 );
1126   gtk_widget_show( hbox91 );
1127   SBASSTopMargin=AddSpinButton( MSGTR_PREFERENCES_SUB_ASS_TOP_MARGIN,
1128         (GtkAdjustment *)gtk_adjustment_new(0,0,512,1,8,0),hbox91 );
1129
1130   hbox92=gtk_hbox_new( FALSE,0 );
1131   gtk_widget_set_name( hbox92,"hbox92" );
1132   gtk_box_pack_start( GTK_BOX( hbox9 ),hbox92,TRUE,FALSE,0 );
1133   gtk_widget_show( hbox92 );
1134   SBASSBottomMargin=AddSpinButton( MSGTR_PREFERENCES_SUB_ASS_BOTTOM_MARGIN,
1135         (GtkAdjustment *)gtk_adjustment_new(0,0,512,1,8,0),hbox92 );
1136
1137   label=AddLabel( MSGTR_PREFERENCES_SubtitleOSD,NULL );
1138     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),2 ),label );
1139   vbox601=AddVBox( notebook1,0 );
1140
1141 // --- 4. page
1142
1143   vbox603=AddVBox(
1144     AddFrame( NULL,GTK_SHADOW_NONE,
1145       AddFrame( MSGTR_PREFERENCES_FRAME_Font,GTK_SHADOW_ETCHED_OUT,vbox601,0 ),1 ),0 );
1146
1147   hbox6=AddHBox( vbox603,1 );
1148   AddLabel( MSGTR_PREFERENCES_Font,hbox6 );
1149   prEFontName=gtk_entry_new();
1150   gtk_widget_set_name( prEFontName,"prEFontName" );
1151   gtk_widget_show( prEFontName );
1152   gtk_box_pack_start( GTK_BOX( hbox6 ),prEFontName,TRUE,TRUE,0 );
1153   hbuttonbox5=AddHButtonBox( hbox6 );
1154     gtk_container_set_border_width( GTK_CONTAINER( hbuttonbox5 ),3 );
1155   BLoadFont=AddButton( MSGTR_Browse,hbuttonbox5 );
1156
1157 #ifndef CONFIG_FREETYPE
1158   hbox7=AddHBox( vbox603,1 );
1159   AddLabel( MSGTR_PREFERENCES_FontFactor,hbox7 );
1160   HSFontFactoradj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,10,0.05,0,0 ) );
1161   HSFontFactor=AddHScaler( HSFontFactoradj,hbox7,2 );
1162 #else
1163
1164   RBFontNoAutoScale=AddRadioButton( MSGTR_PREFERENCES_FontNoAutoScale,&Font_group,vbox603 );
1165   RBFontAutoScaleHeight=AddRadioButton( MSGTR_PREFERENCES_FontPropHeight,&Font_group,vbox603 );
1166   RBFontAutoScaleWidth=AddRadioButton( MSGTR_PREFERENCES_FontPropWidth,&Font_group,vbox603 );
1167   RBFontAutoScaleDiagonal=AddRadioButton( MSGTR_PREFERENCES_FontPropDiagonal,&Font_group,vbox603 );
1168
1169   table1=gtk_table_new( 3,2,FALSE );
1170   gtk_widget_set_name( table1,"table1" );
1171   gtk_widget_show( table1 );
1172   gtk_box_pack_start( GTK_BOX( vbox603 ),table1,FALSE,FALSE,0 );
1173
1174   label=AddLabel( MSGTR_PREFERENCES_FontEncoding,NULL );
1175     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1176
1177   CBFontEncoding=gtk_combo_new();
1178   gtk_widget_set_name( CBFontEncoding,"CBFontEncoding" );
1179   gtk_widget_show( CBFontEncoding );
1180   gtk_table_attach( GTK_TABLE( table1 ),CBFontEncoding,1,2,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1181   {
1182    int i;
1183    for ( i=0;lEncoding[i].name;i++ ) CBFontEncoding_items=g_list_append( CBFontEncoding_items,lEncoding[i].comment );
1184   }
1185   gtk_combo_set_popdown_strings( GTK_COMBO( CBFontEncoding ),CBFontEncoding_items );
1186   g_list_free( CBFontEncoding_items );
1187
1188   EFontEncoding=GTK_COMBO( CBFontEncoding )->entry;
1189   gtk_widget_set_name( EFontEncoding,"EFontEncoding" );
1190   gtk_entry_set_editable( GTK_ENTRY( EFontEncoding ),FALSE );
1191   gtk_widget_show( EFontEncoding );
1192
1193   label=AddLabel( MSGTR_PREFERENCES_FontBlur,NULL );
1194     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1195
1196   HSFontBluradj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0.1,0,0 ) );
1197   HSFontBlur=AddHScaler( HSFontBluradj,NULL,2 );
1198     gtk_table_attach( GTK_TABLE( table1 ),HSFontBlur,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1199
1200   label=AddLabel( MSGTR_PREFERENCES_FontOutLine,NULL );
1201     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,2,3,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1202
1203   HSFontOutLineadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0.1,0,0 ) );
1204   HSFontOutLine=AddHScaler( HSFontOutLineadj,NULL,2 );
1205     gtk_table_attach( GTK_TABLE( table1 ),HSFontOutLine,1,2,2,3,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1206
1207   label=AddLabel( MSGTR_PREFERENCES_FontTextScale,NULL );
1208     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1209
1210   HSFontTextScaleadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0.1,0,0 ) );
1211   HSFontTextScale=AddHScaler( HSFontTextScaleadj,NULL,2 );
1212     gtk_table_attach( GTK_TABLE( table1 ),HSFontTextScale,1,2,3,4,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1213
1214   label=AddLabel( MSGTR_PREFERENCES_FontOSDScale,NULL );
1215     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,4,5,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1216
1217   HSFontOSDScaleadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0.1,0,0 ) );
1218   HSFontOSDScale=AddHScaler( HSFontOSDScaleadj,NULL,2 );
1219     gtk_table_attach( GTK_TABLE( table1 ),HSFontOSDScale,1,2,4,5,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1220 #endif
1221
1222   label=AddLabel( MSGTR_PREFERENCES_FRAME_Font,NULL );
1223     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),3 ),label );
1224
1225 // --- 5. page
1226
1227   vbox601=AddVBox( notebook1,0 );
1228
1229   vbox602=AddVBox(
1230     AddFrame( NULL,GTK_SHADOW_NONE,
1231       AddFrame( MSGTR_PREFERENCES_FRAME_CodecDemuxer,GTK_SHADOW_ETCHED_OUT,vbox601,0 ),1 ),0 );
1232
1233   CBNonInterlaved=AddCheckButton( MSGTR_PREFERENCES_NI,vbox602 );
1234   CBIndex=AddCheckButton( MSGTR_PREFERENCES_IDX,vbox602 );
1235
1236   hbox5=AddHBox( vbox602,1 );
1237
1238   AddLabel( MSGTR_PREFERENCES_VideoHardwareAcceleration,hbox5 );
1239
1240   CBVHW=gtk_combo_new();
1241   gtk_widget_set_name( CBVHW,"CBVHW" );
1242   gtk_widget_show( CBVHW );
1243   gtk_box_pack_start( GTK_BOX( hbox5 ),CBVHW,TRUE,TRUE,0 );
1244
1245   EVHW=GTK_COMBO( CBVHW )->entry;
1246   gtk_widget_set_name( EVHW,"CEVHW" );
1247   gtk_entry_set_editable( GTK_ENTRY( EVHW ),FALSE );
1248   gtk_widget_show( EVHW );
1249
1250   hbox5=AddHBox( vbox602,1 );
1251
1252   AddLabel( MSGTR_PREFERENCES_VideoCodecFamily,hbox5 );
1253
1254   CBVFM=gtk_combo_new();
1255   gtk_widget_set_name( CBVFM,"CBVFM" );
1256   gtk_widget_show( CBVFM );
1257   gtk_box_pack_start( GTK_BOX( hbox5 ),CBVFM,TRUE,TRUE,0 );
1258
1259   EVFM=GTK_COMBO( CBVFM )->entry;
1260   gtk_widget_set_name( EVFM,"CEVFM" );
1261   gtk_entry_set_editable( GTK_ENTRY( EVFM ),FALSE );
1262   gtk_widget_show( EVFM );
1263
1264   hbox5=AddHBox( vbox602,1 );
1265
1266   AddLabel( MSGTR_PREFERENCES_AudioCodecFamily,hbox5 );
1267
1268   CBAFM=gtk_combo_new();
1269   gtk_widget_set_name( CBAFM,"CBAFM" );
1270   gtk_widget_show( CBAFM );
1271   gtk_box_pack_start( GTK_BOX( hbox5 ),CBAFM,TRUE,TRUE,0 );
1272
1273   EAFM=GTK_COMBO( CBAFM )->entry;
1274   gtk_widget_set_name( EAFM,"EAFM" );
1275   gtk_entry_set_editable( GTK_ENTRY( EAFM ),FALSE );
1276   gtk_widget_show( EAFM );
1277
1278   label=AddLabel( MSGTR_PREFERENCES_Codecs,NULL );
1279     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),4 ),label );
1280
1281   vbox601=AddVBox( notebook1,0 );
1282
1283 // --- 6. page
1284
1285   vbox602=AddVBox(
1286     AddFrame( NULL,GTK_SHADOW_NONE,
1287       AddFrame( MSGTR_PREFERENCES_FRAME_PostProcess,GTK_SHADOW_ETCHED_OUT,vbox601,0 ),1 ),0 );
1288
1289   CBPostprocess=AddCheckButton( MSGTR_PREFERENCES_PostProcess,vbox602 );
1290
1291   hbox5=AddHBox( vbox602,1 );
1292
1293   AddLabel( MSGTR_PREFERENCES_AutoQuality,hbox5 );
1294
1295   if ( guiIntfStruct.sh_video && guiIntfStruct.Playing ) HSPPQualityadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,get_video_quality_max( guiIntfStruct.sh_video ),0,0,0 ) );
1296    else HSPPQualityadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,100,0,0,0 ) );
1297   HSPPQuality=AddHScaler( HSPPQualityadj,hbox5,0 );
1298
1299   vbox602=AddVBox(
1300     AddFrame( NULL,GTK_SHADOW_NONE,
1301       AddFrame( MSGTR_PREFERENCES_FRAME_Cache,GTK_SHADOW_ETCHED_OUT,vbox601,0 ),1 ),0 );
1302
1303   CBCache=AddCheckButton( MSGTR_PREFERENCES_Cache,vbox602 );
1304
1305   hbox5=AddHBox( vbox602,1 );
1306
1307   AddLabel( MSGTR_PREFERENCES_CacheSize,hbox5 );
1308
1309   SBCacheadj=GTK_ADJUSTMENT( gtk_adjustment_new( 2048,4,65535,1,10,10 ) );
1310   SBCache=gtk_spin_button_new( GTK_ADJUSTMENT( SBCacheadj ),1,0 );
1311   gtk_widget_show( SBCache );
1312   gtk_box_pack_start( GTK_BOX( hbox5 ),SBCache,TRUE,TRUE,0 );
1313
1314   vbox602=AddVBox(
1315     AddFrame( NULL,GTK_SHADOW_NONE,
1316       AddFrame( MSGTR_PREFERENCES_FRAME_Misc,GTK_SHADOW_ETCHED_OUT,vbox601,1 ),1 ),0 );
1317
1318   CBShowVideoWindow=AddCheckButton( MSGTR_PREFERENCES_ShowVideoWindow,vbox602 );
1319   CBLoadFullscreen=AddCheckButton( MSGTR_PREFERENCES_LoadFullscreen,vbox602 );
1320   CBSaveWinPos=AddCheckButton( MSGTR_PREFERENCES_SaveWinPos,vbox602 );
1321   CBStopXScreenSaver=AddCheckButton( MSGTR_PREFERENCES_XSCREENSAVER,vbox602 );
1322   CBPlayBar=AddCheckButton( MSGTR_PREFERENCES_PlayBar,vbox602 );
1323
1324   AddHSeparator( vbox602 );
1325
1326   CBAutoSync=AddCheckButton( MSGTR_PREFERENCES_AutoSync,vbox602 );
1327   hbox5=AddHBox( vbox602,1 );
1328   AddLabel( MSGTR_PREFERENCES_AutoSyncValue,hbox5 );
1329   SBAutoSyncadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,10000,1,10,10 ) );
1330   SBAutoSync=gtk_spin_button_new( GTK_ADJUSTMENT( SBAutoSyncadj ),1,0 );
1331   gtk_widget_show( SBAutoSync );
1332   gtk_box_pack_start( GTK_BOX( hbox5 ),SBAutoSync,TRUE,TRUE,0 );
1333
1334   AddHSeparator( vbox602 );
1335
1336   table1=gtk_table_new( 2,2,FALSE );
1337     gtk_widget_set_name( table1,"table1" );
1338     gtk_widget_show( table1 );
1339     gtk_box_pack_start( GTK_BOX( vbox602 ),table1,FALSE,FALSE,0 );
1340
1341   label=AddLabel( MSGTR_PREFERENCES_DVDDevice,NULL );
1342     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1343   prEDVDDevice=gtk_entry_new();
1344     gtk_widget_set_name( prEDVDDevice,"prEDVDDevice" );
1345     gtk_widget_show( prEDVDDevice );
1346     gtk_table_attach( GTK_TABLE( table1 ),prEDVDDevice,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1347
1348   label=AddLabel( MSGTR_PREFERENCES_CDROMDevice,NULL );
1349     gtk_table_attach( GTK_TABLE( table1 ),label,0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1350   prECDRomDevice=gtk_entry_new();
1351     gtk_widget_set_name( prECDRomDevice,"prECDRomDevice" );
1352     gtk_widget_show( prECDRomDevice );
1353     gtk_table_attach( GTK_TABLE( table1 ),prECDRomDevice,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 );
1354
1355 //  AddHSeparator( vbox602 );
1356
1357   label=AddLabel( MSGTR_PREFERENCES_Misc,NULL );
1358     gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ),5 ),label );
1359
1360 // ---
1361
1362   AddHSeparator( vbox1 );
1363
1364   hbuttonbox1=AddHButtonBox( vbox1 );
1365     gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
1366     gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
1367   BOk=AddButton( MSGTR_Ok,hbuttonbox1 );
1368   BCancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
1369
1370   gtk_widget_add_accelerator( BOk,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
1371   gtk_widget_add_accelerator( BCancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
1372
1373   gtk_signal_connect( GTK_OBJECT( Preferences ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&Preferences );
1374
1375   gtk_signal_connect( GTK_OBJECT( AConfig ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bAConfig );
1376   gtk_signal_connect( GTK_OBJECT( BOk ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bOk );
1377   gtk_signal_connect( GTK_OBJECT( BCancel ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bCancel );
1378   gtk_signal_connect( GTK_OBJECT( VConfig ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bVconfig );
1379 #if 0
1380   gtk_signal_connect( GTK_OBJECT( BLoadSubtitle ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bLSubtitle );
1381 #endif
1382   gtk_signal_connect( GTK_OBJECT( BLoadFont ),"clicked",GTK_SIGNAL_FUNC( prButton ),(void*)bLFont );
1383
1384 #if 0
1385   gtk_signal_connect( GTK_OBJECT( CBNormalize ),"toggled",GTK_SIGNAL_FUNC( on_CBNormalize_toggled ),NULL );
1386   gtk_signal_connect( GTK_OBJECT( CBSoftwareMixer ),"toggled",GTK_SIGNAL_FUNC( on_CBSoftwareMixer_toggled ),NULL );
1387   gtk_signal_connect( GTK_OBJECT( CBSurround ),"toggled",GTK_SIGNAL_FUNC( on_CBSurround_toggled ),NULL );
1388   gtk_signal_connect( GTK_OBJECT( CBExtraStereo ),"toggled",GTK_SIGNAL_FUNC( on_CBExtraStereo_toggled ),NULL );
1389   gtk_signal_connect( GTK_OBJECT( CBDoubleBuffer ),"toggled",GTK_SIGNAL_FUNC( on_CBDoubleBuffer_toggled ),NULL );
1390   gtk_signal_connect( GTK_OBJECT( CBDR ),"toggled",GTK_SIGNAL_FUNC( on_CBDR_toggled ),NULL );
1391   gtk_signal_connect( GTK_OBJECT( CBFramedrop ),"toggled",GTK_SIGNAL_FUNC( on_CBFramedrop_toggled ),NULL );
1392   gtk_signal_connect( GTK_OBJECT( CBHFramedrop ),"toggled",GTK_SIGNAL_FUNC( on_CBHFramedrop_toggled ),NULL );
1393   gtk_signal_connect( GTK_OBJECT( CBFullScreen ),"toggled",GTK_SIGNAL_FUNC( on_CBFullScreen_toggled ),NULL );
1394   gtk_signal_connect( GTK_OBJECT( CBNonInterlaved ),"toggled",GTK_SIGNAL_FUNC( on_CBNonInterlaved_toggled ),NULL );
1395   gtk_signal_connect( GTK_OBJECT( CBFlip ),"toggled",GTK_SIGNAL_FUNC( on_CBFlip_toggled ),NULL );
1396   gtk_signal_connect( GTK_OBJECT( CBPostprocess ),"toggled",GTK_SIGNAL_FUNC( on_CBPostprocess_toggled ),NULL );
1397   gtk_signal_connect( GTK_OBJECT( CBNoAutoSub ),"toggled",GTK_SIGNAL_FUNC( on_CBNoAutoSub_toggled ),NULL );
1398   gtk_signal_connect( GTK_OBJECT( CBSubUnicode ),"toggled",GTK_SIGNAL_FUNC( on_CNSubUnicode_toggled ),NULL );
1399   gtk_signal_connect( GTK_OBJECT( CBDumpMPSub ),"toggled",GTK_SIGNAL_FUNC( on_CBDumpMPSub_toggled ),NULL );
1400   gtk_signal_connect( GTK_OBJECT( CBDumpSrt ),"toggled",GTK_SIGNAL_FUNC( on_CBDumpSrt_toggled ),NULL );
1401 #endif
1402 #if 0
1403   gtk_signal_connect( GTK_OBJECT( RBOSDNone ),"toggled",GTK_SIGNAL_FUNC( on_RBOSDNone_toggled ),NULL );
1404   gtk_signal_connect( GTK_OBJECT( RBOSDTandP ),"toggled",GTK_SIGNAL_FUNC( on_RBOSDTandP_toggled ),NULL );
1405   gtk_signal_connect( GTK_OBJECT( RBOSDIndicator ),"toggled",GTK_SIGNAL_FUNC( on_RBOSDIndicator_toggled ),NULL );
1406   gtk_signal_connect( GTK_OBJECT( RBOSDTPTT ),"toggled",GTK_SIGNAL_FUNC( on_RBOSDIndicator_toggled ),NULL );
1407   gtk_signal_connect( GTK_OBJECT( CBAudioEqualizer ),"toggled",GTK_SIGNAL_FUNC( on_CBAudioEqualizer_toggled ),NULL );
1408 #endif
1409 #if 0
1410   gtk_signal_connect( GTK_OBJECT( HSAudioDelay ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSAudioDelay_motion_notify_event ),NULL );
1411   gtk_signal_connect( GTK_OBJECT( HSPanscan ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSPanscan_motion_notify_event ),NULL );
1412   gtk_signal_connect( GTK_OBJECT( label2 ),"motion_notify_event",GTK_SIGNAL_FUNC( on_label2_motion_notify_event ),NULL );
1413   gtk_signal_connect( GTK_OBJECT( HSSubDelay ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSSubDelay_motion_notify_event ),NULL );
1414   gtk_signal_connect( GTK_OBJECT( HSSubPosition ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSSubPosition_motion_notify_event ),NULL );
1415   gtk_signal_connect( GTK_OBJECT( HSSubFPS ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSSubFPS_motion_notify_event ),NULL );
1416   gtk_signal_connect( GTK_OBJECT( HSFontFactor ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSFontFactor_motion_notify_event ),NULL );
1417   gtk_signal_connect( GTK_OBJECT( HSPPQuality ),"motion_notify_event",GTK_SIGNAL_FUNC( on_HSPPQuality_motion_notify_event ),NULL );
1418 #endif
1419
1420   gtk_notebook_set_page( GTK_NOTEBOOK( notebook1 ),2 );
1421
1422   gtk_window_add_accel_group( GTK_WINDOW( Preferences ),accel_group );
1423
1424   return Preferences;
1425 }
1426
1427 #ifdef CONFIG_OSS_AUDIO
1428 static GList *appendOSSDevices(GList *l)
1429 {
1430   // careful! the current implementation allows only string constants!
1431   l = g_list_append(l, (gpointer)"/dev/dsp");
1432   if (gtkAOOSSDevice && strncmp(gtkAOOSSDevice, "/dev/sound", 10) == 0) {
1433     l = g_list_append(l, (gpointer)"/dev/sound/dsp0");
1434     l = g_list_append(l, (gpointer)"/dev/sound/dsp1");
1435     l = g_list_append(l, (gpointer)"/dev/sound/dsp2");
1436     l = g_list_append(l, (gpointer)"/dev/sound/dsp3");
1437   } else {
1438     l = g_list_append(l, (gpointer)"/dev/dsp0");
1439     l = g_list_append(l, (gpointer)"/dev/dsp1");
1440     l = g_list_append(l, (gpointer)"/dev/dsp2");
1441     l = g_list_append(l, (gpointer)"/dev/dsp3");
1442   }
1443 #ifdef CONFIG_DXR3
1444   l = g_list_append(l, (gpointer)"/dev/em8300_ma");
1445   l = g_list_append(l, (gpointer)"/dev/em8300_ma-0");
1446   l = g_list_append(l, (gpointer)"/dev/em8300_ma-1");
1447   l = g_list_append(l, (gpointer)"/dev/em8300_ma-2");
1448   l = g_list_append(l, (gpointer)"/dev/em8300_ma-3");
1449 #endif
1450   return l;
1451 }
1452
1453 static GList *appendOSSMixers(GList *l)
1454 {
1455   // careful! the current implementation allows only string constants!
1456   l = g_list_append(l, (gpointer)"/dev/mixer");
1457   if (gtkAOOSSMixer && strncmp(gtkAOOSSMixer, "/dev/sound", 10) == 0) {
1458     l = g_list_append(l, (gpointer)"/dev/sound/mixer0");
1459     l = g_list_append(l, (gpointer)"/dev/sound/mixer1");
1460     l = g_list_append(l, (gpointer)"/dev/sound/mixer2");
1461     l = g_list_append(l, (gpointer)"/dev/sound/mixer3");
1462   } else {
1463     l = g_list_append(l, (gpointer)"/dev/mixer0");
1464     l = g_list_append(l, (gpointer)"/dev/mixer1");
1465     l = g_list_append(l, (gpointer)"/dev/mixer2");
1466     l = g_list_append(l, (gpointer)"/dev/mixer3");
1467   }
1468   return l;
1469 }
1470
1471 static GList *appendOSSMixerChannels(GList *l)
1472 {
1473   l = g_list_append(l, (gpointer)"vol");
1474   l = g_list_append(l, (gpointer)"pcm");
1475   l = g_list_append(l, (gpointer)"line");
1476   return l;
1477 }
1478 #endif
1479
1480 #ifdef CONFIG_ALSA
1481 static GList *appendALSADevices(GList *l)
1482 {
1483   l = g_list_append(l, (gpointer)"default");
1484   l = g_list_append(l, (gpointer)"hw=0.0");
1485   l = g_list_append(l, (gpointer)"hw=0.1");
1486   l = g_list_append(l, (gpointer)"hw=0.2");
1487   l = g_list_append(l, (gpointer)"surround40");
1488   l = g_list_append(l, (gpointer)"surround51");
1489   l = g_list_append(l, (gpointer)"plug=surround40");
1490   l = g_list_append(l, (gpointer)"plug=surround51");
1491   return l;
1492 }
1493
1494 static GList *appendALSAMixers(GList *l)
1495 {
1496   l = g_list_append(l, (gpointer)"default");
1497   return l;
1498 }
1499
1500 static GList *appendALSAMixerChannels(GList *l)
1501 {
1502   l = g_list_append(l, (gpointer)"Master");
1503   l = g_list_append(l, (gpointer)"Line");
1504   l = g_list_append(l, (gpointer)"PCM");
1505   l = g_list_append(l, (gpointer)"PCM,1");
1506   return l;
1507 }
1508 #endif
1509
1510 #ifdef CONFIG_SDL
1511 static GList *appendSDLDevices(GList *l)
1512 {
1513   l = g_list_append(l, (gpointer)"alsa");
1514   l = g_list_append(l, (gpointer)"arts");
1515   l = g_list_append(l, (gpointer)"esd");
1516   l = g_list_append(l, (gpointer)"jack");
1517   l = g_list_append(l, (gpointer)"oss");
1518   l = g_list_append(l, (gpointer)"nas");
1519   return l;
1520 }
1521 #endif
1522
1523 #ifdef CONFIG_ESD
1524 static GList *appendESDDevices(GList *l)
1525 {
1526   l = g_list_append(l, (gpointer)"Enter Remote IP");
1527   l = g_list_append(l, (gpointer)"Use Software Mixer");
1528   return l;
1529 }
1530 #endif
1531
1532 // Gets text string from a gtk entry, interpreting
1533 // MSGTR_PREFERENCES_DriverDefault as null string.
1534 static const char *getGtkEntryText(GtkWidget *from)
1535 {
1536   const char *tmp = gtk_entry_get_text(GTK_ENTRY(from));
1537   if (strcmp(tmp, MSGTR_PREFERENCES_DriverDefault) == 0) {
1538     tmp = NULL;
1539   }
1540   return tmp;
1541 }
1542
1543 // Sets text string of a gtk entry, interpreting
1544 // null string as MSGTR_PREFERENCES_DriverDefault.
1545 static void setGtkEntryText(GtkWidget *dest, char *to)
1546 {
1547   if (!to) {
1548     to = MSGTR_PREFERENCES_DriverDefault;
1549   }
1550   gtk_entry_set_text(GTK_ENTRY(dest),to);
1551 }
1552
1553        GtkWidget *AudioConfig;
1554 static GtkWidget *CEAudioDevice;
1555 static GtkWidget *CBAudioDevice;
1556 static GtkWidget *CEAudioMixer;
1557 static GtkWidget *CBAudioMixer;
1558 static GtkWidget *CEAudioMixerChannel;
1559 static GtkWidget *CBAudioMixerChannel;
1560 static GtkWidget *BAudioOk;
1561 static GtkWidget *BAudioCancel;
1562
1563 void ShowAudioConfig( void ) {
1564   if (AudioConfig) gtkActive(AudioConfig);
1565   else AudioConfig = create_AudioConfig();
1566
1567 #ifdef CONFIG_OSS_AUDIO
1568   if (strncmp(ao_driver[0], "oss", 3) == 0) {
1569     setGtkEntryText(CEAudioDevice, gtkAOOSSDevice);
1570     setGtkEntryText(CEAudioMixer, gtkAOOSSMixer);
1571     setGtkEntryText(CEAudioMixerChannel, gtkAOOSSMixerChannel);
1572   }
1573 #endif
1574 #ifdef CONFIG_ALSA
1575   if (strncmp(ao_driver[0], "alsa", 4) == 0) {
1576     setGtkEntryText(CEAudioDevice, gtkAOALSADevice);
1577     setGtkEntryText(CEAudioMixer, gtkAOALSAMixer);
1578     setGtkEntryText(CEAudioMixerChannel, gtkAOALSAMixerChannel);
1579   }
1580 #endif
1581 #ifdef CONFIG_SDL
1582   if (strncmp(ao_driver[0], "sdl", 3) == 0) {
1583     setGtkEntryText(CEAudioDevice, gtkAOSDLDriver);
1584   }
1585 #endif
1586 #ifdef CONFIG_ESD
1587   if (strncmp(ao_driver[0], "esd", 3) == 0) {
1588     setGtkEntryText(CEAudioDevice, gtkAOESDDevice);
1589   }
1590 #endif
1591
1592   gtk_widget_show(AudioConfig);
1593   gtkSetLayer(AudioConfig);
1594 }
1595
1596 void HideAudioConfig( void ) {
1597   if (!AudioConfig) return;
1598   gtk_widget_hide(AudioConfig);
1599   gtk_widget_destroy(AudioConfig);
1600   AudioConfig=NULL;
1601 }
1602
1603 static void audioButton(GtkButton *button, gpointer user_data) {
1604   switch( (int)user_data ) {
1605     case 1:
1606 #ifdef CONFIG_OSS_AUDIO
1607       if (strncmp(ao_driver[0], "oss", 3) == 0) {
1608         gfree((void **) &gtkAOOSSDevice);
1609         gtkAOOSSDevice = gstrdup(getGtkEntryText(CEAudioDevice));
1610         gfree((void **) &gtkAOOSSMixer);
1611         gtkAOOSSMixer = gstrdup(getGtkEntryText(CEAudioMixer));
1612         gfree((void **) &gtkAOOSSMixerChannel);
1613         gtkAOOSSMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
1614       }
1615 #endif
1616 #ifdef CONFIG_ALSA
1617       if (strncmp(ao_driver[0], "alsa", 4) == 0) {
1618         gfree((void **) &gtkAOALSADevice);
1619         gtkAOALSADevice = gstrdup(getGtkEntryText(CEAudioDevice));
1620         gfree((void **) &gtkAOALSAMixer);
1621         gtkAOALSAMixer = gstrdup(getGtkEntryText(CEAudioMixer));
1622         gfree((void **) &gtkAOALSAMixerChannel);
1623         gtkAOALSAMixerChannel = gstrdup(getGtkEntryText(CEAudioMixerChannel));
1624       }
1625 #endif
1626 #ifdef CONFIG_SDL
1627       if (strncmp(ao_driver[0], "sdl", 3) == 0) {
1628         gfree((void **) &gtkAOSDLDriver);
1629         gtkAOSDLDriver = gstrdup(getGtkEntryText(CEAudioDevice));
1630       }
1631 #endif
1632 #ifdef CONFIG_ESD
1633       if (strncmp(ao_driver[0], "esd", 3) == 0) {
1634         gfree((void **) &gtkAOESDDevice);
1635         gtkAOESDDevice = gstrdup(getGtkEntryText(CEAudioDevice));
1636       }
1637 #endif
1638    case 0:
1639       HideAudioConfig();
1640       break;
1641   }
1642 }
1643
1644 GtkWidget *create_AudioConfig( void ) {
1645   GList *items = NULL;
1646   GtkWidget *vbox;
1647   GtkWidget *table;
1648   GtkWidget *label;
1649   GtkWidget *hbuttonbox;
1650   GtkAccelGroup *accel_group;
1651
1652   AudioConfig = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1653   gtk_widget_set_name(AudioConfig, "AudioConfig");
1654   gtk_object_set_data(GTK_OBJECT(AudioConfig), "AudioConfig", AudioConfig);
1655   gtk_window_set_title(GTK_WINDOW(AudioConfig), MSGTR_AudioPreferences);
1656   gtk_window_set_position(GTK_WINDOW(AudioConfig), GTK_WIN_POS_CENTER);
1657   gtk_window_set_policy(GTK_WINDOW(AudioConfig), FALSE, FALSE, FALSE);
1658   gtk_window_set_wmclass(GTK_WINDOW(AudioConfig), "Audio Config", "MPlayer");
1659
1660   gtk_widget_realize(AudioConfig);
1661   gtkAddIcon(AudioConfig);
1662
1663   vbox = AddVBox(AddDialogFrame(AudioConfig), 0);
1664
1665   table = gtk_table_new(2, 3, FALSE);
1666   gtk_widget_set_name(table, "table");
1667   gtk_widget_show(table);
1668   gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
1669
1670   label = AddLabel(MSGTR_PREFERENCES_Audio_Device, NULL);
1671   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1672
1673   CBAudioDevice = AddComboBox(NULL);
1674   gtk_table_attach(GTK_TABLE(table), CBAudioDevice, 1, 2, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1675   items = g_list_append(items,(gpointer)MSGTR_PREFERENCES_DriverDefault);
1676 #ifdef CONFIG_OSS_AUDIO
1677   if (strncmp(ao_driver[0], "oss", 3) == 0)
1678     items = appendOSSDevices(items);
1679 #endif
1680 #ifdef CONFIG_ALSA
1681   if (strncmp(ao_driver[0], "alsa", 4) == 0)
1682     items = appendALSADevices(items);
1683 #endif
1684 #ifdef CONFIG_SDL
1685   if (strncmp(ao_driver[0], "sdl", 3) == 0)
1686     items = appendSDLDevices(items);
1687 #endif
1688 #ifdef CONFIG_ESD
1689   if (strncmp(ao_driver[0], "esd", 3) == 0)
1690     items = appendESDDevices(items);
1691 #endif
1692   gtk_combo_set_popdown_strings(GTK_COMBO(CBAudioDevice), items);
1693   g_list_free(items);
1694   items = NULL;
1695
1696   CEAudioDevice = GTK_COMBO(CBAudioDevice)->entry;
1697   gtk_widget_set_name(CEAudioDevice, "CEAudioDevice");
1698   gtk_widget_show(CEAudioDevice);
1699
1700   label = AddLabel(MSGTR_PREFERENCES_Audio_Mixer, NULL);
1701   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1702
1703   CBAudioMixer = AddComboBox(NULL);
1704   gtk_table_attach(GTK_TABLE(table), CBAudioMixer, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1705   items = g_list_append(items, (gpointer)MSGTR_PREFERENCES_DriverDefault);
1706 #ifdef CONFIG_OSS_AUDIO
1707   if (strncmp(ao_driver[0], "oss", 3) == 0)
1708     items = appendOSSMixers(items);
1709 #endif
1710 #ifdef CONFIG_ALSA
1711   if (strncmp(ao_driver[0], "alsa", 4) == 0)
1712     items = appendALSAMixers(items);
1713 #endif
1714   gtk_combo_set_popdown_strings(GTK_COMBO(CBAudioMixer), items);
1715   g_list_free(items);
1716   items = NULL;
1717
1718   CEAudioMixer = GTK_COMBO(CBAudioMixer)->entry;
1719   gtk_widget_set_name(CEAudioMixer, "CEAudioMixer");
1720   gtk_widget_show(CEAudioMixer);
1721
1722   label = AddLabel(MSGTR_PREFERENCES_Audio_MixerChannel, NULL);
1723   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1724
1725   CBAudioMixerChannel = AddComboBox(NULL);
1726   gtk_table_attach(GTK_TABLE(table), CBAudioMixerChannel, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0);
1727   items = g_list_append(items, (gpointer)MSGTR_PREFERENCES_DriverDefault);
1728 #ifdef CONFIG_OSS_AUDIO
1729   if (strncmp(ao_driver[0], "oss", 3) == 0)
1730     items = appendOSSMixerChannels(items);
1731 #endif
1732 #ifdef CONFIG_ALSA
1733   if (strncmp(ao_driver[0], "alsa", 4) == 0)
1734     items = appendALSAMixerChannels(items);
1735 #endif
1736   gtk_combo_set_popdown_strings(GTK_COMBO(CBAudioMixerChannel), items);
1737   g_list_free(items);
1738   items = NULL;
1739
1740   CEAudioMixerChannel = GTK_COMBO(CBAudioMixerChannel)->entry;
1741   gtk_widget_set_name(CEAudioMixerChannel, "CEAudioMixerChannel");
1742   gtk_widget_show(CEAudioMixerChannel);
1743
1744   AddHSeparator(vbox);
1745
1746   hbuttonbox = AddHButtonBox(vbox);
1747   gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox), GTK_BUTTONBOX_END);
1748   gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox), 10);
1749   BAudioOk = AddButton(MSGTR_Ok, hbuttonbox);
1750   BAudioCancel = AddButton(MSGTR_Cancel, hbuttonbox);
1751
1752   gtk_signal_connect(GTK_OBJECT(AudioConfig), "destroy", GTK_SIGNAL_FUNC(WidgetDestroy), &AudioConfig);
1753   gtk_signal_connect(GTK_OBJECT(BAudioOk), "clicked", GTK_SIGNAL_FUNC(audioButton), (void*)1);
1754   gtk_signal_connect(GTK_OBJECT(BAudioCancel), "clicked", GTK_SIGNAL_FUNC(audioButton), (void*)0);
1755
1756   accel_group = gtk_accel_group_new();
1757   gtk_widget_add_accelerator(BAudioOk, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE);
1758   gtk_widget_add_accelerator(BAudioCancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE);
1759   gtk_window_add_accel_group(GTK_WINDOW(AudioConfig), accel_group);
1760
1761   return AudioConfig;
1762 }
1763
1764 #ifdef CONFIG_DXR3
1765 // --- dxr3 config box
1766
1767 static GtkWidget * DXR3Config;
1768 static GtkWidget * CBDevice;
1769 static GtkWidget * CEDXR3Device;
1770 static GtkWidget * RBVNone;
1771 static GtkWidget * RBVLavc;
1772 static GtkWidget * dxr3BOk;
1773 static GtkWidget * dxr3BCancel;
1774
1775 GtkWidget * create_DXR3Config( void );
1776
1777 void ShowDXR3Config( void )
1778 {
1779  if ( DXR3Config ) gtkActive( DXR3Config );
1780   else DXR3Config=create_DXR3Config();
1781
1782  gtk_entry_set_text( GTK_ENTRY( CEDXR3Device ),gtkDXR3Device );
1783
1784  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBVNone ),TRUE );
1785  if ( gtkVfLAVC ) gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( RBVLavc ),TRUE );
1786
1787  gtk_widget_show( DXR3Config );
1788  gtkSetLayer( DXR3Config );
1789 }
1790
1791 void HideDXR3Config( void )
1792 {
1793  if ( !DXR3Config ) return;
1794  gtk_widget_hide( DXR3Config );
1795  gtk_widget_destroy( DXR3Config );
1796  DXR3Config=NULL;
1797 }
1798
1799 static void dxr3Button( GtkButton * button,gpointer user_data )
1800 {
1801  switch ( (int)user_data )
1802  {
1803   case 0: // Ok
1804        gfree( (void **)&gtkDXR3Device ); gtkDXR3Device=strdup( gtk_entry_get_text( GTK_ENTRY( CEDXR3Device ) ) );
1805        gtkVfLAVC=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBVLavc ) );
1806   case 1: // Cancel
1807        HideDXR3Config();
1808        break;
1809  }
1810 }
1811
1812 GtkWidget * create_DXR3Config( void )
1813 {
1814  GtkWidget * vbox1;
1815  GtkWidget * vbox2;
1816  GtkWidget * hbox1;
1817  GList     * CBDevice_items = NULL;
1818  GtkWidget * vbox3;
1819  GSList    * VEncoder_group = NULL;
1820  GtkWidget * hbuttonbox1;
1821  GtkAccelGroup * accel_group;
1822
1823  accel_group=gtk_accel_group_new();
1824
1825  DXR3Config=gtk_window_new( GTK_WINDOW_TOPLEVEL );
1826  gtk_widget_set_name( DXR3Config,"DXR3Config" );
1827  gtk_object_set_data( GTK_OBJECT( DXR3Config ),"DXR3Config",DXR3Config );
1828 // gtk_widget_set_usize( DXR3Config,300,156 );
1829  GTK_WIDGET_SET_FLAGS( DXR3Config,GTK_CAN_DEFAULT );
1830  gtk_window_set_title( GTK_WINDOW( DXR3Config ),"DXR3/H+" );
1831  gtk_window_set_position( GTK_WINDOW( DXR3Config ),GTK_WIN_POS_CENTER );
1832  gtk_window_set_policy( GTK_WINDOW( DXR3Config ),FALSE,FALSE,FALSE );
1833  gtk_window_set_wmclass( GTK_WINDOW( DXR3Config ),"DXR3","MPlayer" );
1834
1835  gtk_widget_realize( DXR3Config );
1836  gtkAddIcon( DXR3Config );
1837
1838  vbox1=AddVBox( AddDialogFrame( DXR3Config ),0 );
1839  vbox2=AddVBox( vbox1,0 );
1840  hbox1=AddHBox( vbox2,1 );
1841  AddLabel( MSGTR_PREFERENCES_Audio_Device,hbox1 );
1842
1843  CBDevice=AddComboBox( hbox1 );
1844
1845  CBDevice_items=g_list_append( CBDevice_items,( gpointer ) "/dev/em8300" );
1846  CBDevice_items=g_list_append( CBDevice_items,( gpointer ) "/dev/em8300-0" );
1847  CBDevice_items=g_list_append( CBDevice_items,( gpointer ) "/dev/em8300-1" );
1848  CBDevice_items=g_list_append( CBDevice_items,( gpointer ) "/dev/em8300-2" );
1849  CBDevice_items=g_list_append( CBDevice_items,( gpointer ) "/dev/em8300-3" );
1850  gtk_combo_set_popdown_strings( GTK_COMBO( CBDevice ),CBDevice_items );
1851  g_list_free( CBDevice_items );
1852
1853  CEDXR3Device=GTK_COMBO( CBDevice )->entry;
1854  gtk_widget_set_name( CEDXR3Device,"CEDXR3Device" );
1855  gtk_widget_show( CEDXR3Device );
1856  gtk_entry_set_text( GTK_ENTRY( CEDXR3Device ),"/dev/em8300" );
1857
1858  AddHSeparator( vbox2 );
1859  vbox3=AddVBox( vbox2,0 );
1860  AddLabel( MSGTR_PREFERENCES_DXR3_VENC,vbox3 );
1861  RBVNone=AddRadioButton( MSGTR_PREFERENCES_None,&VEncoder_group,vbox3 );
1862  RBVLavc=AddRadioButton( MSGTR_PREFERENCES_DXR3_LAVC,&VEncoder_group,vbox3 );
1863
1864  AddHSeparator( vbox1 );
1865
1866  hbuttonbox1=AddHButtonBox( vbox1 );
1867    gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
1868    gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
1869  dxr3BOk=AddButton( MSGTR_Ok,hbuttonbox1 );
1870  dxr3BCancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
1871
1872  gtk_widget_add_accelerator( dxr3BOk,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
1873  gtk_widget_add_accelerator( dxr3BCancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
1874
1875  gtk_signal_connect( GTK_OBJECT( DXR3Config ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&DXR3Config );
1876
1877  gtk_signal_connect( GTK_OBJECT( dxr3BOk ),"clicked",GTK_SIGNAL_FUNC( dxr3Button ),(void *)0 );
1878  gtk_signal_connect( GTK_OBJECT( dxr3BCancel ),"clicked",GTK_SIGNAL_FUNC( dxr3Button ),(void *)1 );
1879
1880  gtk_window_add_accel_group( GTK_WINDOW( DXR3Config ),accel_group );
1881
1882  return DXR3Config;
1883 }
1884
1885 #endif