Mercurial > mplayer.hg
annotate gui/ui/gtk/equalizer.c @ 34321:daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
author | ib |
---|---|
date | Thu, 08 Dec 2011 16:06:24 +0000 |
parents | fd05ddb85f03 |
children | a650895d50a5 |
rev | line source |
---|---|
33572 | 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 <stdio.h> | |
21 #include <sys/types.h> | |
22 #include <sys/stat.h> | |
23 #include <unistd.h> | |
24 #include <string.h> | |
25 | |
26 #include <gdk/gdkkeysyms.h> | |
27 #include <gtk/gtk.h> | |
28 | |
29 #include "config.h" | |
30 #include "gui/app.h" | |
31 #include "gui/cfg.h" | |
33738 | 32 #include "gui/interface.h" |
33572 | 33 #include "help_mp.h" |
34 #include "libaf/equalizer.h" | |
33689
8d0290220239
Replace numeric constants for gtkEquChannels array size.
ib
parents:
33646
diff
changeset
|
35 #include "libavutil/common.h" |
33572 | 36 #include "libvo/video_out.h" |
37 #include "stream/stream.h" | |
38 #include "libmpdemux/demuxer.h" | |
39 #include "libmpdemux/stheader.h" | |
40 #include "libmpcodecs/dec_video.h" | |
41 #include "gui/ui/widgets.h" | |
33739 | 42 #include "gui/util/mem.h" |
33737 | 43 #include "gui/util/string.h" |
33572 | 44 |
45 #include "equalizer.h" | |
46 #include "tools.h" | |
47 | |
48 #define eqRange 15 | |
49 | |
50 GtkWidget * Equalizer = NULL; | |
51 static GtkWidget * EquConfig; | |
52 | |
53 static GtkWidget * Notebook; | |
54 static GtkWidget * ChannelsList; | |
55 static GtkWidget * VContrast, * VBrightness, * VHue, * VSaturation; | |
56 static GtkAdjustment * VContrastadj, * VBrightnessadj, * VHueadj, * VSaturationadj; | |
57 static GtkWidget * Ok, * Clear, * Config; | |
58 static GtkWidget * A3125, * A125, * A6250, * A250, * A500, * A1000, * A2000, * A4000, * A8000, * A16000; | |
59 static GtkAdjustment * A3125adj, * A125adj, * A6250adj, * A250adj, * A500adj, * A1000adj, * A2000adj, * A4000adj, * A8000adj, * A16000adj; | |
60 | |
61 static int Channel = -1; | |
62 | |
63 // --- | |
64 | |
65 char * gtkEquChannel1 = NULL; | |
66 char * gtkEquChannel2 = NULL; | |
67 char * gtkEquChannel3 = NULL; | |
68 char * gtkEquChannel4 = NULL; | |
69 char * gtkEquChannel5 = NULL; | |
70 char * gtkEquChannel6 = NULL; | |
71 | |
72 // --- | |
73 | |
74 void ShowEquConfig( void ); | |
75 void HideEquConfig( void ); | |
76 | |
77 static void eqSetBands( int channel ) | |
78 { | |
79 if ( channel < 0 ) channel=0; | |
80 gtk_adjustment_set_value( A3125adj,0.0f - gtkEquChannels[channel][0] ); | |
81 gtk_adjustment_set_value( A6250adj,0.0f - gtkEquChannels[channel][1] ); | |
82 gtk_adjustment_set_value( A125adj,0.0f - gtkEquChannels[channel][2] ); | |
83 gtk_adjustment_set_value( A250adj,0.0f - gtkEquChannels[channel][3] ); | |
84 gtk_adjustment_set_value( A500adj,0.0f - gtkEquChannels[channel][4] ); | |
85 gtk_adjustment_set_value( A1000adj,0.0f - gtkEquChannels[channel][5] ); | |
86 gtk_adjustment_set_value( A2000adj,0.0f - gtkEquChannels[channel][6] ); | |
87 gtk_adjustment_set_value( A4000adj,0.0f - gtkEquChannels[channel][7] ); | |
88 gtk_adjustment_set_value( A8000adj,0.0f - gtkEquChannels[channel][8] ); | |
89 gtk_adjustment_set_value( A16000adj,0.0f - gtkEquChannels[channel][9] ); | |
90 | |
91 if ( guiInfo.sh_video ) | |
92 { | |
93 get_video_colors( guiInfo.sh_video,"brightness",&vo_gamma_brightness ); | |
94 get_video_colors( guiInfo.sh_video,"contrast",&vo_gamma_contrast ); | |
95 get_video_colors( guiInfo.sh_video,"hue",&vo_gamma_hue ); | |
96 get_video_colors( guiInfo.sh_video,"saturation",&vo_gamma_saturation ); | |
97 } | |
98 | |
99 gtk_adjustment_set_value( VContrastadj,(float)vo_gamma_contrast ); | |
100 gtk_adjustment_set_value( VBrightnessadj,(float)vo_gamma_brightness ); | |
101 gtk_adjustment_set_value( VHueadj,(float)vo_gamma_hue ); | |
102 gtk_adjustment_set_value( VSaturationadj,(float)vo_gamma_saturation ); | |
103 } | |
104 | |
105 static void eqSetChannelNames( void ) | |
106 { | |
107 gchar * str[2]; | |
108 gtk_clist_clear( GTK_CLIST( ChannelsList ) ); | |
109 str[1]=""; | |
110 str[0]=MSGTR_EQU_All; | |
111 gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
33646 | 112 if ( guiInfo.AudioChannels > 1 ) |
33572 | 113 { |
114 str[0]=gtkEquChannel1; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
115 str[0]=gtkEquChannel2; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
116 } | |
33646 | 117 if ( guiInfo.AudioChannels > 2 ) |
33572 | 118 { |
119 str[0]=gtkEquChannel3; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
120 str[0]=gtkEquChannel4; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
121 } | |
33646 | 122 if ( guiInfo.AudioChannels > 4 ) |
33572 | 123 { |
124 str[0]=gtkEquChannel5; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
125 str[0]=gtkEquChannel6; gtk_clist_append( GTK_CLIST( ChannelsList ) ,str); | |
126 } | |
127 gtk_clist_select_row( GTK_CLIST( ChannelsList ),0,0 ); | |
128 } | |
129 | |
130 void ShowEqualizer( void ) | |
131 { | |
132 if ( Equalizer ) gtkActive( Equalizer ); | |
133 else Equalizer=create_Equalizer(); | |
134 | |
135 if ( !gtkEquChannel1 ) gtkEquChannel1=strdup( MSGTR_EQU_Front_Right ); | |
136 if ( !gtkEquChannel2 ) gtkEquChannel2=strdup( MSGTR_EQU_Front_Left ); | |
137 if ( !gtkEquChannel3 ) gtkEquChannel3=strdup( MSGTR_EQU_Back_Right ); | |
138 if ( !gtkEquChannel4 ) gtkEquChannel4=strdup( MSGTR_EQU_Back_Left ); | |
139 if ( !gtkEquChannel5 ) gtkEquChannel5=strdup( MSGTR_EQU_Center ); | |
140 if ( !gtkEquChannel6 ) gtkEquChannel6=strdup( MSGTR_EQU_Bass ); | |
141 | |
142 eqSetChannelNames(); | |
143 | |
144 if ( !guiInfo.Playing || !guiInfo.sh_video ) | |
145 { | |
146 gtk_widget_set_sensitive( VContrast,FALSE ); | |
147 gtk_widget_set_sensitive( VBrightness,FALSE ); | |
148 gtk_widget_set_sensitive( VHue,FALSE ); | |
149 gtk_widget_set_sensitive( VSaturation,FALSE ); | |
150 } | |
151 Channel=-1; | |
152 eqSetBands( 0 ); | |
153 if ( !guiInfo.Playing || !gtkEnableAudioEqualizer ) | |
154 { | |
155 gtk_widget_set_sensitive( ChannelsList,FALSE ); | |
156 gtk_widget_set_sensitive( A3125,FALSE ); | |
157 gtk_widget_set_sensitive( A125,FALSE ); | |
158 gtk_widget_set_sensitive( A6250,FALSE ); | |
159 gtk_widget_set_sensitive( A250,FALSE ); | |
160 gtk_widget_set_sensitive( A500,FALSE ); | |
161 gtk_widget_set_sensitive( A1000,FALSE ); | |
162 gtk_widget_set_sensitive( A2000,FALSE ); | |
163 gtk_widget_set_sensitive( A4000,FALSE ); | |
164 gtk_widget_set_sensitive( A8000,FALSE ); | |
165 gtk_widget_set_sensitive( A16000,FALSE ); | |
166 } | |
167 | |
168 if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( Notebook ) ) == 0 ) gtk_widget_show( Config ); | |
169 gtk_widget_show( Equalizer ); | |
170 } | |
171 | |
172 static void HideEqualizer( void ) | |
173 { | |
174 if ( !Equalizer ) return; | |
175 gtk_widget_hide( Equalizer ); | |
176 gtk_widget_destroy( Equalizer ); | |
177 Equalizer=NULL; | |
178 if ( EquConfig ) HideEquConfig(); | |
179 } | |
180 | |
181 static gboolean eqHScaleMotion( GtkWidget * widget,GdkEventMotion * event,gpointer user_data ) | |
182 { | |
183 equalizer_t eq; | |
184 switch ( (int)user_data ) | |
185 { | |
186 case 0: eq.gain=A3125adj->value; break; | |
187 case 1: eq.gain=A6250adj->value; break; | |
188 case 2: eq.gain=A125adj->value; break; | |
189 case 3: eq.gain=A250adj->value; break; | |
190 case 4: eq.gain=A500adj->value; break; | |
191 case 5: eq.gain=A1000adj->value; break; | |
192 case 6: eq.gain=A2000adj->value; break; | |
193 case 7: eq.gain=A4000adj->value; break; | |
194 case 8: eq.gain=A8000adj->value; break; | |
195 case 9: eq.gain=A16000adj->value; break; | |
196 default: return FALSE; | |
197 } | |
198 eq.gain=0.0f - eq.gain; | |
199 eq.band=(int)user_data; | |
200 if ( Channel == -1 ) | |
201 { | |
202 int i; | |
203 for ( i=0;i<6;i++ ) | |
33766 | 204 { eq.channel=i; mplayer( MPLAYER_SET_EQUALIZER,0,&eq ); } |
205 } else { eq.channel=Channel; mplayer( MPLAYER_SET_EQUALIZER,0,&eq ); } | |
33572 | 206 |
207 return FALSE; | |
208 } | |
209 | |
210 static gboolean eqVScaleMotion( GtkWidget * widget,GdkEventMotion * event,gpointer user_data ) | |
211 { | |
212 | |
213 switch( (int)user_data ) | |
214 { | |
33769 | 215 case 1: mplayer( MPLAYER_SET_CONTRAST,VContrastadj->value,0 ); break; |
216 case 2: mplayer( MPLAYER_SET_BRIGHTNESS,VBrightnessadj->value,0 ); break; | |
217 case 3: mplayer( MPLAYER_SET_HUE,VHueadj->value,0 ); break; | |
218 case 4: mplayer( MPLAYER_SET_SATURATION,VSaturationadj->value,0 ); break; | |
33572 | 219 } |
220 | |
221 return FALSE; | |
222 } | |
223 | |
224 static void eqButtonReleased( GtkButton * button,gpointer user_data ) | |
225 { | |
226 switch( (int)user_data ) | |
227 { | |
228 case 0: HideEqualizer(); break; | |
229 case 1: | |
230 if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( Notebook ) ) == 0 ) | |
231 { | |
232 if ( !guiInfo.Playing || !gtkEnableAudioEqualizer ) break; | |
33766 | 233 mplayer( MPLAYER_SET_EQUALIZER,0,NULL ); |
33572 | 234 eqSetBands( Channel ); |
235 } | |
236 else | |
237 { | |
238 if ( !guiInfo.Playing ) break; | |
33769 | 239 mplayer( MPLAYER_SET_CONTRAST,0,0 ); |
240 mplayer( MPLAYER_SET_BRIGHTNESS,0,0 ); | |
241 mplayer( MPLAYER_SET_HUE,0,0 ); | |
242 mplayer( MPLAYER_SET_SATURATION,0,0 ); | |
33572 | 243 eqSetBands( Channel ); |
244 } | |
245 break; | |
246 case 2: | |
247 ShowEquConfig(); | |
248 break; | |
249 } | |
250 } | |
251 | |
252 static void eqFocus( GtkWindow * window,GtkWidget * widget,gpointer user_data ) | |
253 { eqSetBands( Channel ); } | |
254 | |
255 static void eqSelectChannelsListRow( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
256 { | |
257 Channel=row - 1; | |
258 eqSetBands( Channel ); | |
259 if ( Channel == -1 ) | |
260 { | |
33756
e55098a29bcb
Use unsigned index variable for comparison with array size.
ib
parents:
33743
diff
changeset
|
261 unsigned int i,j; equalizer_t eq; |
33689
8d0290220239
Replace numeric constants for gtkEquChannels array size.
ib
parents:
33646
diff
changeset
|
262 for ( i=1;i<FF_ARRAY_ELEMS(gtkEquChannels);i++ ) |
8d0290220239
Replace numeric constants for gtkEquChannels array size.
ib
parents:
33646
diff
changeset
|
263 for ( j=0;j<FF_ARRAY_ELEMS(*gtkEquChannels);j++ ) |
33766 | 264 { eq.band=j; eq.channel=i; eq.gain=gtkEquChannels[0][j]; mplayer( MPLAYER_SET_EQUALIZER,0,&eq ); } |
33572 | 265 } |
266 } | |
267 | |
268 static void eqNotebook( GtkNotebook * notebook, GtkNotebookPage * page, | |
269 gint page_num, gpointer user_data ) | |
270 { | |
271 if ( page_num ) gtk_widget_hide( Config ); | |
272 else gtk_widget_show( Config ); | |
273 } | |
274 | |
275 GtkWidget * create_Equalizer( void ) | |
276 { | |
277 GtkWidget * vbox1; | |
278 GtkWidget * hbox1; | |
279 GtkWidget * scrolledwindow1; | |
280 GtkWidget * table1; | |
281 GtkWidget * hbuttonbox1; | |
282 GtkAccelGroup * accel_group; | |
283 | |
284 accel_group=gtk_accel_group_new(); | |
285 | |
286 Equalizer=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
287 gtk_widget_set_name( Equalizer,MSGTR_Equalizer ); | |
288 gtk_object_set_data( GTK_OBJECT( Equalizer ),MSGTR_Equalizer,Equalizer ); | |
289 gtk_widget_set_usize( Equalizer,-1,256 ); | |
290 gtk_window_set_title( GTK_WINDOW( Equalizer ),MSGTR_Equalizer ); | |
291 gtk_window_set_position( GTK_WINDOW( Equalizer ),GTK_WIN_POS_CENTER ); | |
292 gtk_window_set_policy( GTK_WINDOW( Equalizer ),FALSE,FALSE,FALSE ); | |
293 gtk_window_set_wmclass( GTK_WINDOW( Equalizer ),"Equalizer","MPlayer" ); | |
294 | |
295 gtk_widget_realize( Equalizer ); | |
296 gtkAddIcon( Equalizer ); | |
297 | |
298 vbox1=AddVBox( AddDialogFrame( Equalizer ),0 ); | |
299 | |
300 Notebook=gtk_notebook_new(); | |
301 gtk_widget_set_name( Notebook,"Notebook" ); | |
302 gtk_widget_show( Notebook ); | |
303 gtk_box_pack_start( GTK_BOX( vbox1 ),Notebook,TRUE,TRUE,0 ); | |
304 gtk_container_set_border_width( GTK_CONTAINER( Notebook ),1 ); | |
305 | |
306 hbox1=AddHBox( Notebook,0 ); | |
307 | |
308 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
309 gtk_widget_set_name( scrolledwindow1,"scrolledwindow1" ); | |
310 gtk_widget_show( scrolledwindow1 ); | |
311 gtk_box_pack_start( GTK_BOX( hbox1 ),scrolledwindow1,FALSE,FALSE,0 ); | |
312 gtk_widget_set_usize( scrolledwindow1,106,-2 ); | |
313 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
314 | |
315 ChannelsList=gtk_clist_new( 1 ); | |
316 gtk_widget_set_name( ChannelsList,"ChannelsList" ); | |
317 gtk_widget_show( ChannelsList ); | |
318 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),ChannelsList ); | |
319 gtk_clist_set_column_width( GTK_CLIST( ChannelsList ),0,80 ); | |
320 gtk_clist_column_titles_hide( GTK_CLIST( ChannelsList ) ); | |
321 | |
322 table1=gtk_table_new( 2,10,FALSE ); | |
323 gtk_widget_set_name( table1,"table1" ); | |
324 gtk_widget_show( table1 ); | |
325 gtk_box_pack_start( GTK_BOX( hbox1 ),table1,FALSE,FALSE,0 ); | |
326 gtk_table_set_row_spacings( GTK_TABLE( table1 ),4 ); | |
327 gtk_table_set_col_spacings( GTK_TABLE( table1 ),9 ); | |
328 | |
329 A3125adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
330 A3125=AddVScaler( A3125adj,NULL,-1 ); | |
331 gtk_table_attach( GTK_TABLE( table1 ),A3125,0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
332 | |
333 A6250adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
334 A6250=AddVScaler( A6250adj,NULL,-1 ); | |
335 gtk_table_attach( GTK_TABLE( table1 ),A6250,1,2,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
336 | |
337 A125adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
338 A125=AddVScaler( A125adj,NULL,-1 ); | |
339 gtk_table_attach( GTK_TABLE( table1 ),A125,2,3,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
340 | |
341 A250adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
342 A250=AddVScaler( A250adj,NULL,-1 ); | |
343 gtk_table_attach( GTK_TABLE( table1 ),A250,3,4,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
344 | |
345 A500adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
346 A500=AddVScaler( A500adj,NULL,-1 ); | |
347 gtk_table_attach( GTK_TABLE( table1 ),A500,4,5,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
348 | |
349 A1000adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
350 A1000=AddVScaler( A1000adj,NULL,-1 ); | |
351 gtk_table_attach( GTK_TABLE( table1 ),A1000,5,6,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
352 | |
353 A2000adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
354 A2000=AddVScaler( A2000adj,NULL,-1 ); | |
355 gtk_table_attach( GTK_TABLE( table1 ),A2000,6,7,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
356 | |
357 A4000adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
358 A4000=AddVScaler( A4000adj,NULL,-1 ); | |
359 gtk_table_attach( GTK_TABLE( table1 ),A4000,7,8,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
360 | |
361 A8000adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
362 A8000=AddVScaler( A8000adj,NULL,-1 ); | |
363 gtk_table_attach( GTK_TABLE( table1 ),A8000,8,9,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
364 | |
365 A16000adj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-eqRange,eqRange,0.5,0,0 ) ); | |
366 A16000=AddVScaler( A16000adj,NULL,-1 ); | |
367 gtk_table_attach( GTK_TABLE( table1 ),A16000,9,10,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),0,0 ); | |
368 | |
369 gtk_table_attach( GTK_TABLE( table1 ), | |
370 AddLabel( "31.25",NULL ), | |
371 0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
372 | |
373 gtk_table_attach( GTK_TABLE( table1 ), | |
374 AddLabel( "62.50",NULL ), | |
375 1,2,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
376 | |
377 gtk_table_attach( GTK_TABLE( table1 ), | |
378 AddLabel( "125",NULL ), | |
379 2,3,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
380 | |
381 gtk_table_attach( GTK_TABLE( table1 ), | |
382 AddLabel( "250",NULL ), | |
383 3,4,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
384 | |
385 gtk_table_attach( GTK_TABLE( table1 ), | |
386 AddLabel( "500",NULL ), | |
387 4,5,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
388 | |
389 gtk_table_attach( GTK_TABLE( table1 ), | |
390 AddLabel( "1000",NULL ), | |
391 5,6,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
392 | |
393 gtk_table_attach( GTK_TABLE( table1 ), | |
394 AddLabel( "2000",NULL ), | |
395 6,7,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
396 | |
397 gtk_table_attach( GTK_TABLE( table1 ), | |
398 AddLabel( "4000",NULL ), | |
399 7,8,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
400 | |
401 gtk_table_attach( GTK_TABLE( table1 ), | |
402 AddLabel( "8000",NULL ), | |
403 8,9,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
404 | |
405 gtk_table_attach( GTK_TABLE( table1 ), | |
406 AddLabel( "16000",NULL ), | |
407 9,10,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
408 | |
409 gtk_notebook_set_tab_label( GTK_NOTEBOOK( Notebook ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( Notebook ),0 ), | |
410 AddLabel( MSGTR_EQU_Audio,NULL ) ); | |
411 | |
412 table1=gtk_table_new( 4,2,FALSE ); | |
413 gtk_widget_set_name( table1,"table1" ); | |
414 gtk_widget_show( table1 ); | |
415 gtk_container_add( GTK_CONTAINER( Notebook ),table1 ); | |
416 | |
417 gtk_table_attach( GTK_TABLE( table1 ), | |
418 AddLabel( MSGTR_EQU_Contrast,NULL ), | |
419 0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
420 | |
421 gtk_table_attach( GTK_TABLE( table1 ), | |
422 AddLabel( MSGTR_EQU_Brightness,NULL ), | |
423 0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
424 | |
425 gtk_table_attach( GTK_TABLE( table1 ), | |
426 AddLabel( MSGTR_EQU_Hue,NULL ), | |
427 0,1,2,3,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
428 | |
429 gtk_table_attach( GTK_TABLE( table1 ), | |
430 AddLabel( MSGTR_EQU_Saturation,NULL ), | |
431 0,1,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
432 | |
433 VContrastadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-100,100,1,0,0 ) ); | |
434 VContrast=AddHScaler( VContrastadj,NULL,1 ); | |
435 gtk_table_attach( GTK_TABLE( table1 ),VContrast,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
436 gtk_widget_set_usize( VContrast,-1,45 ); | |
437 | |
438 VBrightnessadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-100,100,1,0,0 ) ); | |
439 VBrightness=AddHScaler( VBrightnessadj,NULL,1 ); | |
440 gtk_table_attach( GTK_TABLE( table1 ),VBrightness,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
441 gtk_widget_set_usize( VBrightness,-1,45 ); | |
442 | |
443 VHueadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-100,100,1,0,0 ) ); | |
444 VHue=AddHScaler( VHueadj,NULL,1 ); | |
445 gtk_table_attach( GTK_TABLE( table1 ),VHue,1,2,2,3,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
446 gtk_widget_set_usize( VHue,-1,45 ); | |
447 | |
448 VSaturationadj=GTK_ADJUSTMENT( gtk_adjustment_new( 0,-100,100,1,0,0 ) ); | |
449 VSaturation=AddHScaler( VSaturationadj,NULL,1 ); | |
450 gtk_table_attach( GTK_TABLE( table1 ),VSaturation,1,2,3,4,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
451 gtk_widget_set_usize( VSaturation,-1,45 ); | |
452 | |
453 gtk_notebook_set_tab_label( GTK_NOTEBOOK( Notebook ),gtk_notebook_get_nth_page( GTK_NOTEBOOK( Notebook ),1 ), | |
454 AddLabel( MSGTR_EQU_Video,NULL ) ); | |
455 | |
456 AddHSeparator( vbox1 ); | |
457 | |
458 hbuttonbox1=AddHButtonBox( vbox1 ); | |
459 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
460 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
461 | |
462 Config=AddButton( MSGTR_Config,hbuttonbox1 ); | |
463 Clear=AddButton( MSGTR_Clear,hbuttonbox1 ); | |
464 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
465 | |
466 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
467 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
468 | |
469 gtk_signal_connect( GTK_OBJECT( Equalizer ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&Equalizer ); | |
470 gtk_signal_connect( GTK_OBJECT( Equalizer ),"focus_in_event",GTK_SIGNAL_FUNC( eqFocus ),(void *)2 ); | |
471 | |
472 gtk_signal_connect( GTK_OBJECT( ChannelsList ),"select_row",GTK_SIGNAL_FUNC( eqSelectChannelsListRow ),NULL ); | |
473 | |
474 gtk_signal_connect( GTK_OBJECT( A3125 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)0 ); | |
475 gtk_signal_connect( GTK_OBJECT( A6250 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)1 ); | |
476 gtk_signal_connect( GTK_OBJECT( A125 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)2 ); | |
477 gtk_signal_connect( GTK_OBJECT( A250 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)3 ); | |
478 gtk_signal_connect( GTK_OBJECT( A500 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)4 ); | |
479 gtk_signal_connect( GTK_OBJECT( A1000 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)5 ); | |
480 gtk_signal_connect( GTK_OBJECT( A2000 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)6 ); | |
481 gtk_signal_connect( GTK_OBJECT( A4000 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)7 ); | |
482 gtk_signal_connect( GTK_OBJECT( A8000 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)8 ); | |
483 gtk_signal_connect( GTK_OBJECT( A16000 ),"motion_notify_event",GTK_SIGNAL_FUNC( eqHScaleMotion ),(void*)9 ); | |
484 | |
485 gtk_signal_connect( GTK_OBJECT( VContrast ),"motion_notify_event",GTK_SIGNAL_FUNC( eqVScaleMotion ),(void*)1 ); | |
486 gtk_signal_connect( GTK_OBJECT( VBrightness ),"motion_notify_event",GTK_SIGNAL_FUNC( eqVScaleMotion ),(void*)2 ); | |
487 gtk_signal_connect( GTK_OBJECT( VHue ),"motion_notify_event",GTK_SIGNAL_FUNC( eqVScaleMotion ),(void*)3 ); | |
488 gtk_signal_connect( GTK_OBJECT( VSaturation ),"motion_notify_event",GTK_SIGNAL_FUNC( eqVScaleMotion ),(void *)4 ); | |
489 | |
490 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( eqButtonReleased ),(void *)0 ); | |
491 gtk_signal_connect( GTK_OBJECT( Clear ),"clicked",GTK_SIGNAL_FUNC( eqButtonReleased ),(void *)1 ); | |
492 gtk_signal_connect( GTK_OBJECT( Config ),"clicked",GTK_SIGNAL_FUNC( eqButtonReleased ),(void *)2 ); | |
493 | |
494 gtk_signal_connect( GTK_OBJECT( Notebook ),"switch_page",GTK_SIGNAL_FUNC( eqNotebook ),NULL ); | |
495 | |
496 gtk_window_add_accel_group( GTK_WINDOW( Equalizer ),accel_group ); | |
497 | |
498 return Equalizer; | |
499 } | |
500 | |
501 // --- equalizer config dialog box | |
502 | |
503 static GtkWidget * CBChannel1; | |
504 static GtkWidget * CEChannel1; | |
505 static GtkWidget * CBChannel2; | |
506 static GtkWidget * CEChannel2; | |
507 static GtkWidget * CBChannel3; | |
508 static GtkWidget * CEChannel3; | |
509 static GtkWidget * CBChannel4; | |
510 static GtkWidget * CEChannel4; | |
511 static GtkWidget * CBChannel5; | |
512 static GtkWidget * CEChannel5; | |
513 static GtkWidget * CBChannel6; | |
514 static GtkWidget * CEChannel6; | |
515 static GtkWidget * ecOk; | |
516 static GtkWidget * ecCancel; | |
517 | |
518 GtkWidget * create_EquConfig( void ); | |
519 | |
520 void ShowEquConfig( void ) | |
521 { | |
522 GList * Items = NULL; | |
523 | |
524 if ( EquConfig ) gtkActive( EquConfig ); | |
525 else EquConfig=create_EquConfig(); | |
526 | |
527 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Front_Right ); | |
528 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Front_Left ); | |
529 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Back_Right ); | |
530 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Back_Left ); | |
531 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Center ); | |
532 Items=g_list_append( Items,(gpointer)MSGTR_EQU_Bass ); | |
533 | |
534 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel1 ),Items ); | |
535 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel2 ),Items ); | |
536 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel3 ),Items ); | |
537 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel4 ),Items ); | |
538 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel5 ),Items ); | |
539 gtk_combo_set_popdown_strings( GTK_COMBO( CBChannel6 ),Items ); | |
540 | |
541 g_list_free( Items ); | |
542 | |
543 gtk_entry_set_text( GTK_ENTRY( CEChannel1 ),gtkEquChannel1 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel1 ),FALSE ); | |
544 gtk_entry_set_text( GTK_ENTRY( CEChannel2 ),gtkEquChannel2 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel2 ),FALSE ); | |
545 gtk_entry_set_text( GTK_ENTRY( CEChannel3 ),gtkEquChannel3 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel3 ),FALSE ); | |
546 gtk_entry_set_text( GTK_ENTRY( CEChannel4 ),gtkEquChannel4 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel4 ),FALSE ); | |
547 gtk_entry_set_text( GTK_ENTRY( CEChannel5 ),gtkEquChannel5 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel5 ),FALSE ); | |
548 gtk_entry_set_text( GTK_ENTRY( CEChannel6 ),gtkEquChannel6 ); gtk_entry_set_editable( GTK_ENTRY( CEChannel6 ),FALSE ); | |
549 | |
550 gtk_widget_show( EquConfig ); | |
551 gtkSetLayer( EquConfig ); | |
552 } | |
553 | |
554 void HideEquConfig( void ) | |
555 { | |
556 if ( !EquConfig ) return; | |
557 gtk_widget_hide( EquConfig ); | |
558 gtk_widget_destroy( EquConfig ); | |
559 EquConfig=NULL; | |
560 } | |
561 | |
562 static void ecButtonReleased( GtkButton * button,gpointer user_data ) | |
563 { | |
564 if ( (int)user_data ) | |
565 { // if you pressed Ok | |
33739 | 566 nfree( gtkEquChannel1 ); gtkEquChannel1=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel1 ) ) ); |
567 nfree( gtkEquChannel2 ); gtkEquChannel2=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel2 ) ) ); | |
568 nfree( gtkEquChannel3 ); gtkEquChannel3=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel3 ) ) ); | |
569 nfree( gtkEquChannel4 ); gtkEquChannel4=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel4 ) ) ); | |
570 nfree( gtkEquChannel5 ); gtkEquChannel5=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel5 ) ) ); | |
571 nfree( gtkEquChannel6 ); gtkEquChannel6=gstrdup( gtk_entry_get_text( GTK_ENTRY( CEChannel6 ) ) ); | |
33572 | 572 eqSetChannelNames(); |
573 } | |
574 HideEquConfig(); | |
575 } | |
576 | |
577 GtkWidget * create_EquConfig( void ) | |
578 { | |
579 GtkWidget * vbox1; | |
580 GtkWidget * table1; | |
581 GtkWidget * hbuttonbox1; | |
582 GtkAccelGroup * accel_group; | |
583 | |
584 accel_group=gtk_accel_group_new(); | |
585 | |
586 EquConfig=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
587 gtk_widget_set_name( EquConfig,"EquConfig" ); | |
588 gtk_object_set_data( GTK_OBJECT( EquConfig ),"EquConfig",EquConfig ); | |
589 gtk_widget_set_usize( EquConfig,350,260 ); | |
590 GTK_WIDGET_SET_FLAGS( EquConfig,GTK_CAN_DEFAULT ); | |
591 gtk_window_set_title( GTK_WINDOW( EquConfig ),MSGTR_ConfigureEqualizer ); | |
592 gtk_window_set_position( GTK_WINDOW( EquConfig ),GTK_WIN_POS_CENTER ); | |
593 // gtk_window_set_modal( GTK_WINDOW( EquConfig ),TRUE ); | |
594 gtk_window_set_policy( GTK_WINDOW( EquConfig ),FALSE,FALSE,FALSE ); | |
595 gtk_window_set_wmclass( GTK_WINDOW( EquConfig ),"EquConfig","MPlayer" ); | |
596 | |
597 gtk_widget_realize( EquConfig ); | |
598 gtkAddIcon( EquConfig ); | |
599 | |
600 vbox1=AddVBox( AddDialogFrame( EquConfig ),0 ); | |
601 | |
602 table1=gtk_table_new( 6,2,FALSE ); | |
603 gtk_widget_set_name( table1,"table1" ); | |
604 gtk_widget_show( table1 ); | |
605 gtk_box_pack_start( GTK_BOX( vbox1 ),table1,TRUE,TRUE,0 ); | |
606 gtk_table_set_row_spacings( GTK_TABLE( table1 ),4 ); | |
607 gtk_table_set_col_spacings( GTK_TABLE( table1 ),4 ); | |
608 | |
609 gtk_table_attach( GTK_TABLE( table1 ), | |
610 AddLabel( MSGTR_EQU_Channel1,NULL ), | |
611 0,1,0,1,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
612 | |
613 gtk_table_attach( GTK_TABLE( table1 ), | |
614 AddLabel( MSGTR_EQU_Channel2,NULL ), | |
615 0,1,1,2,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
616 | |
617 gtk_table_attach( GTK_TABLE( table1 ), | |
618 AddLabel( MSGTR_EQU_Channel3,NULL ), | |
619 0,1,2,3,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
620 | |
621 gtk_table_attach( GTK_TABLE( table1 ), | |
622 AddLabel( MSGTR_EQU_Channel4,NULL ), | |
623 0,1,3,4,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
624 | |
625 gtk_table_attach( GTK_TABLE( table1 ), | |
626 AddLabel( MSGTR_EQU_Channel5,NULL ), | |
627 0,1,4,5,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
628 | |
629 gtk_table_attach( GTK_TABLE( table1 ), | |
630 AddLabel( MSGTR_EQU_Channel6,NULL ), | |
631 0,1,5,6,(GtkAttachOptions)( GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
632 | |
633 CBChannel1=AddComboBox( NULL ); | |
634 gtk_table_attach( GTK_TABLE( table1 ),CBChannel1,1,2,0,1,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
635 | |
636 CEChannel1=GTK_COMBO( CBChannel1 )->entry; | |
637 gtk_widget_set_name( CEChannel1,"CEChannel1" ); | |
638 gtk_widget_show( CEChannel1 ); | |
639 | |
640 CBChannel2=AddComboBox( NULL ); | |
641 gtk_table_attach( GTK_TABLE( table1 ),CBChannel2,1,2,1,2,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
642 | |
643 CEChannel2=GTK_COMBO( CBChannel2 )->entry; | |
644 gtk_widget_set_name( CEChannel2,"CEChannel2" ); | |
645 gtk_widget_show( CEChannel2 ); | |
646 | |
647 CBChannel3=AddComboBox( NULL ); | |
648 gtk_table_attach( GTK_TABLE( table1 ),CBChannel3,1,2,2,3,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
649 | |
650 CEChannel3=GTK_COMBO( CBChannel3 )->entry; | |
651 gtk_widget_set_name( CEChannel3,"CEChannel3" ); | |
652 gtk_widget_show( CEChannel3 ); | |
653 | |
654 CBChannel4=AddComboBox( NULL ); | |
655 gtk_table_attach( GTK_TABLE( table1 ),CBChannel4,1,2,3,4,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
656 | |
657 CEChannel4=GTK_COMBO( CBChannel4 )->entry; | |
658 gtk_widget_set_name( CEChannel4,"CEChannel4" ); | |
659 gtk_widget_show( CEChannel4 ); | |
660 | |
661 CBChannel5=AddComboBox( NULL ); | |
662 gtk_table_attach( GTK_TABLE( table1 ),CBChannel5,1,2,4,5,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
663 | |
664 CEChannel5=GTK_COMBO( CBChannel5 )->entry; | |
665 gtk_widget_set_name( CEChannel5,"CEChannel5" ); | |
666 gtk_widget_show( CEChannel5 ); | |
667 | |
668 CBChannel6=AddComboBox( NULL ); | |
669 gtk_table_attach( GTK_TABLE( table1 ),CBChannel6,1,2,5,6,(GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),(GtkAttachOptions)( 0 ),0,0 ); | |
670 | |
671 CEChannel6=GTK_COMBO( CBChannel6 )->entry; | |
672 gtk_widget_set_name( CEChannel6,"CEChannel6" ); | |
673 gtk_widget_show( CEChannel6 ); | |
674 | |
675 AddHSeparator( vbox1 ); | |
676 | |
677 hbuttonbox1=AddHButtonBox( vbox1 ); | |
678 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
679 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
680 | |
681 ecOk=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
682 ecCancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
683 | |
684 gtk_widget_add_accelerator( ecOk,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
685 gtk_widget_add_accelerator( ecCancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
686 | |
687 gtk_signal_connect( GTK_OBJECT( EquConfig ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&EquConfig ); | |
688 | |
689 gtk_signal_connect( GTK_OBJECT( ecOk ),"clicked",GTK_SIGNAL_FUNC( ecButtonReleased ),(void *)1 ); | |
690 gtk_signal_connect( GTK_OBJECT( ecCancel ),"clicked",GTK_SIGNAL_FUNC( ecButtonReleased ),(void *)0 ); | |
691 | |
692 gtk_window_add_accel_group( GTK_WINDOW( EquConfig ),accel_group ); | |
693 | |
694 return EquConfig; | |
695 } |