@@ -287,6 +287,7 @@ int set_channel_source(int chan_num, int type, char *name)
287287 vert -> data_offset [chan_num - 1 ] = -1 ;
288288 /* set scale and offset to nominal values */
289289 chan -> vert_offset = 0.0 ;
290+ chan -> saved_vert_offset = 0.0 ;
290291 chan -> scale_index = 0 ;
291292 /* return success */
292293 return 0 ;
@@ -401,6 +402,8 @@ int set_vert_offset(double setting, int ac_coupled)
401402 /* set the new offset */
402403 chan -> vert_offset = setting ;
403404 chan -> ac_offset = ac_coupled ;
405+ /* copy the offset to restore when toggling AC coupling */
406+ chan -> saved_vert_offset = chan -> vert_offset ;
404407 /* update the offset display */
405408 if (chan -> data_type == HAL_BIT ) {
406409 snprintf (buf1 , BUFLEN , "----" );
@@ -723,7 +726,7 @@ static gboolean dialog_set_offset(int chan_num)
723726 vert -> offset_entry , FALSE, TRUE, 0 );
724727
725728 /* update elements */
726- snprintf (data .buf , BUFLEN , "%f" , chan -> vert_offset );
729+ snprintf (data .buf , BUFLEN , "%f" , chan -> saved_vert_offset );
727730 /* get AC coupling setting from channel */
728731 data .ac_coupled = chan -> ac_offset ;
729732 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vert -> offset_ac ), data .ac_coupled );
@@ -772,6 +775,14 @@ static void offset_changed(GtkEditable * editable, struct offset_data *data)
772775 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctrl_usr -> vert .offset_ac ));
773776 gtk_widget_set_sensitive (ctrl_usr -> vert .offset_entry , !data -> ac_coupled );
774777
778+ if (!data -> ac_coupled ) {
779+ /* select all chars, so if the user types the original value goes away */
780+ gtk_editable_select_region (
781+ GTK_EDITABLE (ctrl_usr -> vert .offset_entry ), 0 , strlen (data -> buf ));
782+ /* make it active so user doesn't have to click on it */
783+ gtk_widget_grab_focus (GTK_WIDGET (ctrl_usr -> vert .offset_entry ));
784+ }
785+
775786 /* maybe user typed something, save it in the buffer */
776787 text = gtk_entry_get_text (GTK_ENTRY (ctrl_usr -> vert .offset_entry ));
777788 snprintf (data -> buf , BUFLEN , "%s" , text );
0 commit comments