Browse Source

Add creation and modification times to project info dialog.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
5b752d5dc5
5 changed files with 56 additions and 15 deletions
  1. +33
    -4
      Timeline/Project.C
  2. +3
    -2
      Timeline/Project.H
  3. +16
    -6
      Timeline/TLE.fl
  4. +2
    -2
      util/file.C
  5. +2
    -1
      util/file.h

+ 33
- 4
Timeline/Project.C View File

@@ -61,6 +61,7 @@ const char *Project::_errstr[] =
};

char Project::_name[256];
char Project::_created_on[40];
char Project::_path[512];
bool Project::_is_open = false;
int Project::_lockfd = 0;
@@ -101,8 +102,20 @@ Project::write_info ( void )
return false;
}

fprintf( fp, "created by\n\t%s\nversion\n\t%d\nsample rate\n\t%lu\n",
char s[40];

if ( ! *_created_on )
{
time_t t = time( NULL );
ctime_r( &t, s );
s[ strlen( s ) - 1 ] = '\0';
}
else
strcpy( s, _created_on );

fprintf( fp, "created by\n\t%s\ncreated on\n\t%s\nversion\n\t%d\nsample rate\n\t%lu\n",
APP_TITLE " " VERSION,
s,
PROJECT_VERSION,
(unsigned long)timeline->sample_rate() );

@@ -112,7 +125,7 @@ Project::write_info ( void )
}

bool
Project::read_info ( int *version, nframes_t *sample_rate )
Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date )
{
FILE *fp;

@@ -122,6 +135,10 @@ Project::read_info ( int *version, nframes_t *sample_rate )
return false;
}

*version = 0;
*sample_rate = 0;
*creation_date = 0;

char *name, *value;

while ( fscanf( fp, "%a[^\n]\n\t%a[^\n]\n", &name, &value ) == 2 )
@@ -132,6 +149,8 @@ Project::read_info ( int *version, nframes_t *sample_rate )
*sample_rate = atoll( value );
else if ( ! strcmp( name, "version" ) )
*version = atoi( value );
else if ( ! strcmp( name, "created on" ) )
*creation_date = strdup( value );

free( name );
free( value );
@@ -157,11 +176,12 @@ Project::close ( void )

Loggable::close();

write_info();
// write_info();

_is_open = false;

*Project::_name = '\0';
*Project::_created_on = '\0';

release_lock( &_lockfd, ".lock" );

@@ -215,8 +235,9 @@ Project::open ( const char *name )

int version;
nframes_t rate;
char *creation_date;

if ( ! read_info( &version, &rate ) )
if ( ! read_info( &version, &rate, &creation_date ) )
return E_INVALID;

if ( version != PROJECT_VERSION )
@@ -227,6 +248,14 @@ Project::open ( const char *name )

timeline->sample_rate( rate );

if ( creation_date )
{
strcpy( _created_on, creation_date );
free( creation_date );
}
else
*_created_on = 0;

set_name( name );

*_path = '\0';


+ 3
- 2
Timeline/Project.H View File

@@ -29,11 +29,11 @@ class Project
static bool _is_open;
static char _name[256];
static char _path[512];
static char _created_on[40];

static bool write_info ( void );
static bool read_info ( int *version, nframes_t *sample_rate );
static bool read_info ( int *version, nframes_t *sample_rate, char **creation_date );
static void set_name ( const char *name );

static const char *_errstr[];

public:
@@ -57,4 +57,5 @@ public:
static bool open ( void ) { return _is_open; }
static bool create ( const char *name, const char *template_name );

static const char *created_on ( void ) { return _created_on; }
};

+ 16
- 6
Timeline/TLE.fl View File

@@ -837,7 +837,8 @@ Function {new_project_chooser()} {C return_type void
nsd.run();} {}
}

class Project_Info_Dialog {} {
class Project_Info_Dialog {open
} {
Function {Project_Info_Dialog()} {open
} {
code {make_window();} {}
@@ -869,7 +870,7 @@ if ( logo_box->image() )
}
Fl_Output {} {
label {Size of Journal}
xywh {210 80 100 25} box UP_BOX labeltype SHADOW_LABEL align 1
xywh {180 80 100 25} box UP_BOX labeltype SHADOW_LABEL align 1
code0 {static char pat[40];}
code1 {snprintf( pat, sizeof( pat ), "%.1fK", size( "history" ) / (float)1024 );}
code2 {o->value( pat );}
@@ -877,18 +878,19 @@ if ( logo_box->image() )
}
Fl_Output {} {
label {Created On}
xywh {350 80 135 25} box UP_BOX labeltype SHADOW_LABEL align 1
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 Length
xywh {30 130 115 25} align 1
xywh {30 130 115 25} box BORDER_BOX color 47 align 1 textcolor 71
code0 {char pat[40];}
code1 {Clock::frame_to_HMS( pat, sizeof( pat ), timeline->length() );}
code2 {o->value( pat );}
}
Fl_Value_Output {} {
label Tracks
xywh {230 130 60 25} align 1
xywh {200 130 55 25} align 1
code0 {o->value( timeline->ntracks() );}
}
Fl_Box logo_box {
@@ -923,6 +925,14 @@ window->do_callback();}
callback {window->do_callback();}
xywh {330 700 74 25}
}
Fl_Output {} {
label {Last Modified On} selected
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 );}
}
}
}
}
@@ -952,7 +962,7 @@ if ( logo_box->image() )
((Fl_Shared_Image*)logo_box->image())->release();
logo_box->image( NULL );
}} open
private xywh {669 197 495 655} type Double xclass {Non-DAW} visible
private xywh {349 201 495 655} type Double xclass {Non-DAW} visible
} {
Fl_Tabs {} {open
xywh {0 264 497 392}


+ 2
- 2
util/file.C View File

@@ -26,7 +26,7 @@
#include <stdlib.h>

unsigned long
mtime ( const char *file )
modification_time ( const char *file )
{
struct stat st;

@@ -40,7 +40,7 @@ mtime ( const char *file )
bool
newer ( const char *file1, const char *file2 )
{
return mtime( file1 ) > mtime( file2 );
return modification_time( file1 ) > modification_time( file2 );
}

unsigned long


+ 2
- 1
util/file.h View File

@@ -19,7 +19,8 @@

#include <stdio.h>

unsigned long mtime ( const char *file );
unsigned long modification_time ( const char *file );

bool newer ( const char *file1, const char *file2 );
unsigned long size ( const char *file );
int exists ( const char *name );


Loading…
Cancel
Save