//------------------------------------------------------------------------- // Filename: options.cc // Version: $Id: options.cc,v 1.1.2.3 1999/05/24 22:54:50 erik Exp $ // Copyright: Copyright (C) 1999, Erik Mouw // Author: Erik Mouw // Description: GUI "options" menu stuff // Created at: Wed May 5 16:38:54 1999 // Modified by: Erik Mouw // Modified at: Mon May 24 14:12:47 1999 //------------------------------------------------------------------------- // // 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 of the License, 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; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #ident "$Id: options.cc,v 1.1.2.3 1999/05/24 22:54:50 erik Exp $" #ifdef HAVE_CONFIG_H # include "config.h" #endif #ifdef MUSICA_DEBUG # include #endif #include #include #include "gui.hh" #include "main.hh" #include "options.hh" static void optionsPlayApplyCallback(GtkWidget *widget, gpointer data); static void optionsPlayOkCallback(GtkWidget *widget, gpointer data); static void optionsPlayCancelCallback(GtkWidget *widget, gpointer data); static void optionsDeviceCloseCallback(GtkWidget *widget, gpointer data); static GtkWidget *optionsPlayDialog = 0; static GtkWidget *optionsDeviceDialog = 0; static GtkWidget *autoPlayButton = 0; static GtkObject *ffwdSpeedAdjustment = 0; static GtkWidget *ffwdSpeedHscale = 0; static GtkWidget *resetTempoButton = 0; static GtkWidget *cancelButton = 0; void optionsPlayCallback(GtkWidget *widget, gpointer data) { GtkWidget *frame; GtkWidget *button; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *label; double value; char buf[128]; #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif if(optionsPlayDialog == 0) { optionsPlayDialog = gtk_dialog_new(); g_snprintf(buf, 127, "%s: Play options", windowName); gtk_window_set_title(GTK_WINDOW(optionsPlayDialog), buf); gtk_signal_connect(GTK_OBJECT(optionsPlayDialog), "delete_event", GTK_SIGNAL_FUNC(dialogDeleteCallback), optionsPlayDialog); // frame for play options frame = gtk_frame_new(" Play "); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsPlayDialog)->vbox), frame, TRUE, TRUE, 2); gtk_widget_show(frame); gtk_container_border_width(GTK_CONTAINER(frame), 2); // vbox for the check buttons vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); label = gtk_label_new("When opening a file:"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 1); gtk_widget_show(label); // autoplay button autoPlayButton = gtk_check_button_new_with_label("Automatically start playing"); gtk_box_pack_start(GTK_BOX(vbox), autoPlayButton, FALSE, TRUE, 1); gtk_widget_show(autoPlayButton); // reset tempo resetTempoButton = gtk_check_button_new_with_label("Reset the relative tempo"); gtk_box_pack_start(GTK_BOX(vbox), resetTempoButton, FALSE, TRUE, 1); gtk_widget_show(resetTempoButton); // frame for speed options frame = gtk_frame_new(" Fast-forward speed "); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsPlayDialog)->vbox), frame, TRUE, TRUE, 2); gtk_widget_show(frame); gtk_container_border_width(GTK_CONTAINER(frame), 2); // vbox for slider and text vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); ffwdSpeedAdjustment = gtk_adjustment_new(10.0, // value 2.0, // lower 11.0, // upper 1.0, // step increment 1.0, // page increment 1.0); // page size ffwdSpeedHscale = gtk_hscale_new(GTK_ADJUSTMENT(ffwdSpeedAdjustment)); gtk_scale_set_digits(GTK_SCALE(ffwdSpeedHscale), 0); gtk_scale_set_value_pos(GTK_SCALE(ffwdSpeedHscale), GTK_POS_TOP); gtk_box_pack_start(GTK_BOX(vbox), ffwdSpeedHscale, FALSE, TRUE, 1); gtk_widget_show(ffwdSpeedHscale); // hbox for the two labels hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 1); gtk_widget_show(hbox); // labels label = gtk_label_new("Slower"); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 1); gtk_widget_show(label); label = gtk_label_new("Faster"); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 1); gtk_widget_show(label); // buttons in the action area button = gtk_button_new_with_label("Ok"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsPlayDialog)->action_area), button, TRUE, TRUE, 1); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(optionsPlayOkCallback), optionsPlayDialog); gtk_widget_show(button); button = gtk_button_new_with_label("Apply"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsPlayDialog)->action_area), button, TRUE, TRUE, 1); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(optionsPlayApplyCallback), optionsPlayDialog); gtk_widget_show(button); cancelButton = gtk_button_new_with_label("Cancel"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsPlayDialog)->action_area), cancelButton, TRUE, TRUE, 1); gtk_signal_connect(GTK_OBJECT(cancelButton), "clicked", GTK_SIGNAL_FUNC(optionsPlayCancelCallback), optionsPlayDialog); gtk_widget_show(cancelButton); } // set values if(autoPlay == true) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoPlayButton), TRUE); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoPlayButton), FALSE); if(resetTempo == true) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resetTempoButton), TRUE); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resetTempoButton), FALSE); value = thePlayer->getFastForwardSpeed(); gtk_adjustment_set_value(GTK_ADJUSTMENT(ffwdSpeedAdjustment), (gfloat)value); // set default button gtk_widget_grab_focus(cancelButton); showOrRaiseWindow(optionsPlayDialog); } static void optionsPlayApplyCallback(GtkWidget *widget, gpointer data) { double value; GtkWidget *dialog = GTK_WIDGET(data); #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif assert(dialog != 0); // get values if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoPlayButton)) == TRUE) autoPlay = true; else autoPlay = false; if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resetTempoButton)) == TRUE) resetTempo = true; else resetTempo = false; value = (double)GTK_ADJUSTMENT(ffwdSpeedAdjustment)->value; thePlayer->setFastForwardSpeed(value); } static void optionsPlayOkCallback(GtkWidget *widget, gpointer data) { GtkWidget *dialog = GTK_WIDGET(data); #ifdef MUSICA_DEBUG cerr << __PRETTY_FUNCTION__<< endl; #endif assert(dialog != 0); gtk_widget_hide(dialog); optionsPlayApplyCallback(widget, data); } static void optionsPlayCancelCallback(GtkWidget *widget, gpointer data) { GtkWidget *dialog = GTK_WIDGET(data); #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif assert(dialog != 0); gtk_widget_hide(dialog); } void optionsDeviceCallback(GtkWidget *widget, gpointer data) { GtkWidget *label; GtkWidget *button; char buf[128]; #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif if(optionsDeviceDialog == 0) { optionsDeviceDialog = gtk_dialog_new(); g_snprintf(buf, 127, "%s: Device options", windowName); gtk_window_set_title(GTK_WINDOW(optionsDeviceDialog), buf); gtk_signal_connect(GTK_OBJECT(optionsDeviceDialog), "delete_event", GTK_SIGNAL_FUNC(dialogDeleteCallback), optionsDeviceDialog); label = gtk_label_new("(This page intentionally left blank)"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsDeviceDialog)->vbox), label, TRUE, TRUE, 2); gtk_widget_show(label); button = gtk_button_new_with_label("Close"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(optionsDeviceCloseCallback), optionsDeviceDialog); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(optionsDeviceDialog)->action_area), button, TRUE, TRUE, 1); gtk_widget_show(button); gtk_widget_grab_focus(button); } showOrRaiseWindow(optionsDeviceDialog); } static void optionsDeviceCloseCallback(GtkWidget *widget, gpointer data) { GtkWidget *dialog = GTK_WIDGET(data); #ifdef MUSICA_DEBUG cerr<< __PRETTY_FUNCTION__<< endl; #endif assert(dialog != 0); gtk_widget_hide(dialog); }