32 #include "libmp3splt_manager.h"
34 static void lmanager_change_window_progress_bar(splt_progress *p_bar,
void *data);
35 static void lmanager_put_message_from_library(
const char *message, splt_message_type mess_type,
void *data);
37 void lmanager_init_and_find_plugins(
ui_state *ui)
39 mp3splt_set_progress_function(ui->mp3splt_state, lmanager_change_window_progress_bar, ui);
40 mp3splt_set_split_filename_function(ui->mp3splt_state, lmanager_put_split_filename, ui);
41 mp3splt_set_message_function(ui->mp3splt_state, lmanager_put_message_from_library, ui);
43 mp3splt_set_int_option(ui->mp3splt_state, SPLT_OPT_DEBUG_MODE, SPLT_FALSE);
44 mp3splt_set_int_option(ui->mp3splt_state,
45 SPLT_OPT_SET_FILE_FROM_CUE_IF_FILE_TAG_FOUND, SPLT_TRUE);
47 gint error = mp3splt_find_plugins(ui->mp3splt_state);
50 char *error_from_library = mp3splt_get_strerror(ui->mp3splt_state, error);
51 if (error_from_library == NULL) {
return; }
52 ui_fail(ui, error_from_library);
56 void lmanager_stop_split(
ui_state *ui)
58 gint err = mp3splt_stop_split(ui->mp3splt_state);
62 static gboolean lmanager_put_split_filename_idle(
ui_with_fname *ui_fname)
64 char *filename = ui_fname->fname;
69 gint fname_status_size = (strlen(filename) + 255);
70 gchar *fname_status = g_malloc(
sizeof(
char) * fname_status_size);
71 g_snprintf(fname_status, fname_status_size, _(
" File '%s' created"), filename);
81 gtk_widget_set_sensitive(ui->gui->queue_files_button, TRUE);
82 gtk_widget_set_sensitive(ui->gui->remove_all_files_button, TRUE);
85 while (gtk_events_pending())
102 void lmanager_put_split_filename(
const char *filename,
void *data)
108 ui_fname->fname = NULL;
111 ui_fname->fname = strdup(filename);
114 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
115 (GSourceFunc)lmanager_put_split_filename_idle, ui_fname, NULL);
118 static gboolean lmanager_put_message_from_library_idle(
ui_with_message *ui_message)
120 splt_message_type mess_type = ui_message->mess_type;
123 char *mess = ui_message->message;
128 for (i = 0;i < strlen(mess);i++)
139 while (gtk_events_pending())
141 gtk_main_iteration();
156 static void lmanager_put_message_from_library(
const char *message, splt_message_type mess_type,
void *data)
162 ui_message->message = NULL;
165 ui_message->message = strdup(message);
167 ui_message->mess_type = mess_type;
169 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
170 (GSourceFunc)lmanager_put_message_from_library_idle, ui_message, NULL);
173 static gboolean lmanager_change_window_progress_bar_idle(
ui_with_p_bar *ui_p_bar)
177 gchar progress_text[1024] =
" ";
179 switch (ui_p_bar->progress_type)
181 case SPLT_PROGRESS_PREPARE:
182 g_snprintf(progress_text,1023, _(
" preparing \"%s\" (%d of %d)"),
183 ui_p_bar->filename_shorted,
184 ui_p_bar->current_split,
185 ui_p_bar->max_splits);
187 case SPLT_PROGRESS_CREATE:
188 g_snprintf(progress_text,1023, _(
" creating \"%s\" (%d of %d)"),
189 ui_p_bar->filename_shorted,
190 ui_p_bar->current_split,
191 ui_p_bar->max_splits);
193 case SPLT_PROGRESS_SEARCH_SYNC:
194 g_snprintf(progress_text,1023, _(
" searching for sync errors..."));
196 case SPLT_PROGRESS_SCAN_SILENCE:
197 if (get_currently_scanning_for_silence_safe(ui))
199 g_snprintf(progress_text,1023, _(
"Computing amplitude wave data..."));
203 g_snprintf(progress_text,1023,
204 _(
"S: %02d, Level: %.2f dB; scanning for silence..."),
205 ui_p_bar->silence_found_tracks, ui_p_bar->silence_db_level);
209 g_snprintf(progress_text,1023,
" ");
213 gchar printed_value[1024] = {
'\0' };
214 g_snprintf(printed_value, 1023,
"%6.2f %% %s", ui_p_bar->percent_progress * 100, progress_text);
216 gtk_progress_bar_set_fraction(ui->gui->percent_progress_bar, ui_p_bar->percent_progress);
217 gtk_progress_bar_set_text(ui->gui->percent_progress_bar, printed_value);
220 while (gtk_events_pending())
222 gtk_main_iteration();
227 if (ui_p_bar->filename_shorted)
229 g_free(ui_p_bar->filename_shorted);
237 static void lmanager_change_window_progress_bar(splt_progress *p_bar,
void *data)
244 ui_p_bar->progress_type = mp3splt_progress_get_type(p_bar);
245 ui_p_bar->filename_shorted = mp3splt_progress_get_filename_shorted(p_bar);
246 ui_p_bar->current_split = mp3splt_progress_get_current_split(p_bar);
247 ui_p_bar->max_splits = mp3splt_progress_get_max_splits(p_bar);
248 ui_p_bar->silence_found_tracks = mp3splt_progress_get_silence_found_tracks(p_bar);
249 ui_p_bar->silence_db_level = mp3splt_progress_get_silence_db_level(p_bar);
250 ui_p_bar->percent_progress = mp3splt_progress_get_percent_progress(p_bar);
252 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
253 (GSourceFunc)lmanager_change_window_progress_bar_idle, ui_p_bar, NULL);
void print_status_bar_confirmation(gint error, ui_state *ui)
Output an error message from libmp3splt to the status bar.
void put_status_message_with_type(const gchar *text, splt_message_type mess_type, ui_state *ui)
Output a message to the status message bar.
void put_status_message(const gchar *text, ui_state *ui)
Output a info message to the status message bar.
void add_split_row(const gchar *name, ui_state *ui)
add a row to the table