1 /* wavbreaker - A tool to split a wave file up into multiple waves.
2  * Copyright (C) 2002-2005 Timothy Robinson
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 
19 #include <gtk/gtk.h>
20 
21 #include <stdlib.h>
22 #include <unistd.h>
23 
24 #include "sample.h"
25 #include "wavbreaker.h"
26 
27 #include "gettext.h"
28 
29 
30 static char *saveas_dirname = NULL;
31 
saveas_get_dirname()32 char *saveas_get_dirname()
33 {
34     return saveas_dirname;
35 }
36 
saveas_set_dirname(const char * val)37 void saveas_set_dirname(const char *val)
38 {
39     if (saveas_dirname != NULL) {
40         g_free(saveas_dirname);
41     }
42     saveas_dirname = g_strdup(val);
43 }
44 
saveas_show(GtkWidget * parent_window)45 void saveas_show(GtkWidget *parent_window)
46 {
47     GtkWidget *dialog;
48 
49     dialog = gtk_file_chooser_dialog_new( _("Select folder to save wave files"),
50                                           GTK_WINDOW(parent_window),
51                                           GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
52                                           _("_Cancel"), GTK_RESPONSE_CANCEL,
53                                           _("_Save"), GTK_RESPONSE_ACCEPT,
54                                           NULL);
55 
56     if( saveas_get_dirname() == NULL) {
57         saveas_set_dirname( getenv( "PWD"));
58     }
59 
60     gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), saveas_get_dirname());
61 
62     if( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
63         saveas_set_dirname( gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)));
64         wavbreaker_write_files( saveas_get_dirname());
65     }
66 
67     gtk_widget_destroy( GTK_WIDGET(dialog));
68 }
69 
70 
71