/* * Configuration GUI for XMMS waterfall spectrum analyzer * * Author: Seth Golub - Nov 1999 * Based on code from XMMS echo plugin by Johan Levin. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA * */ #include #include #include "waterfall.h" static GtkWidget *conf_dialog, *gradient_check, *hue_clist, *scrolling_check, *orientation_check, *persistpos_check, *layout_clist, *fsmooth_spinner, *tsmooth_spinner; static gint selected_layout, selected_hue; static gint conf_destroy_cb(GtkWidget * w, GdkEventAny * e, gpointer data) { gtk_widget_destroy(conf_dialog); conf_dialog = NULL; return TRUE; } static void conf_ok_cb(GtkButton * button, gpointer data) { wconf.gradient = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gradient_check)) ? SQRT_GRADIENT : LINEAR_GRADIENT; wconf.scrolling = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(scrolling_check)); wconf.layout = selected_layout; wconf.hue_mode = selected_hue; wconf.orientation = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(orientation_check)) ? ORIENT_TOP : ORIENT_BOTTOM ); wconf.persistent_position = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(persistpos_check)); wconf.freq_smooth_width = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(fsmooth_spinner) ); wconf.time_smooth_weight = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(tsmooth_spinner) ); make_fg_colors(); write_config(); gtk_widget_destroy(GTK_WIDGET(conf_dialog)); conf_dialog = NULL; } static void conf_cancel_cb(GtkButton * button, gpointer data) { gtk_widget_destroy(GTK_WIDGET(conf_dialog)); conf_dialog = NULL; } static void conf_apply_cb(GtkButton * button, gpointer data) { wconf.gradient = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gradient_check)) ? SQRT_GRADIENT : LINEAR_GRADIENT; wconf.scrolling = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(scrolling_check)); wconf.orientation = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(orientation_check)) ? ORIENT_TOP : ORIENT_BOTTOM ); wconf.persistent_position = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(persistpos_check)); wconf.freq_smooth_width = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(fsmooth_spinner) ); wconf.time_smooth_weight = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(tsmooth_spinner) ); wconf.layout = selected_layout; wconf.hue_mode = selected_hue; make_fg_colors(); } static void layout_select_row_cb( GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data ) { selected_layout = row; } static void hue_select_row_cb( GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data ) { selected_hue = row; } void waterfall_configure(void) { GtkWidget *button, *frame, *vbox, *hbox, *label; GList *hue_glist = NULL; gchar *textlist[1]; gint i; if (conf_dialog != NULL) return; conf_dialog = gtk_dialog_new(); gtk_signal_connect(GTK_OBJECT(conf_dialog), "destroy", GTK_SIGNAL_FUNC(conf_destroy_cb), NULL); gtk_container_border_width(GTK_CONTAINER(conf_dialog), 5); gtk_window_set_title(GTK_WINDOW(conf_dialog), "Configure Waterfall"); /* Layout frame */ frame = gtk_frame_new( "Layout" ); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->vbox),frame, TRUE, TRUE, 5); gtk_widget_show(frame); vbox = gtk_vbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(vbox), 5); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); /* LAYOUT */ textlist[0] = "Layout"; layout_clist = gtk_clist_new_with_titles( 1, textlist ); gtk_clist_column_title_passive( GTK_CLIST(layout_clist), 0 ); gtk_clist_set_selection_mode( GTK_CLIST(layout_clist), GTK_SELECTION_SINGLE); textlist[0] = LAYOUT_MONO_TEXT; gtk_clist_append( GTK_CLIST(layout_clist), textlist ); textlist[0] = LAYOUT_MIRRORED_MONO_TEXT; gtk_clist_append( GTK_CLIST(layout_clist), textlist ); textlist[0] = LAYOUT_STEREO_TEXT; gtk_clist_append( GTK_CLIST(layout_clist), textlist ); gtk_box_pack_start(GTK_BOX(vbox),layout_clist, TRUE, TRUE, 5); selected_layout = wconf.layout; gtk_clist_select_row( GTK_CLIST(layout_clist), wconf.layout, 0 ); gtk_signal_connect( GTK_OBJECT(layout_clist), "select_row", GTK_SIGNAL_FUNC(layout_select_row_cb), NULL ); gtk_widget_show(layout_clist); /* SCROLLING */ scrolling_check = gtk_check_button_new_with_label( "scrolling" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(scrolling_check), wconf.scrolling ); gtk_box_pack_end(GTK_BOX(vbox),scrolling_check, TRUE, TRUE, 5); gtk_widget_show(scrolling_check); /* ORIENTATION */ orientation_check = gtk_check_button_new_with_label( "upside-down" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(orientation_check), wconf.orientation == ORIENT_TOP ); gtk_box_pack_end(GTK_BOX(vbox),orientation_check, TRUE, TRUE, 5); gtk_widget_show(orientation_check); /* PERSISTENT_POSITION */ persistpos_check = gtk_check_button_new_with_label( "save window position" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(persistpos_check), wconf.persistent_position ); gtk_box_pack_end(GTK_BOX(vbox),persistpos_check, TRUE, TRUE, 5); gtk_widget_show(persistpos_check); /* Hue frame */ frame = gtk_frame_new( "Hue" ); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->vbox),frame, TRUE, TRUE, 5); gtk_widget_show(frame); vbox = gtk_vbox_new(FALSE, 0); gtk_container_border_width(GTK_CONTAINER(vbox), 5); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); /* HUE_MODE */ textlist[0] = "Hue"; hue_clist = gtk_clist_new_with_titles( 1, textlist ); gtk_clist_column_title_passive( GTK_CLIST(hue_clist), 0 ); gtk_clist_set_selection_mode( GTK_CLIST(hue_clist), GTK_SELECTION_BROWSE); textlist[0] = "Constant"; gtk_clist_append( GTK_CLIST(hue_clist), textlist ); textlist[0] = "Intensity"; gtk_clist_append( GTK_CLIST(hue_clist), textlist ); textlist[0] = "Stereo"; gtk_clist_append( GTK_CLIST(hue_clist), textlist ); textlist[0] = "Onset"; gtk_clist_append( GTK_CLIST(hue_clist), textlist ); textlist[0] = "Entropy"; gtk_clist_append( GTK_CLIST(hue_clist), textlist ); gtk_box_pack_start(GTK_BOX(vbox),hue_clist, TRUE, TRUE, 5); selected_layout = wconf.layout; gtk_clist_select_row( GTK_CLIST(hue_clist), wconf.hue_mode, 0 ); gtk_signal_connect( GTK_OBJECT(hue_clist), "select_row", GTK_SIGNAL_FUNC(hue_select_row_cb), NULL ); gtk_widget_show(hue_clist); /* Brightness Boost */ gradient_check = gtk_check_button_new_with_label( "brightness boost" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(gradient_check), (wconf.gradient == SQRT_GRADIENT ) ? TRUE : FALSE ); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->vbox),gradient_check, TRUE, TRUE, 5); gtk_widget_show(gradient_check); /* FREQ_SMOOTH_WIDTH */ hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->vbox),hbox, TRUE,TRUE,5); gtk_widget_show(hbox); fsmooth_spinner = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( wconf.freq_smooth_width, 1, NUM_BANDS, 1, 5, 0 ) ), 0, 0); gtk_box_pack_start(GTK_BOX(hbox), fsmooth_spinner, TRUE, TRUE, 5); gtk_widget_show(fsmooth_spinner); label = gtk_label_new( "Frequency smoothing width" ); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5); gtk_widget_show(label); /* TIME_SMOOTH_WEIGHT */ hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->vbox),hbox, TRUE,TRUE,5); gtk_widget_show(hbox); tsmooth_spinner = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( wconf.time_smooth_weight, 0, 100, 1, 10, 0 ) ), 0, 0); gtk_box_pack_start(GTK_BOX(hbox), tsmooth_spinner, TRUE, TRUE, 5); gtk_widget_show(tsmooth_spinner); label = gtk_label_new( "Time smoothing weight" ); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5); gtk_widget_show(label); /* dialog action buttons */ button = gtk_button_new_with_label("Ok"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->action_area), button, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(conf_ok_cb), NULL); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_grab_default(button); gtk_widget_show(button); button = gtk_button_new_with_label("Cancel"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->action_area), button, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(conf_cancel_cb), NULL); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_show(button); button = gtk_button_new_with_label("Apply"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(conf_dialog)->action_area), button, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(conf_apply_cb), NULL); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_show(button); gtk_widget_show(conf_dialog); }