non/FL/New_Project_Dialog.fl

133 lines
3.3 KiB
Plaintext

# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.H}
code_name {.C}
comment {//
// Copyright (C) 2008 Jonathan Moore Liles
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
} {in_source in_header
}
decl {\#include <stdlib.h>} {private local
}
decl {\#include <string.h>} {private local
}
decl {\#include <stdio.h>} {private local
}
decl {\#include <FL/Fl_File_Chooser.H>} {private local
}
class New_Project_Dialog {open
} {
Function {New_Project_Dialog()} {open
} {
code {_default_path = 0;
path = 0;
make_window();} {}
}
Function {run()} {open return_type void
} {
code {_directory->value( _default_path );
_window->show();
while ( _window->shown() )
Fl::wait();} {}
}
Function {make_window()} {open
} {
Fl_Window _window {
label {New Project} open selected
xywh {743 696 550 105} type Double modal visible
} {
Fl_File_Input _name {
label {Named:}
xywh {75 55 375 35}
}
Fl_Button {} {
label Browse
callback {_directory->value( fl_dir_chooser( "Directory for new project", NULL, 0 ) );}
xywh {455 15 80 35}
}
Fl_Return_Button {} {
label Create
callback {if ( strlen( _directory->value() ) && strlen( _name->value() ) )
{
char pat[1024];
snprintf( pat, sizeof( pat ), "%s/%s", _directory->value(), _name->value() );
path = strdup( pat );
_default_path = _directory->value() ? strdup( _directory->value() ) : 0;
//if ( ! Project::create( pat, _template->text( _template->value() ) ) )
// fl_alert( "Error creating project!" );
_window->hide();
}}
xywh {455 55 80 35}
}
Fl_File_Input _directory {
label {Where:}
callback {if ( ! fl_filename_isdir( o->value() ) )
{
fl_alert( "Must be a directory" );
o->value( "" );
return;
}
// write_line( user_config_dir, "default_path", o->value() );}
xywh {75 15 375 35}
code0 {\#include <FL/filename.H>}
code1 {char *v = NULL;}
code2 {// read_line( user_config_dir, "default_path", &v );}
code3 {o->value( v );}
}
}
}
decl {char *path;} {public local
}
decl {char *_default_path} {private local
}
Function {default_path( char *s )} {open return_type void
} {
code {_default_path = s;} {}
}
Function {default_path()} {open return_type {char *}
} {
code {return _default_path;} {}
}
}
Function {new_project_chooser( char **default_path)} {open C return_type {char*}
} {
code {New_Project_Dialog nsd;
nsd.default_path( *default_path );
nsd.run();
if ( nsd.default_path() )
*default_path = nsd.default_path();
return nsd.path;} {}
}