00001 #ifdef HAVE_CONFIG_H 00002 # include <config.h> 00003 #endif 00004 00005 #include <gnome.h> 00006 #include <stdint.h> 00007 00008 #include "prop_callbacks.h" 00009 #include "prop_interface.h" 00010 #include "support.h" 00011 00012 #include "preferences.h" 00013 #include "morse.h" 00014 #include "audio.h" 00015 #include "interface_il.h" 00016 00017 #define ENTRY_LENGTH 10 00018 00019 void 00020 on_morse2txt_properties_apply (GnomePropertyBox *propertybox, 00021 gint page_num, 00022 gpointer user_data) 00023 { 00024 const gchar *s = NULL; 00025 GtkWidget *tmp; 00026 static char ctmp[AUDIO_DEVICE_NAME_LENGTH]; 00027 00028 tmp = lookup_widget(main_gui.properties_v, "comboboxentryDevicePath"); 00029 s = gtk_combo_box_get_active_text(GTK_COMBO_BOX(tmp)); 00030 g_snprintf(ctmp, AUDIO_DEVICE_NAME_LENGTH, "%s", s); 00031 audio_device_name_set(morse_audio_rec_dev_get(), ctmp); 00032 00033 tmp = lookup_widget(main_gui.properties_v, "comboboxentryDeviceType"); 00034 morse_audio_device_type_id_set((int32_t)gtk_combo_box_get_active(GTK_COMBO_BOX(tmp))); 00035 00036 tmp = lookup_widget(main_gui.properties_v, "comboboxentrySampleFrequency"); 00037 morse_audio_sample_rate_set(atoi(gtk_combo_box_get_active_text(GTK_COMBO_BOX(tmp)))); 00038 00039 tmp = lookup_widget(main_gui.properties_v, "comboboxentryFFTPacketLength"); 00040 morse_set_tone_packet_size(atoi(gtk_combo_box_get_active_text(GTK_COMBO_BOX(tmp)))); 00041 00042 tmp = lookup_widget(main_gui.properties_v, "comboboxentryFilterTaps"); 00043 morse_set_filter_taps(atoi(gtk_combo_box_get_active_text(GTK_COMBO_BOX(tmp)))); 00044 00045 morse_set_fft_data_size(morse_get_tone_packet_size() / FFT_DATA_SIZE_DIVISOR); 00046 gtk_curve_set_range (GTK_CURVE (main_gui.scope_v), 0.0, (gfloat)morse_get_fft_data_size(), 0.0, morse_get_fft_graph_top()); 00047 00048 gtk_adjustment_set_value(GTK_ADJUSTMENT(main_gui.adjustment_frequency_v), 0.0); 00049 GTK_ADJUSTMENT(main_gui.adjustment_frequency_v)->lower = 0.0; 00050 GTK_ADJUSTMENT(main_gui.adjustment_frequency_v)->upper = (gfloat)(morse_get_fft_data_size() - 1); 00051 } 00052 00053 00054 void 00055 on_morse2txt_properties_show (GtkWidget *widget, 00056 gpointer user_data) 00057 { 00058 GtkWidget *tmp; 00059 double freq_resolution, max_wpm; 00060 int packet_length, sample_freq; 00061 static char c_tmp[ENTRY_LENGTH]; 00062 char *tmp_char; 00063 int32_t i; 00064 00065 sample_freq = morse_audio_sample_rate_get(); 00066 packet_length = morse_get_tone_packet_size(); 00067 00068 freq_resolution = (double)sample_freq / (double)packet_length; 00069 max_wpm = morse_max_wpm_supported((double)sample_freq, (double)packet_length); 00070 00071 g_snprintf(c_tmp, ENTRY_LENGTH, "%d", morse_get_tone_packet_size()); 00072 tmp = lookup_widget(main_gui.properties_v, "comboboxentryFFTPacketLength"); 00073 gtk_entry_set_text(GTK_ENTRY(GTK_BIN(tmp)->child), c_tmp); 00074 00075 g_snprintf(c_tmp, ENTRY_LENGTH, "%2.1f", freq_resolution); 00076 tmp = lookup_widget(main_gui.properties_v, "frequency_resolution_entry"); 00077 gtk_entry_set_text(GTK_ENTRY(tmp), c_tmp); 00078 00079 g_snprintf(c_tmp, ENTRY_LENGTH, "%2.1f", max_wpm); 00080 tmp = lookup_widget(main_gui.properties_v, "maximum_wpm_entry"); 00081 gtk_entry_set_text(GTK_ENTRY(tmp), c_tmp); 00082 00083 g_snprintf(c_tmp, ENTRY_LENGTH, "%d", sample_freq); 00084 tmp = lookup_widget(main_gui.properties_v, "comboboxentrySampleFrequency"); 00085 gtk_entry_set_text(GTK_ENTRY(GTK_BIN(tmp)->child), c_tmp); 00086 00087 tmp = lookup_widget(main_gui.properties_v, "comboboxentryDevicePath"); 00088 audio_device_name_get(morse_audio_rec_dev_get(), &tmp_char); 00089 gtk_entry_set_text(GTK_ENTRY(GTK_BIN(tmp)->child), tmp_char); 00090 00091 tmp = lookup_widget(main_gui.properties_v, "comboboxentryFilterTaps"); 00092 g_snprintf(c_tmp, ENTRY_LENGTH, "%d", morse_get_filter_taps()); 00093 gtk_entry_set_text(GTK_ENTRY(GTK_BIN(tmp)->child), c_tmp); 00094 00095 tmp = lookup_widget(main_gui.properties_v, "comboboxentryDeviceType"); 00096 i = 0; 00097 while(NULL != (tmp_char = audio_device_type_name_get(i))) { 00098 gtk_combo_box_append_text(GTK_COMBO_BOX(tmp), tmp_char); 00099 i++; 00100 } 00101 gtk_combo_box_set_active(GTK_COMBO_BOX(tmp), (gint)morse_audio_device_type_id_get()); 00102 00103 gnome_property_box_set_modified(GNOME_PROPERTY_BOX(main_gui.properties_v), FALSE); 00104 } 00105 00106 00107 void 00108 widget_in_property_box_changed (GtkComboBox *combobox, 00109 gpointer user_data) 00110 { 00111 GtkWidget *tmp; 00112 double freq_resolution, max_wpm; 00113 int packet_length, sample_freq; 00114 00115 char c_tmp[ENTRY_LENGTH]; 00116 00117 gnome_property_box_changed (GNOME_PROPERTY_BOX (main_gui.properties_v)); 00118 00119 tmp = lookup_widget(main_gui.properties_v, "comboboxentrySampleFrequency"); 00120 sample_freq = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(tmp)->child))); 00121 00122 tmp = lookup_widget(main_gui.properties_v, "comboboxentryFFTPacketLength"); 00123 packet_length = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(tmp)->child))); 00124 00125 freq_resolution = (double)sample_freq / (double)packet_length; 00126 max_wpm = morse_max_wpm_supported((double)sample_freq, (double)packet_length); 00127 00128 g_snprintf(c_tmp, ENTRY_LENGTH, "%2.1f", freq_resolution); 00129 tmp = lookup_widget(main_gui.properties_v, "frequency_resolution_entry"); 00130 gtk_entry_set_text(GTK_ENTRY(tmp), c_tmp); 00131 00132 g_snprintf(c_tmp, ENTRY_LENGTH, "%2.1f", max_wpm); 00133 tmp = lookup_widget(main_gui.properties_v, "maximum_wpm_entry"); 00134 gtk_entry_set_text(GTK_ENTRY(tmp), c_tmp); 00135 }