//------------------------------------------------------------------------- // Filename: file.cc // Version: $Id: file.cc,v 1.1.4.2 1999/05/24 22:54:50 erik Exp $ // Copyright: Copyright (C) 1999, Erik Mouw (J.A.K.Mouw@its.tudelft.nl) // Author: Erik Mouw // Description: GUI file selection functions // Created at: Sun May 2 17:04:01 1999 // Modified by: Erik Mouw // Modified at: Sat May 22 14:42:48 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: file.cc,v 1.1.4.2 1999/05/24 22:54:50 erik Exp $" #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include "gui.hh" #include "file.hh" static void fileOpenOkCallback(GtkWidget *widget, gpointer data); static void fileOpenCancelCallback(GtkWidget *widget, gpointer data); static gint fileSelectionDeleteCallback(GtkWidget *widget, gpointer data); static GtkWidget *fileSelection = 0; void fileOpenCallback(GtkWidget *widget, gpointer data) { char buf[128]; #ifdef MUSICA_DEBUG g_print("File --> Open\n"); #endif if(fileSelection == 0) { g_snprintf(buf, 127, "%s - open MIDI file", windowName); fileSelection = gtk_file_selection_new(buf); gtk_signal_connect(GTK_OBJECT(fileSelection), "delete_event", GTK_SIGNAL_FUNC(fileSelectionDeleteCallback), fileSelection); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileSelection)->ok_button), "clicked", GTK_SIGNAL_FUNC(fileOpenOkCallback), fileSelection); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileSelection)->cancel_button), "clicked", GTK_SIGNAL_FUNC(fileOpenCancelCallback), fileSelection); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(fileSelection)); gtk_file_selection_complete(GTK_FILE_SELECTION(fileSelection), "*.[mM][iI][dD]*"); } // set selection to midi files only gtk_file_selection_complete(GTK_FILE_SELECTION(fileSelection), "*.[mM][iI][dD]*"); // FIXME: this hides directories // show widget showOrRaiseWindow(fileSelection); } static void fileOpenOkCallback(GtkWidget *widget, gpointer data) { GtkWidget *window = GTK_WIDGET(data); gchar *filename; #ifdef MUSICA_DEBUG g_print("OK\n"); #endif gtk_widget_hide(window); filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(window)); #ifdef MUSICA_DEBUG g_print("File: %s\n", filename); #endif openFile(filename); } static void fileOpenCancelCallback(GtkWidget *widget, gpointer data) { GtkWidget *window = GTK_WIDGET(data); #ifdef MUSICA_DEBUG g_print("Cancel\n"); #endif gtk_widget_hide(window); } static gint fileSelectionDeleteCallback(GtkWidget *widget, gpointer data) { #ifdef MUSICA_DEBUG g_print("Delete window\n"); #endif gtk_widget_hide(widget); return(TRUE); }