]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Save and restore tx_dialog location.
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Tue, 17 Mar 2020 17:13:21 +0000 (17:13 +0000)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Tue, 17 Mar 2020 17:13:21 +0000 (17:13 +0000)
Only display OC Menu when protocol 1 or 2.
Remove couple of warnings when compiling on Mac.

new_menu.c
oc_menu.c
radio.c
radio_menu.c
soapy_discovery.c
soapy_protocol.c
transmitter.c
transmitter.h

index 0e6fa587165b6b63aecc3051250074e2ee5b2c25..7b2b2735d21944098691116dd0b7c2288bb85a7d 100644 (file)
@@ -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);
index 6dcbab9c2477cffed65a21b13371a51e52518571..6d111458dc27d8af9abcb4da255cf152916360e6 100644 (file)
--- 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 4bb1d216eca1641e1b4ecf41530ee8e70849491a..1b822109c5639d3ed78c7f65e3e3cef5a13bed13 100644 (file)
--- 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);
index 3b20c2a24bd728653ceb6a47300eb7ef5bbcc1fb..388ba4d27aafda8de343aae69435481a22780ca5 100644 (file)
@@ -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;
 
index 330644df7608a5c3ded86f861f7b7297edb6fb83..8b50de9ed2c6e4d4a0e4bb55b096e01cd1a96d1b 100644 (file)
@@ -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) {
index 3b67dfbc56f85eb4656e5bc2ac4adc957ae1723c..d9914a68ae920611e6ed2fe2d7181a7effec940d 100644 (file)
@@ -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) {
index 0c27b37ae3c4661ed324e820843fb4982b9efc44..4f0222baf61697e91ba6cc77c1a75e72e1f4dc5e 100644 (file)
@@ -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);
 
 
index 6b751468e15b0cbeb1ccdafb61a9e37e2aa866e0..ad10695bff8aa03980d3d0e199b4ee2168b17138 100644 (file)
@@ -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);