2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999-2003 Alexander König
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 Description: Displays the progress indicator dialog for file
26 #include "tX_loaddlg.h"
30 #include "tX_mastergui.h"
32 GtkWidget *ld_loaddlg=(GtkWidget *) NULL;
33 GtkWidget *ld_single_l=(GtkWidget *)NULL;
34 GtkWidget *ld_single_p=(GtkWidget *)NULL;
35 GtkWidget *ld_multi_l=(GtkWidget *)NULL;
36 GtkWidget *ld_multi_p=(GtkWidget *)NULL;
37 GtkWindow *ld_window=(GtkWindow *)NULL;
45 #define WID_DYN TRUE, TRUE, 0
46 #define WID_FIX FALSE, FALSE, 0
47 #define add_widget_dyn(wid); gtk_box_pack_start(GTK_BOX(vbox), wid, WID_DYN);\
50 #define add_widget_fix(wid); gtk_box_pack_start(GTK_BOX(vbox), wid, WID_FIX);\
53 #define gtk_flush(); { int ctr=0; while (gtk_events_pending()) { ctr++; if (ctr>5) break; gtk_main_iteration(); gdk_flush(); }}
56 int ld_create_loaddlg(int mode, int count)
59 GtkWidget *actionarea;
62 if (ld_loaddlg) return(1);
67 ld_loaddlg=gtk_dialog_new_with_buttons("terminatorX - loading",
68 GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_NONE, NULL);
69 ld_window=&(GTK_DIALOG(ld_loaddlg)->window);
70 gtk_container_set_border_width(GTK_CONTAINER(ld_window), 5);
72 vbox=GTK_WIDGET(GTK_DIALOG(ld_loaddlg)->vbox);
73 gtk_box_set_spacing(GTK_BOX(vbox), 5);
75 actionarea=GTK_WIDGET(GTK_DIALOG(ld_loaddlg)->action_area);
76 gtk_box_set_spacing(GTK_BOX(actionarea), 5);
78 if (mode==TX_LOADDLG_MODE_MULTI)
80 ld_multi_l=gtk_label_new("Loading Set");
81 gtk_misc_set_alignment(GTK_MISC(ld_multi_l), 0.5, 0.5);
82 add_widget_fix(ld_multi_l);
84 ld_multi_p=gtk_progress_bar_new();
85 add_widget_fix(ld_multi_p);
87 dummy=gtk_hseparator_new();
88 add_widget_fix(dummy);
93 ld_single_l=gtk_label_new("Loading File");
94 add_widget_fix(ld_single_l);
96 ld_single_p=gtk_progress_bar_new();
97 add_widget_fix(ld_single_p);
99 gtk_window_set_modal(ld_window, TRUE);
100 gtk_window_set_default_size(ld_window, 400, 100);
101 gtk_widget_realize(ld_loaddlg);
102 gdk_window_set_decorations(gtk_widget_get_parent_window(vbox),(GdkWMDecoration) 0);
103 gtk_widget_show(ld_loaddlg);
110 char *strip_path(char *name)
114 tmp=strrchr(name, (int) '/');
128 void ld_set_setname(char *name)
133 setname=strip_path(name);
134 sprintf(buffer, "Loading tX-set [%s]", setname);
135 gtk_label_set_text(GTK_LABEL(ld_multi_l), buffer);
139 void ld_set_filename(char *name)
147 filename=strip_path(name);
148 if (ld_mode==TX_LOADDLG_MODE_MULTI)
150 sprintf(buffer, "Loading file No. %i of %i [%s]", ld_current, ld_count, filename);
154 sprintf(buffer, "Loading file [%s]", filename);
156 gtk_label_set_text(GTK_LABEL(ld_single_l), buffer);
158 if (ld_mode==TX_LOADDLG_MODE_MULTI)
160 setprog=(((float) ld_current)/((float) ld_count));
161 gtk_progress_bar_update(GTK_PROGRESS_BAR(ld_multi_p), setprog);
167 void ld_set_progress(gfloat progress)
169 progress=floor(progress*200.0)/200.0;
170 if (progress>1.0) progress=1.0;
171 //printf("%f\n", progress);
173 if (progress!=ld_old_prog)
175 gtk_progress_bar_update(GTK_PROGRESS_BAR(ld_single_p), progress);
180 ld_old_prog=progress;
187 gtk_widget_hide(ld_loaddlg);
188 gtk_widget_destroy(ld_loaddlg);