@@ -83,6 +83,8 @@ struct offset_data {
8383 int ac_coupled ;
8484};
8585
86+ GtkWidget * chan_buttons [16 ] = {NULL };
87+
8688static void init_chan_sel_window (void );
8789static void init_chan_info_window (void );
8890static void init_vert_info_window (void );
@@ -535,9 +537,10 @@ static void init_chan_sel_window(void)
535537 color_array [0 ][j ] = normal_colors [n ][j ];
536538 color_array [1 ][j ] = selected_colors [n ][j ];
537539 }
538- snprintf (buf , 4 , "%ld" , n + 1 );
540+ snprintf (buf , 4 , "%ld" , n + 1 );
539541 /* define the button */
540542 button = gtk_toggle_button_new_with_label (buf );
543+ chan_buttons [n ] = button ;
541544
542545 style_with_css (button , color_array );
543546 /* put it in the window */
@@ -803,7 +806,7 @@ static void chan_sel_button(GtkWidget * widget, gpointer gdata)
803806 chan_num = (long ) gdata ;
804807 chan = & (ctrl_usr -> chan [chan_num - 1 ]);
805808
806- if (ignore_click != 0 ) {
809+ if (ignore_click ) {
807810 ignore_click = 0 ;
808811 return ;
809812 }
@@ -851,14 +854,19 @@ static void chan_sel_button(GtkWidget * widget, gpointer gdata)
851854 }
852855 }
853856 vert -> chan_enabled [chan_num - 1 ] = 1 ;
857+ /* make chan_num the selected channel */
858+ vert -> selected = chan_num ;
859+ channel_changed ();
860+ } else if (vert -> selected == chan_num ) {
861+ /* a click on an already active channel turns it off */
862+ set_channel_off (chan_num );
863+ ignore_click = 0 ;
854864 } else {
855865 /* channel was already enabled, user wants to select it */
856866 /* button should stay down, so we force it */
857867 ignore_click = 1 ;
858868 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget ), TRUE);
859- }
860- if (vert -> selected != chan_num ) {
861- /* make chan_num the selected channel */
869+ /* make chan_num the selected channel */
862870 vert -> selected = chan_num ;
863871 channel_changed ();
864872 }
@@ -1092,8 +1100,18 @@ void channel_changed(void)
10921100 GtkAdjustment * adj ;
10931101 gchar * name ;
10941102 gchar buf1 [BUFLEN + 1 ], buf2 [BUFLEN + 1 ];
1095-
1103+ static int last_channel = 0 ;
10961104 vert = & (ctrl_usr -> vert );
1105+ /* add a name to apply CSS for highlighted channel */
1106+ if (last_channel != vert -> selected ) {
1107+ if (last_channel ) {
1108+ gtk_widget_set_name (chan_buttons [last_channel - 1 ],"" );
1109+ }
1110+ if (vert -> selected ) {
1111+ gtk_widget_set_name (chan_buttons [vert -> selected - 1 ],"selected" );
1112+ }
1113+ last_channel = vert -> selected ;
1114+ }
10971115 if ((vert -> selected < 1 ) || (vert -> selected > 16 )) {
10981116 gtk_label_set_text_if (vert -> scale_label , "----" );
10991117 gtk_label_set_text_if (vert -> chan_num_label , "--" );
@@ -1189,9 +1207,9 @@ static void style_with_css(GtkWidget *widget, int (*color_arr)[3])
11891207 GtkStyleContext * context ;
11901208 GtkCssProvider * provider ;
11911209
1192- char buf [180 ];
1193-
1194- snprintf ( buf , sizeof ( buf ), "* {background: none ;}\n"
1210+ char buf [230 ];
1211+ snprintf ( buf , sizeof ( buf ), "* {margin: 1px; border-style:solid; border-width: 2px;}\n"
1212+ "#selected {border-color: black; font-weight: bold ;}\n"
11951213 "*:checked {background: rgb(%d,%d,%d);}\n"
11961214 "*:hover {background: rgb(%d,%d,%d);}\n"
11971215 "*:active {background: rgb(%d,%d,%d);}" ,
0 commit comments