mp3splt-gtk
options_manager.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-2012 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  * Get the current state of all GUI buttons
35  *
36  * The code contained in this file reads out the current
37  * state of all GUI buttons and saves it into the structure
38  * ui->mp3splt_state.
39  ********************************************************/
40 
41 #include "options_manager.h"
42 
51 {
52  lock_mutex(&ui->variables_mutex);
53  mp3splt_set_filename_to_split(ui->mp3splt_state, get_input_filename(ui->gui));
54  unlock_mutex(&ui->variables_mutex);
55 
56  if (get_checked_output_radio_box(ui) == 0)
57  {
59  const char *data = gtk_entry_get_text(GTK_ENTRY(ui->gui->output_entry));
60  gint error = mp3splt_set_oformat(ui->mp3splt_state, data);
62  }
63  else
64  {
66  }
67 }
68 
77 {
78  gui_state *gui = ui->gui;
79 
80  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->frame_mode)))
81  {
83  }
84  else
85  {
87  }
88 
89  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->adjust_mode)))
90  {
93  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->spinner_adjust_offset)));
94  mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_PARAM_GAP,
95  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gui->spinner_adjust_gap)));
97  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->spinner_adjust_threshold)));
99  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->spinner_adjust_min)));
100  }
101  else
102  {
104  }
105 
108 
109  if (get_split_file_mode_safe(ui) == FILE_MODE_SINGLE)
110  {
112  }
113  else
114  {
115  switch (get_selected_split_mode_safe(ui))
116  {
117  case SELECTED_SPLIT_NORMAL:
119  break;
120  case SELECTED_SPLIT_WRAP:
122  break;
123  case SELECTED_SPLIT_TIME:
125  mp3splt_set_long_option(ui->mp3splt_state, SPLT_OPT_SPLIT_TIME,
126  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gui->spinner_time)) * 100);
127  break;
128  case SELECTED_SPLIT_EQUAL_TIME_TRACKS:
131  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gui->spinner_equal_tracks)));
132  break;
133  case SELECTED_SPLIT_SILENCE:
136  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->all_spinner_silence_threshold)));
138  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->all_spinner_silence_offset)));
140  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gui->all_spinner_silence_number_tracks)));
142  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->all_spinner_silence_minimum)));
144  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->all_spinner_track_minimum)));
145  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->all_silence_remove_silence)))
146  {
148  }
149  else
150  {
152  }
153  break;
154  case SELECTED_SPLIT_TRIM_SILENCE:
157  gtk_spin_button_get_value(GTK_SPIN_BUTTON(gui->all_spinner_trim_silence_threshold)));
158  break;
159  case SELECTED_SPLIT_ERROR:
161  break;
162  default:
163  break;
164  }
165  }
166 
167  gint selected_tags_value = rh_get_active_value(gui->tags_radio);
168  if (selected_tags_value == NO_TAGS)
169  {
171  }
172  else if (selected_tags_value == DEFAULT_TAGS)
173  {
175  }
176  else if (selected_tags_value == ORIGINAL_FILE_TAGS)
177  {
179  }
180  else if (selected_tags_value == TAGS_FROM_FILENAME)
181  {
182  put_tags_from_filename_regex_options(ui);
183  }
184 
185  gint tags_radio_choice = get_checked_tags_version_radio_box(gui);
186  if (tags_radio_choice == 0)
187  {
189  }
190  else if (tags_radio_choice == 1)
191  {
193  }
194  else if (tags_radio_choice == 2)
195  {
197  }
198  else if (tags_radio_choice == 3)
199  {
200  mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_FORCE_TAGS_VERSION, 12);
201  }
202 
204  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->create_dirs_from_output_files)));
205 }
206 
207 void put_tags_from_filename_regex_options(ui_state *ui)
208 {
209  gui_state *gui = ui->gui;
210 
212 
213  gint underscores =
214  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->replace_underscore_by_space_check_box));
215  mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_REPLACE_UNDERSCORES_TAG_FORMAT, underscores);
216 
218  ch_get_active_value(gui->artist_text_properties_combo));
220  ch_get_active_value(gui->album_text_properties_combo));
222  ch_get_active_value(gui->title_text_properties_combo));
224  ch_get_active_value(gui->comment_text_properties_combo));
225 
226  const gchar *regular_expression = gtk_entry_get_text(GTK_ENTRY(gui->regex_entry));
227  mp3splt_set_input_filename_regex(ui->mp3splt_state, regular_expression);
228 
229  const gchar *default_comment = gtk_entry_get_text(GTK_ENTRY(gui->comment_tag_entry));
230  if (strlen(default_comment) == 0)
231  {
232  default_comment = NULL;
233  }
234  mp3splt_set_default_comment_tag(ui->mp3splt_state, default_comment);
235 
236  mp3splt_set_default_genre_tag(ui->mp3splt_state, ch_get_active_str_value(gui->genre_combo));
237 }
238