From 5147b16d1295e1358467948cbfb4ab2b3fda45f3 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Tue, 17 Mar 2020 17:13:21 +0000 Subject: [PATCH] Save and restore tx_dialog location. Only display OC Menu when protocol 1 or 2. Remove couple of warnings when compiling on Mac. --- new_menu.c | 11 +++++++---- oc_menu.c | 1 + radio.c | 4 ++++ radio_menu.c | 13 ++++++++----- soapy_discovery.c | 2 +- soapy_protocol.c | 1 + transmitter.c | 16 ++++++++++++++++ transmitter.h | 3 +++ 8 files changed, 41 insertions(+), 10 deletions(-) diff --git a/new_menu.c b/new_menu.c index 0e6fa58..7b2b273 100644 --- a/new_menu.c +++ b/new_menu.c @@ -203,6 +203,7 @@ static gboolean cw_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) } static gboolean oc_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + g_print("oc_cb\n"); cleanup(); oc_menu(top_window); return TRUE; @@ -553,10 +554,12 @@ void new_menu() gtk_grid_attach(GTK_GRID(grid),dsp_b,(i%5),i/5,1,1); i++; - GtkWidget *oc_b=gtk_button_new_with_label("OC"); - g_signal_connect (oc_b, "button-press-event", G_CALLBACK(oc_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),oc_b,(i%5),i/5,1,1); - i++; + if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) { + GtkWidget *oc_b=gtk_button_new_with_label("OC"); + g_signal_connect (oc_b, "button-press-event", G_CALLBACK(oc_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),oc_b,(i%5),i/5,1,1); + i++; + } GtkWidget *display_b=gtk_button_new_with_label("Display"); g_signal_connect (display_b, "button-press-event", G_CALLBACK(display_cb), NULL); diff --git a/oc_menu.c b/oc_menu.c index 6dcbab9..6d11145 100644 --- a/oc_menu.c +++ b/oc_menu.c @@ -113,6 +113,7 @@ static void oc_memory_tune_time_cb(GtkWidget *widget, gpointer data) { void oc_menu(GtkWidget *parent) { int i,j; +g_print("oc_menu: parent=%p\n",parent); parent_window=parent; dialog=gtk_dialog_new(); diff --git a/radio.c b/radio.c index 4bb1d21..1b82210 100644 --- a/radio.c +++ b/radio.c @@ -1330,6 +1330,9 @@ static void rxtx(int state) { if(duplex) { gtk_widget_show_all(transmitter->dialog); + if(transmitter->dialog_x!=-1 && transmitter->dialog_y!=-1) { + gtk_window_move(GTK_WINDOW(transmitter->dialog),transmitter->dialog_x,transmitter->dialog_y); + } } else { gtk_fixed_put(GTK_FIXED(fixed),transmitter->panel,transmitter->x,transmitter->y); } @@ -1356,6 +1359,7 @@ static void rxtx(int state) { SetChannelState(transmitter->id,0,1); tx_set_displaying(transmitter,0); if(duplex) { + gtk_window_get_position(GTK_WINDOW(transmitter->dialog),&transmitter->dialog_x,&transmitter->dialog_y); gtk_widget_hide(transmitter->dialog); } else { gtk_container_remove(GTK_CONTAINER(fixed), transmitter->panel); diff --git a/radio_menu.c b/radio_menu.c index 3b20c2a..388ba4d 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -440,11 +440,14 @@ void radio_menu(GtkWidget *parent) { row++; - receivers_2=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(receivers_1),"2"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (receivers_2), receivers==2); - gtk_grid_attach(GTK_GRID(grid),receivers_2,col,row,1,1); - g_signal_connect(receivers_2,"toggled",G_CALLBACK(receivers_cb),(gpointer *)2); - row++; + if(receivers>1) { + receivers_2=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(receivers_1),"2"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (receivers_2), receivers==2); + gtk_grid_attach(GTK_GRID(grid),receivers_2,col,row,1,1); + g_signal_connect(receivers_2,"toggled",G_CALLBACK(receivers_cb),(gpointer *)2); + row++; + } + col++; if(row>temp_row) temp_row=row; diff --git a/soapy_discovery.c b/soapy_discovery.c index 330644d..8b50de9 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -263,7 +263,7 @@ void soapy_discovery() { fprintf(stderr,"soapy_discovery\n"); rtlsdr_count=0; SoapySDRKwargs *results = SoapySDRDevice_enumerate(NULL, &length); -fprintf(stderr,"soapy_discovery: length=%d\n",length); +fprintf(stderr,"soapy_discovery: length=%d\n",(int)length); for (i = 0; i < length; i++) { for (size_t j = 0; j < results[i].size; j++) { if(strcmp(results[i].keys[j],"driver")==0 && strcmp(results[i].vals[j],"audio")!=0) { diff --git a/soapy_protocol.c b/soapy_protocol.c index 3b67dfb..d9914a6 100644 --- a/soapy_protocol.c +++ b/soapy_protocol.c @@ -375,6 +375,7 @@ fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_closeStream\n"); SoapySDRDevice_closeStream(soapy_device,rx_stream); fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_unmake\n"); SoapySDRDevice_unmake(soapy_device); + return NULL; } void soapy_protocol_process_local_mic(float sample) { diff --git a/transmitter.c b/transmitter.c index 0c27b37..4f0222b 100644 --- a/transmitter.c +++ b/transmitter.c @@ -244,6 +244,13 @@ void transmitter_save_state(TRANSMITTER *tx) { sprintf(name,"transmitter.%d.xit",tx->id); sprintf(value,"%lld",tx->xit); setProperty(name,value); + + sprintf(name,"transmitter.%d.dialog_x",tx->id); + sprintf(value,"%d",tx->dialog_x); + setProperty(name,value); + sprintf(name,"transmitter.%d.dialog_y",tx->id); + sprintf(value,"%d",tx->dialog_y); + setProperty(name,value); } void transmitter_restore_state(TRANSMITTER *tx) { @@ -338,6 +345,12 @@ void transmitter_restore_state(TRANSMITTER *tx) { sprintf(name,"transmitter.%d.xit",tx->id); value=getProperty(name); if(value) tx->xit=atoll(value); + sprintf(name,"transmitter.%d.dialog_x",tx->id); + value=getProperty(name); + if(value) tx->dialog_x=atoi(value); + sprintf(name,"transmitter.%d.dialog_y",tx->id); + value=getProperty(name); + if(value) tx->dialog_y=atoi(value); } static double compute_power(double p) { @@ -778,6 +791,9 @@ fprintf(stderr,"create_transmitter: id=%d buffer_size=%d mic_sample_rate=%d mic_ tx->xit_enabled=FALSE; tx->xit=0LL; + tx->dialog_x=-1; + tx->dialog_y=-1; + transmitter_restore_state(tx); diff --git a/transmitter.h b/transmitter.h index 6b75146..ad10695 100644 --- a/transmitter.h +++ b/transmitter.h @@ -106,6 +106,9 @@ typedef struct _transmitter { int x; int y; + int dialog_x; + int dialog_y; + } TRANSMITTER; extern TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, int width, int height); -- 2.45.2