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)
51 if (error_from_library == NULL) {
return; }
52 ui_fail(ui, error_from_library);
56 void lmanager_stop_split(
ui_state *ui)
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)
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)
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);
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);
194 g_snprintf(progress_text,1023, _(
" searching for sync errors..."));
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)
252 gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE,
253 (GSourceFunc)lmanager_change_window_progress_bar_idle, ui_p_bar, NULL);