# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
header_name {.h} 
code_name {.cxx}
decl {\#include <FL/Fl_File_Chooser.H>} {private local
} 

decl {\#include <FL/Fl.H>} {private local
} 

decl {\#include <FL/x.H>} {private local
} 

decl {\#include <unistd.h>} {private local
} 

decl {\#include <sys/types.h>} {private local
} 

decl {\#include <sys/wait.h>} {private local
} 

Function {} {open
} {
  code {UserInterface *ui = new UserInterface();

Fl_Double_Window *w = ui->make_window();

w->show();

Fl::run();

return 0;} {}
} 

class UserInterface {open
} {
  Function {make_window()} {open
  } {
    Fl_Window main_window {
      label {Import Ardour Session} open
      xywh {610 468 395 310} type Double xclass {Non-Timeline} visible
    } {
      Fl_Box {} {
        label {Non Timeline : Ardour Session Importer}
        xywh {5 6 385 54} box ROUND_UP_BOX color 90 labelfont 1 labelsize 16
      }
      Fl_Box {} {
        label {This program will non-descrutively examine an existing Ardour 1, 2 or 3 format session file and replace the current Non Timeline project with the Tracks and Regions it finds. This program will only operate on a new (empty) Non Timeline project.}
        xywh {5 66 385 128} box ROUND_UP_BOX align 128
      }
      Fl_Return_Button {} {
        label Import
        callback {pid_t pid;
if ( ! (pid = fork()) )
{

	char *s;
//	asprintf( &s, "xterm -into 0x%lx -e import-ardour-session --overwrite '%s' '%s'", fl_xid( main_window ), file_input->value(), getenv("PWD" ));
	asprintf( &s, "import-ardour-session --overwrite '%s' '%s'", file_input->value(), getenv("PWD" ));

	exit( system( s ) );
}


int status;

while ( 0 == waitpid( pid, &status, WNOHANG ) )
{
	Fl::wait(0.01);
	
	if ( progress->value() >= 100 )
		progress->value( 0 );
	else
		progress->value( progress->value() + 5 );

	progress->redraw();
}

if ( 0 == status )
	fl_message( "Import succesful. You've been freed. Go make music!" );
else
	fl_alert( "There was an error importing this session!" );

exit(0);} selected
        xywh {270 270 115 30}
      }
      Fl_File_Input file_input {
        label {Path to .ardour File:}
        xywh {10 226 285 34} align 1
      }
      Fl_Button {} {
        label Browse
        callback {file_input->value( fl_file_chooser( ".ardour file", "*.ardour", NULL, 0 ) );}
        xywh {300 231 85 30}
      }
      Fl_Slider progress {
        label {slider:}
        xywh {15 272 245 27} type Horizontal color 48 selection_color 63 labeltype NO_LABEL align 18 maximum 100 deactivate
      }
    }
  }
} 
