mp3splt-gtk

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

export.c
Go to the documentation of this file.
1 /**********************************************************
2 *
3 * mp3splt-gtk -- utility based on mp3splt,
4 * for mp3/ogg splitting without decoding
5 *
6 * Copyright: (C) 2005-2010 Alexandru Munteanu
7 * Contact: m@ioalex.net
8 *
9 * http://mp3splt.sourceforge.net/
10 *
11 *********************************************************/
12
13 /**********************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 * USA.
29 *
30 *********************************************************/
31
32 /*!********************************************************
33 * \file
34 * The function that allows to export the current list of
35 * splitpoints as a Cue sheet.
36 *********************************************************/
37
38 #include "export.h"
39
41 static void export_to_cue_file(const gchar* filename, ui_state *ui)
42 {
43 const gchar *old_fname = mp3splt_get_filename_to_split(ui->mp3splt_state);
44 gchar *fname = NULL;
45 if (old_fname != NULL) { fname = g_strdup(old_fname); }
46
47 mp3splt_set_filename_to_split(ui->mp3splt_state, get_input_filename(ui->gui));
48
49 gchar *directory = g_path_get_dirname(filename);
50 mp3splt_set_path_of_split(ui->mp3splt_state, directory);
51 g_free(directory);
52
53 mp3splt_erase_all_splitpoints(ui->mp3splt_state);
54 mp3splt_erase_all_tags(ui->mp3splt_state);
55
56 put_splitpoints_and_tags_in_mp3splt_state(ui->mp3splt_state, ui);
57
58 gchar *file = g_path_get_basename(filename);
59 splt_code err = mp3splt_export(ui->mp3splt_state, CUE_EXPORT, file, SPLT_FALSE);
60 print_status_bar_confirmation(err, ui);
61 g_free(file);
62
63 mp3splt_set_filename_to_split(ui->mp3splt_state, fname);
64 if (fname != NULL) { g_free(fname); }
65 }
66
67 void export_cue_file_in_configuration_directory(ui_state *ui)
68 {
69 if (ui->status->lock_cue_export) { return; }
70
71 mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_CUE_DISABLE_CUE_FILE_CREATED_MESSAGE,
72 SPLT_TRUE);
73
74 gchar *configuration_directory = get_configuration_directory();
75
76 gsize filename_size = strlen(configuration_directory) + 20;
77 gchar *splitpoints_cue_filename = g_malloc(filename_size * sizeof(gchar));
78 g_snprintf(splitpoints_cue_filename, filename_size, "%s%s%s", configuration_directory,
79 G_DIR_SEPARATOR_S, "splitpoints.cue");
80
81 export_to_cue_file(splitpoints_cue_filename, ui);
82
83 g_free(configuration_directory);
84 g_free(splitpoints_cue_filename);
85
86 mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_CUE_DISABLE_CUE_FILE_CREATED_MESSAGE,
87 SPLT_FALSE);
88 }
89
91 void export_cue_file_event(GtkWidget *widget, ui_state *ui)
92 {
93 GtkWidget *file_chooser = gtk_file_chooser_dialog_new(_("Cue filename to export"),
94 NULL,
95 GTK_FILE_CHOOSER_ACTION_SAVE,
96 GTK_STOCK_CANCEL,
97 GTK_RESPONSE_CANCEL,
98 GTK_STOCK_SAVE,
99 GTK_RESPONSE_ACCEPT,
100 NULL);
101
102 wh_set_browser_directory_handler(ui, file_chooser);
103
104 GtkFileFilter *our_filter = gtk_file_filter_new();
105 gtk_file_filter_set_name (our_filter, _("cue files (*.cue)"));
106 gtk_file_filter_add_pattern(our_filter, "*.cue");
107 gtk_file_filter_add_pattern(our_filter, "*.CUE");
108 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser), our_filter);
109 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(file_chooser),TRUE);
110
111 if (gtk_dialog_run(GTK_DIALOG(file_chooser)) == GTK_RESPONSE_ACCEPT)
112 {
113 gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
114 export_to_cue_file(filename, ui);
115 g_free(filename);
116 }
117
118 gtk_widget_destroy(file_chooser);
119 }
120
put_splitpoints_and_tags_in_mp3splt_state
void put_splitpoints_and_tags_in_mp3splt_state(splt_state *state, ui_state *ui)
puts the splitpoints into the state
Definition: splitpoints_window.c:2166
get_input_filename
gchar * get_input_filename(gui_state *gui)
Get the name of the input file.
Definition: main_window.c:76
print_status_bar_confirmation
void print_status_bar_confirmation(gint error, ui_state *ui)
Output an error message from libmp3splt to the status bar.
Definition: main_window.c:1115
export_cue_file_event
void export_cue_file_event(GtkWidget *widget, ui_state *ui)
Choose the file to save the session to.
Definition: export.c:91
ui_state
Definition: ui_types.h:485