@@ -0,0 +1,113 @@ | |||||
/*******************************************************************************/ | |||||
/* 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; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
/* Routings for opening/closing/creation of sessions. All the actual | |||||
session state belongs to Timeline and other classes. */ | |||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <sys/stat.h> | |||||
#include "Loggable.H" | |||||
#include "Session.H" | |||||
#include "debug.h" | |||||
char Session::_name[256]; | |||||
void | |||||
Session::set_name ( const char *name ) | |||||
{ | |||||
char *s = rindex( name, '/' ); | |||||
strcpy( Session::_name, s ? s : name ); | |||||
for ( s = Session::_name; *s; ++s ) | |||||
if ( *s == '_' || *s == '-' ) | |||||
*s = ' '; | |||||
} | |||||
static int | |||||
exists ( const char *name ) | |||||
{ | |||||
struct stat st; | |||||
return 0 == stat( name, &st ); | |||||
} | |||||
#include <errno.h> | |||||
bool | |||||
Session::close ( void ) | |||||
{ | |||||
Loggable::close(); | |||||
} | |||||
bool | |||||
Session::open ( const char *name ) | |||||
{ | |||||
if ( chdir( name ) ) | |||||
{ | |||||
WARNING( "Cannot change to session dir \"%s\"", name ); | |||||
return false; | |||||
} | |||||
if ( ! exists( "history" ) || | |||||
! exists( "sources" ) ) | |||||
// ! exists( "options" ) ) | |||||
{ | |||||
WARNING( "Not a Non-DAW session: \"%s\"", name ); | |||||
return false; | |||||
} | |||||
if ( ! Loggable::open( "history" ) ) | |||||
FATAL( "error opening journal" ); | |||||
set_name( name ); | |||||
} | |||||
bool | |||||
Session::create ( const char *name, const char *template_name ) | |||||
{ | |||||
if ( exists( name ) ) | |||||
{ | |||||
WARNING( "Session already exists" ); | |||||
return false; | |||||
} | |||||
if ( mkdir( name, 0777 ) ) | |||||
{ | |||||
WARNING( "Cannot create session directory" ); | |||||
return false; | |||||
} | |||||
if ( chdir( name ) ) | |||||
FATAL( "WTF? Cannot change to new session directory" ); | |||||
mkdir( "sources", 0777 ); | |||||
set_name( name ); | |||||
/* TODO: copy template */ | |||||
close(); | |||||
return open( name ); | |||||
} |
@@ -0,0 +1,34 @@ | |||||
/*******************************************************************************/ | |||||
/* 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; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
class Session | |||||
{ | |||||
static char _name[256]; | |||||
public: | |||||
static const char *name ( void ) { return Session::_name; } | |||||
static void set_name ( const char *name ); | |||||
static bool close ( void ); | |||||
static bool open ( const char *name ); | |||||
static bool create ( const char *name, const char *template_name ); | |||||
}; |
@@ -14,6 +14,8 @@ decl {\#include "Transport.H"} {} | |||||
decl {\#include "Loggable.H"} {} | decl {\#include "Loggable.H"} {} | ||||
decl {\#include "Session.H"} {} | |||||
decl {\#include "Clock.H"} {public | decl {\#include "Clock.H"} {public | ||||
} | } | ||||
@@ -117,7 +119,7 @@ free( path );} {} | |||||
} { | } { | ||||
Fl_Window main_window { | Fl_Window main_window { | ||||
label {Non-DAW - Timeline} open | label {Non-DAW - Timeline} open | ||||
xywh {129 104 1020 765} type Double resizable xclass {Non-DAW} visible | |||||
xywh {174 178 1020 765} type Double resizable xclass {Non-DAW} visible | |||||
} { | } { | ||||
Fl_Menu_Bar menubar {open | Fl_Menu_Bar menubar {open | ||||
xywh {0 0 1024 25} | xywh {0 0 1024 25} | ||||
@@ -546,9 +548,9 @@ delete win;} | |||||
class Timeline | class Timeline | ||||
} | } | ||||
Fl_Box {} { | Fl_Box {} { | ||||
label {<session name>} | |||||
label {<session name>} selected | |||||
xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2 | xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2 | ||||
code0 {o->label( session_display_name );} | |||||
code0 {o->label( Session::name() );} | |||||
} | } | ||||
Fl_Value_Output xruns_output { | Fl_Value_Output xruns_output { | ||||
label {xruns:} | label {xruns:} | ||||
@@ -593,7 +595,7 @@ xruns_output->value( engine->xruns() );} {} | |||||
} { | } { | ||||
Fl_Window {} { | Fl_Window {} { | ||||
label About open | label About open | ||||
xywh {1082 94 495 525} type Double visible | |||||
xywh {677 145 495 525} type Double visible | |||||
} { | } { | ||||
Fl_Tabs {} {open | Fl_Tabs {} {open | ||||
xywh {-4 122 507 419} | xywh {-4 122 507 419} | ||||
@@ -691,7 +693,7 @@ o->hide();} open | |||||
private xywh {75 110 375 25} labeltype EMBOSSED_LABEL | private xywh {75 110 375 25} labeltype EMBOSSED_LABEL | ||||
} | } | ||||
Fl_Box {} { | Fl_Box {} { | ||||
label {New Session} selected | |||||
label {New Session} | |||||
xywh {15 8 520 33} box RSHADOW_BOX color 133 labelsize 20 labelcolor 32 | xywh {15 8 520 33} box RSHADOW_BOX color 133 labelsize 20 labelcolor 32 | ||||
} | } | ||||
Fl_Choice _template { | Fl_Choice _template { | ||||
@@ -49,6 +49,7 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include "Session.H" | |||||
Engine *engine; | Engine *engine; | ||||
Timeline *timeline; | Timeline *timeline; | ||||
@@ -69,27 +70,6 @@ const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles"; | |||||
#include "debug.h" | #include "debug.h" | ||||
char *user_config_dir; | char *user_config_dir; | ||||
char session_display_name[256]; | |||||
void | |||||
set_display_name ( const char *name ) | |||||
{ | |||||
char *s = rindex( name, '/' ); | |||||
strcpy( session_display_name, s ? s : name ); | |||||
for ( s = session_display_name; *s; ++s ) | |||||
if ( *s == '_' || *s == '-' ) | |||||
*s = ' '; | |||||
} | |||||
static int | |||||
exists ( const char *name ) | |||||
{ | |||||
struct stat st; | |||||
return 0 == stat( name, &st ); | |||||
} | |||||
#include <errno.h> | #include <errno.h> | ||||
@@ -103,40 +83,10 @@ ensure_dirs ( void ) | |||||
return r == 0 || errno == EEXIST; | return r == 0 || errno == EEXIST; | ||||
} | } | ||||
bool | |||||
create_session ( const char *name ) | |||||
{ | |||||
if ( exists( name ) ) | |||||
{ | |||||
WARNING( "Session already exists" ); | |||||
return false; | |||||
} | |||||
if ( mkdir( name, 0777 ) ) | |||||
{ | |||||
WARNING( "Cannot create session directory" ); | |||||
return false; | |||||
} | |||||
if ( chdir( name ) ) | |||||
FATAL( "WTF? Cannot change to new session directory" ); | |||||
mkdir( "sources", 0777 ); | |||||
set_display_name( name ); | |||||
/* TODO: load template */ | |||||
return true; | |||||
} | |||||
int | int | ||||
main ( int argc, char **argv ) | main ( int argc, char **argv ) | ||||
{ | { | ||||
*session_display_name = '\0'; | |||||
/* welcome to C++ */ | /* welcome to C++ */ | ||||
LOG_REGISTER_CREATE( Region ); | LOG_REGISTER_CREATE( Region ); | ||||
LOG_REGISTER_CREATE( Time_Point ); | LOG_REGISTER_CREATE( Time_Point ); | ||||
@@ -154,25 +104,11 @@ main ( int argc, char **argv ) | |||||
printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT ); | printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT ); | ||||
const char *pwd = getenv( "PWD" ); | |||||
if ( argc > 1 ) | if ( argc > 1 ) | ||||
{ | |||||
/* FIXME: what about FLTK arguments? */ | |||||
if ( ! Session::open( argv[ 1 ] ) ) | |||||
FATAL( "Could not open session specified on command line" ); | |||||
/* change to session dir */ | |||||
if ( chdir( argv[ 1 ] ) ) | |||||
FATAL( "Cannot change to session dir \"%s\"", argv[ 1 ] ); | |||||
else | |||||
pwd = argv[ 1 ]; | |||||
} | |||||
if ( ! exists( "history" ) || | |||||
! exists( "sources" ) ) | |||||
// ! exists( "options" ) ) | |||||
FATAL( "Not a Non-DAW session: \"%s\"", pwd ); | |||||
set_display_name( pwd ); | |||||
/* FIXME: open session in /tmp if none is given? */ | |||||
TLE tle; | TLE tle; | ||||
@@ -186,9 +122,6 @@ main ( int argc, char **argv ) | |||||
* scenario requiring otherwise */ | * scenario requiring otherwise */ | ||||
transport->stop(); | transport->stop(); | ||||
MESSAGE( "Opening session" ); | |||||
Loggable::open( "history" ); | |||||
MESSAGE( "Starting GUI" ); | MESSAGE( "Starting GUI" ); | ||||
// tle.main_window->show( argc, argv ); | // tle.main_window->show( argc, argv ); | ||||
tle.main_window->show(); | tle.main_window->show(); | ||||
@@ -28,6 +28,7 @@ Timeline/Transport.C \ | |||||
Timeline/Waveform.C \ | Timeline/Waveform.C \ | ||||
Timeline/dsp.C \ | Timeline/dsp.C \ | ||||
Timeline/main.C \ | Timeline/main.C \ | ||||
Timeline/Session.C \ | |||||
debug.C \ | debug.C \ | ||||
Timeline_OBJS:=$(Timeline_SRCS:.C=.o) | Timeline_OBJS:=$(Timeline_SRCS:.C=.o) | ||||