FL/New_Project_Dialog: Don't crash if aborted.
This commit is contained in:
parent
d4c15e6fa7
commit
89f2633463
|
@ -54,17 +54,17 @@ while ( _window->shown() )
|
||||||
Function {make_window()} {open
|
Function {make_window()} {open
|
||||||
} {
|
} {
|
||||||
Fl_Window _window {
|
Fl_Window _window {
|
||||||
label {New Project} open
|
label {New Project} open selected
|
||||||
xywh {762 252 550 195} type Double hide modal
|
xywh {743 696 550 105} type Double modal visible
|
||||||
} {
|
} {
|
||||||
Fl_File_Input _name {
|
Fl_File_Input _name {
|
||||||
label {Named:}
|
label {Named:}
|
||||||
xywh {75 140 375 35}
|
xywh {75 55 375 35}
|
||||||
}
|
}
|
||||||
Fl_Button {} {
|
Fl_Button {} {
|
||||||
label Browse
|
label Browse
|
||||||
callback {_directory->value( fl_dir_chooser( "Directory for new project", NULL, 0 ) );}
|
callback {_directory->value( fl_dir_chooser( "Directory for new project", NULL, 0 ) );}
|
||||||
xywh {455 100 80 35}
|
xywh {455 15 80 35}
|
||||||
}
|
}
|
||||||
Fl_Return_Button {} {
|
Fl_Return_Button {} {
|
||||||
label Create
|
label Create
|
||||||
|
@ -83,7 +83,7 @@ while ( _window->shown() )
|
||||||
|
|
||||||
_window->hide();
|
_window->hide();
|
||||||
}}
|
}}
|
||||||
xywh {455 140 80 35}
|
xywh {455 55 80 35}
|
||||||
}
|
}
|
||||||
Fl_File_Input _directory {
|
Fl_File_Input _directory {
|
||||||
label {Where:}
|
label {Where:}
|
||||||
|
@ -95,36 +95,18 @@ while ( _window->shown() )
|
||||||
}
|
}
|
||||||
|
|
||||||
// write_line( user_config_dir, "default_path", o->value() );}
|
// write_line( user_config_dir, "default_path", o->value() );}
|
||||||
xywh {75 100 375 35}
|
xywh {75 15 375 35}
|
||||||
code0 {\#include <FL/filename.H>}
|
code0 {\#include <FL/filename.H>}
|
||||||
code1 {char *v = NULL;}
|
code1 {char *v = NULL;}
|
||||||
code2 {// read_line( user_config_dir, "default_path", &v );}
|
code2 {// read_line( user_config_dir, "default_path", &v );}
|
||||||
code3 {o->value( v );}
|
code3 {o->value( v );}
|
||||||
}
|
}
|
||||||
Fl_Box {} {
|
|
||||||
label {New Project}
|
|
||||||
xywh {15 8 520 33} box RSHADOW_BOX color 133 labelsize 20 labelcolor 32
|
|
||||||
}
|
|
||||||
Fl_Choice _template {
|
|
||||||
label {Template:} open
|
|
||||||
private xywh {310 60 225 25} down_box BORDER_BOX
|
|
||||||
} {
|
|
||||||
MenuItem {} {
|
|
||||||
label Default selected
|
|
||||||
xywh {0 0 40 25}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decl {char *path;} {public local
|
decl {char *path;} {public local
|
||||||
}
|
}
|
||||||
decl {char *_default_path} {private local
|
decl {char *_default_path} {private local
|
||||||
}
|
}
|
||||||
Function {templates( const char **templates )} {open return_type void
|
|
||||||
} {
|
|
||||||
code {for ( const char **s = templates; *s; ++s )
|
|
||||||
_template->add( *s );} {}
|
|
||||||
}
|
|
||||||
Function {default_path( char *s )} {open return_type void
|
Function {default_path( char *s )} {open return_type void
|
||||||
} {
|
} {
|
||||||
code {_default_path = s;} {}
|
code {_default_path = s;} {}
|
||||||
|
@ -133,23 +115,18 @@ while ( _window->shown() )
|
||||||
} {
|
} {
|
||||||
code {return _default_path;} {}
|
code {return _default_path;} {}
|
||||||
}
|
}
|
||||||
Function {selected_template()} {open return_type {const char *}
|
|
||||||
} {
|
|
||||||
code {return _template->text( _template->value() );} {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Function {new_project_chooser( const char **templates, char **default_path, char **selected_template )} {open C return_type {char*}
|
Function {new_project_chooser( char **default_path)} {open C return_type {char*}
|
||||||
} {
|
} {
|
||||||
code {New_Project_Dialog nsd;
|
code {New_Project_Dialog nsd;
|
||||||
|
|
||||||
nsd.templates( templates );
|
|
||||||
nsd.default_path( *default_path );
|
nsd.default_path( *default_path );
|
||||||
|
|
||||||
nsd.run();
|
nsd.run();
|
||||||
|
|
||||||
*default_path = strdup( nsd.default_path() );
|
if ( nsd.default_path() )
|
||||||
*selected_template = strdup( nsd.selected_template() );
|
*default_path = strdup( nsd.default_path() );
|
||||||
|
|
||||||
return nsd.path;} {}
|
return nsd.path;} {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,21 +186,18 @@ void Mixer::cb_menu(Fl_Widget* o) {
|
||||||
if (! strcmp( picked, "&Project/&New") )
|
if (! strcmp( picked, "&Project/&New") )
|
||||||
{
|
{
|
||||||
DMESSAGE( "New project" );
|
DMESSAGE( "New project" );
|
||||||
const char *templates[] = { "Default", NULL };
|
|
||||||
|
|
||||||
char *default_path;
|
char *default_path;
|
||||||
char *selected_template;
|
|
||||||
|
|
||||||
read_line( user_config_dir, "default_path", &default_path );
|
read_line( user_config_dir, "default_path", &default_path );
|
||||||
|
|
||||||
char *path = new_project_chooser( templates, &default_path, &selected_template );
|
char *path = new_project_chooser( &default_path );
|
||||||
|
|
||||||
if ( path )
|
if ( path )
|
||||||
{
|
{
|
||||||
if ( ! Project::create( path, selected_template ) )
|
if ( ! Project::create( path, NULL ) )
|
||||||
fl_alert( "Error creating project!" );
|
fl_alert( "Error creating project!" );
|
||||||
free( path );
|
free( path );
|
||||||
free( selected_template );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_menu();
|
update_menu();
|
||||||
|
|
|
@ -261,7 +261,7 @@ Loggable::progress_callback( &TLE::progress_cb, this );} {}
|
||||||
label {Non Timeline}
|
label {Non Timeline}
|
||||||
callback {if ( Fl::event_key() != FL_Escape )
|
callback {if ( Fl::event_key() != FL_Escape )
|
||||||
timeline->command_quit();} open
|
timeline->command_quit();} open
|
||||||
xywh {202 266 1025 770} type Double resizable
|
xywh {204 266 1025 770} type Double resizable
|
||||||
code0 {o->xclass( APP_NAME );}
|
code0 {o->xclass( APP_NAME );}
|
||||||
class TLE_Window size_range {900 300 0 0} visible
|
class TLE_Window size_range {900 300 0 0} visible
|
||||||
} {
|
} {
|
||||||
|
@ -330,21 +330,18 @@ pi.run();}
|
||||||
label {&New}
|
label {&New}
|
||||||
callback {save_timeline_settings();
|
callback {save_timeline_settings();
|
||||||
|
|
||||||
const char *templates[] = { "Default", NULL };
|
|
||||||
|
|
||||||
char *default_path;
|
char *default_path;
|
||||||
char *selected_template;
|
|
||||||
|
|
||||||
read_line( user_config_dir, "default_path", &default_path );
|
read_line( user_config_dir, "default_path", &default_path );
|
||||||
|
|
||||||
char *path = new_project_chooser( templates, &default_path, &selected_template );
|
char *path = new_project_chooser( &default_path );
|
||||||
|
|
||||||
if ( path )
|
if ( path )
|
||||||
{
|
{
|
||||||
if ( ! Project::create( path, selected_template ) )
|
if ( ! Project::create( path, NULL ) )
|
||||||
fl_alert( "Error creating project!" );
|
fl_alert( "Error creating project!" );
|
||||||
free( path );
|
free( path );
|
||||||
free( selected_template );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( default_path )
|
if ( default_path )
|
||||||
|
@ -422,7 +419,7 @@ while ( 0 == waitpid( pid, &status, WNOHANG ) )
|
||||||
|
|
||||||
Project::open(path);
|
Project::open(path);
|
||||||
|
|
||||||
free(path);} selected
|
free(path);}
|
||||||
xywh {20 20 40 25}
|
xywh {20 20 40 25}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1055,47 +1052,59 @@ if ( logo_box->image() )
|
||||||
((Fl_Shared_Image*)logo_box->image())->release();
|
((Fl_Shared_Image*)logo_box->image())->release();
|
||||||
logo_box->image( NULL );
|
logo_box->image( NULL );
|
||||||
}} open
|
}} open
|
||||||
private xywh {1193 174 520 775} type Double hide modal
|
private xywh {1195 197 520 710} type Double modal visible
|
||||||
} {
|
} {
|
||||||
Fl_Value_Output {} {
|
Fl_Group {} {open
|
||||||
label {Sample Rate}
|
xywh {25 30 470 75}
|
||||||
xywh {40 80 90 25} labeltype SHADOW_LABEL align 1
|
} {
|
||||||
code0 {o->value( timeline->sample_rate() );}
|
Fl_Value_Output {} {
|
||||||
}
|
label {Sample Rate}
|
||||||
Fl_Output {} {
|
xywh {35 30 90 25} labeltype SHADOW_LABEL align 1
|
||||||
label {Size of Journal}
|
code0 {o->value( timeline->sample_rate() );}
|
||||||
xywh {180 80 100 25} box UP_BOX labeltype SHADOW_LABEL align 1
|
}
|
||||||
code0 {static char pat[40];}
|
Fl_Output {} {
|
||||||
code1 {snprintf( pat, sizeof( pat ), "%.1fK", size( "history" ) / (float)1024 );}
|
label {Size of Journal}
|
||||||
code2 {o->value( pat );}
|
xywh {175 30 100 25} box UP_BOX labeltype SHADOW_LABEL align 1
|
||||||
code3 {\#include "file.h"}
|
code0 {static char pat[40];}
|
||||||
}
|
code1 {snprintf( pat, sizeof( pat ), "%.1fK", size( "history" ) / (float)1024 );}
|
||||||
Fl_Output {} {
|
code2 {o->value( pat );}
|
||||||
label {Created On}
|
code3 {\#include "file.h"}
|
||||||
xywh {320 80 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
|
}
|
||||||
code0 {o->value( Project::created_on() );}
|
Fl_Output {} {
|
||||||
}
|
label {Created On}
|
||||||
Fl_Output {} {
|
xywh {315 30 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
|
||||||
label Length
|
code0 {o->value( Project::created_on() );}
|
||||||
xywh {30 130 115 25} box BORDER_BOX color 47 align 1 textcolor 71
|
}
|
||||||
code0 {char pat[40];}
|
Fl_Output {} {
|
||||||
code1 {Clock::frame_to_HMS( pat, sizeof( pat ), timeline->length() );}
|
label Length
|
||||||
code2 {o->value( pat );}
|
xywh {25 80 115 25} box BORDER_BOX color 47 align 1 textcolor 71
|
||||||
}
|
code0 {char pat[40];}
|
||||||
Fl_Value_Output {} {
|
code1 {Clock::frame_to_HMS( pat, sizeof( pat ), timeline->length() );}
|
||||||
label Tracks
|
code2 {o->value( pat );}
|
||||||
xywh {200 130 55 25} align 1
|
}
|
||||||
code0 {o->value( timeline->ntracks() );}
|
Fl_Value_Output {} {
|
||||||
|
label Tracks
|
||||||
|
xywh {195 80 55 25} align 1
|
||||||
|
code0 {o->value( timeline->ntracks() );}
|
||||||
|
}
|
||||||
|
Fl_Output {} {
|
||||||
|
label {Last Modified On}
|
||||||
|
xywh {315 80 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
|
||||||
|
code0 {time_t t = modification_time( "history" );}
|
||||||
|
code1 {static char s[40];}
|
||||||
|
code2 {ctime_r( &t, s ); s[ strlen( s ) - 1 ] = 0;}
|
||||||
|
code3 {o->value( s );}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Fl_Box logo_box {
|
Fl_Box logo_box {
|
||||||
label {<LOGO>}
|
label {<LOGO>}
|
||||||
private xywh {20 173 485 268} color 53 labelfont 1 labelsize 18 align 16
|
private xywh {18 117 485 268} color 53 labelfont 1 labelsize 18 align 16
|
||||||
code0 {o->image( Fl_Shared_Image::get( PIXMAP_PATH "/non-timeline/icon-256x256.png" ) );}
|
code0 {o->image( Fl_Shared_Image::get( PIXMAP_PATH "/non-timeline/icon-256x256.png" ) );}
|
||||||
code1 {o->label( NULL );}
|
code1 {o->label( NULL );}
|
||||||
}
|
}
|
||||||
Fl_Text_Editor notes_field {
|
Fl_Text_Editor notes_field {
|
||||||
label {Notes:}
|
label {Notes:} selected
|
||||||
private xywh {20 475 480 245} color 47 selection_color 31 textsize 18 textcolor 92
|
private xywh {20 420 480 245} color 47 selection_color 31 textsize 18 textcolor 92
|
||||||
code0 {o->buffer( new Fl_Text_Buffer() );}
|
code0 {o->buffer( new Fl_Text_Buffer() );}
|
||||||
code1 {o->buffer()->loadfile( "notes" );}
|
code1 {o->buffer()->loadfile( "notes" );}
|
||||||
}
|
}
|
||||||
|
@ -1104,28 +1113,12 @@ if ( logo_box->image() )
|
||||||
callback {notes_field->buffer()->savefile( "notes" );
|
callback {notes_field->buffer()->savefile( "notes" );
|
||||||
|
|
||||||
window->do_callback();}
|
window->do_callback();}
|
||||||
xywh {420 735 74 25}
|
xywh {422 676 74 25}
|
||||||
}
|
|
||||||
Fl_Box {} {
|
|
||||||
label {Project Info}
|
|
||||||
xywh {40 18 405 27} box RSHADOW_BOX color 95 labeltype SHADOW_LABEL labelsize 18
|
|
||||||
}
|
|
||||||
Fl_Box {} {
|
|
||||||
label {Project Info}
|
|
||||||
xywh {25 18 470 33} box RSHADOW_BOX color 0 labelsize 20 labelcolor 32
|
|
||||||
}
|
}
|
||||||
Fl_Button {} {
|
Fl_Button {} {
|
||||||
label {&Discard}
|
label {&Discard}
|
||||||
callback {window->do_callback();}
|
callback {window->do_callback();}
|
||||||
xywh {330 735 74 25}
|
xywh {332 676 74 25}
|
||||||
}
|
|
||||||
Fl_Output {} {
|
|
||||||
label {Last Modified On}
|
|
||||||
xywh {320 130 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
|
|
||||||
code0 {time_t t = modification_time( "history" );}
|
|
||||||
code1 {static char s[40];}
|
|
||||||
code2 {ctime_r( &t, s ); s[ strlen( s ) - 1 ] = 0;}
|
|
||||||
code3 {o->value( s );}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue