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)
58 GtkWidget *vbox=gtk_vbox_new(0, 5);
59 GtkWidget *actionarea;
62 if (ld_loaddlg) return(1);
67 ld_loaddlg=gtk_window_new(GTK_WINDOW_POPUP);
68 gtk_window_set_position(GTK_WINDOW(ld_loaddlg), GTK_WIN_POS_CENTER_ON_PARENT);
69 gtk_window_set_title(GTK_WINDOW(ld_loaddlg), "terminatorX - loading");
70 gtk_window_set_transient_for(GTK_WINDOW(ld_loaddlg), GTK_WINDOW(main_window));
72 gtk_container_set_border_width(GTK_CONTAINER(ld_loaddlg), 5);
73 gtk_container_add(GTK_CONTAINER(ld_loaddlg), vbox);
74 gtk_widget_set_size_request(vbox, 400, -1);
75 gtk_widget_show(vbox);
77 //gtk_widget_show(ld_loaddlg);
79 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(GTK_WINDOW(ld_loaddlg), TRUE);
100 //gtk_window_set_default_size(GTK_WINDOW(ld_loaddlg), 400, 100);
101 gtk_widget_realize(ld_loaddlg);
102 gdk_window_set_decorations(ld_loaddlg->window, (GdkWMDecoration) 0);
103 gtk_widget_show(ld_loaddlg);
104 gdk_window_set_cursor(ld_loaddlg->window, tX_cursor::get_cursor());
111 char *strip_path(char *name)
115 if (!name) return NULL;
117 tmp=strrchr(name, (int) '/');
129 void ld_set_setname(char *name)
134 setname=strip_path(name);
135 sprintf(buffer, "Loading tX-set [%s]", setname);
136 gtk_label_set_text(GTK_LABEL(ld_multi_l), buffer);
140 void ld_set_filename(char *name)
148 filename=strip_path(name);
149 if (ld_mode==TX_LOADDLG_MODE_MULTI) {
150 sprintf(buffer, "Loading file No. %i of %i [%s]", ld_current, ld_count, filename);
152 sprintf(buffer, "Loading file [%s]", filename);
154 gtk_label_set_text(GTK_LABEL(ld_single_l), buffer);
156 if (ld_mode==TX_LOADDLG_MODE_MULTI) {
157 setprog=(((float) ld_current)/((float) ld_count));
158 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ld_multi_p), setprog);
164 void ld_set_progress(gfloat progress)
166 progress=floor(progress*200.0)/200.0;
167 if (progress>1.0) progress=1.0;
169 if (progress!=ld_old_prog) {
170 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ld_single_p), progress);
174 ld_old_prog=progress;
180 gtk_widget_hide(ld_loaddlg);
181 gtk_widget_destroy(ld_loaddlg);