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)
44 mp3splt_set_int_option(ui->mp3splt_state,
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)
59 mp3splt_stop_split(ui->mp3splt_state, &err);
63 static gboolean lmanager_put_split_filename_idle(
ui_with_fname *ui_fname)
65 char *filename = ui_fname->fname;
70 gint fname_status_size = (strlen(filename) + 255);
71 gchar *fname_status = g_malloc(
sizeof(
char) * fname_status_size);
72 g_snprintf(fname_status, fname_status_size, _(
" File '%s' created"), filename);
82 gtk_widget_set_sensitive(ui->gui->queue_files_button, TRUE);
83 gtk_widget_set_sensitive(ui->gui->remove_all_files_button, TRUE);
86 while (gtk_events_pending())
103 void lmanager_put_split_filename(
const char *filename,
int progress_data,
void *data)
109 ui_fname->fname = NULL;
112 ui_fname->fname = strdup(filename);
115 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
116 (GSourceFunc)lmanager_put_split_filename_idle, ui_fname, NULL);
119 static gboolean lmanager_put_message_from_library_idle(
ui_with_message *ui_message)
124 char *mess = ui_message->message;
129 for (i = 0;i < strlen(mess);i++)
140 while (gtk_events_pending())
142 gtk_main_iteration();
157 static void lmanager_put_message_from_library(
const char *message,
splt_message_type mess_type,
void *data)
163 ui_message->message = NULL;
166 ui_message->message = strdup(message);
168 ui_message->mess_type = mess_type;
170 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
171 (GSourceFunc)lmanager_put_message_from_library_idle, ui_message, NULL);
174 static gboolean lmanager_change_window_progress_bar_idle(
ui_with_p_bar *ui_p_bar)
178 gchar progress_text[1024] =
" ";
180 switch (ui_p_bar->progress_type)
183 g_snprintf(progress_text,1023, _(
" preparing \"%s\" (%d of %d)"),
184 ui_p_bar->filename_shorted,
185 ui_p_bar->current_split,
186 ui_p_bar->max_splits);
189 g_snprintf(progress_text,1023, _(
" creating \"%s\" (%d of %d)"),
190 ui_p_bar->filename_shorted,
191 ui_p_bar->current_split,
192 ui_p_bar->max_splits);
195 g_snprintf(progress_text,1023, _(
" searching for sync errors..."));
198 if (get_currently_scanning_for_silence_safe(ui))
200 g_snprintf(progress_text,1023, _(
"Computing amplitude wave data..."));
204 g_snprintf(progress_text,1023,
205 _(
"S: %02d, Level: %.2f dB; scanning for silence..."),
206 ui_p_bar->silence_found_tracks, ui_p_bar->silence_db_level);
210 g_snprintf(progress_text,1023,
" ");
214 gchar printed_value[1024] = {
'\0' };
215 g_snprintf(printed_value, 1023,
"%6.2f %% %s", ui_p_bar->percent_progress * 100, progress_text);
217 gtk_progress_bar_set_fraction(ui->gui->percent_progress_bar, ui_p_bar->percent_progress);
218 gtk_progress_bar_set_text(ui->gui->percent_progress_bar, printed_value);
221 while (gtk_events_pending())
223 gtk_main_iteration();
228 if (ui_p_bar->filename_shorted)
230 g_free(ui_p_bar->filename_shorted);
238 static void lmanager_change_window_progress_bar(
splt_progress *p_bar,
void *data)
246 ui_p_bar->filename_shorted = NULL;
257 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
258 (GSourceFunc)lmanager_change_window_progress_bar_idle, ui_p_bar, NULL);