Show disk usage in TLE.

This commit is contained in:
Jonathan Moore Liles 2008-07-30 01:48:22 -05:00
parent 1f4c3b4f9a
commit 840d08aed9
3 changed files with 54 additions and 7 deletions

View File

@ -199,7 +199,7 @@ Loggable::progress_callback( &TLE::progress_cb, this );} {}
Fl_Window main_window {
label Timeline
callback {if ( Fl::event_key() != FL_Escape )
o->hide();} open selected
o->hide();} open
private xywh {133 113 1025 770} type Double resizable xclass Non_DAW visible
} {
Fl_Menu_Bar menubar {open
@ -606,12 +606,12 @@ ab.run();}
}
}
Fl_Box {} {
label {<empty>}
xywh {487 27 308 42} resizable
label {<empty>} selected
xywh {487 27 258 42} resizable
code0 {o->labeltype( FL_NO_LABEL );}
}
Fl_Group {} {open
xywh {865 26 160 44}
xywh {745 26 280 44}
} {
Fl_Box {} {
label {capture:}
@ -637,16 +637,24 @@ ab.run();}
label {50%}
private xywh {921 41 104 14} labelsize 10
}
Fl_Box {} {
label {disk:}
xywh {810 27 55 18} labelsize 10 align 16
}
Fl_Progress disk_usage_progress {
label {50%}
private xywh {810 43 55 26} labelsize 10
}
}
Fl_Button solo_blinker {
label SOLO
xywh {810 30 50 15} box ROUNDED_BOX down_box ROUNDED_BOX color 74 selection_color 92 labelfont 2 labelcolor 39 deactivate
xywh {750 30 50 15} box ROUNDED_BOX down_box ROUNDED_BOX color 74 selection_color 92 labelfont 2 labelcolor 39 deactivate
code0 {\#include "FL/Fl_Blinker.H"}
class Fl_Blinker
}
Fl_Button rec_blinker {
label REC
xywh {810 50 50 15} box ROUNDED_BOX down_box ROUNDED_BOX color 72 selection_color 88 labelfont 2 labelcolor 39 deactivate
xywh {750 50 50 15} box ROUNDED_BOX down_box ROUNDED_BOX color 72 selection_color 88 labelfont 2 labelcolor 39 deactivate
code0 {\#include "FL/Fl_Blinker.H"}
class Fl_Blinker
}
@ -724,12 +732,13 @@ p->label( s );} {}
}
Function {update_status()} {open private
} {
code {static char cbp[5], pbp[5], clp[5];
code {static char cbp[5], pbp[5], clp[5], dup[5];
update_progress( capture_buffer_progress, cbp, timeline->total_input_buffer_percent() );
update_progress( playback_buffer_progress, pbp, timeline->total_output_buffer_percent() );
update_progress( cpu_load_progress, clp, engine->cpu_load() );
update_progress( disk_usage_progress, dup, percent_used( "." ) );
if ( timeline->total_capture_xruns() )
capture_buffer_progress->selection_color( FL_RED );

View File

@ -178,3 +178,38 @@ read_line ( const char *dir, const char *name, char **value )
fclose( fp );
}
#include <sys/statvfs.h>
/** return the number of blocks free on filesystem containing file named /file/ */
unsigned long
free_space ( const char *file )
{
struct statvfs st;
memset( &st, 0, sizeof( st ) );
statvfs( file, &st );
return st.f_bfree;
}
/** return the total number of blocks on filesystem containing file named /file/ */
unsigned long
total_space ( const char *file )
{
struct statvfs st;
memset( &st, 0, sizeof( st ) );
statvfs( file, &st );
return st.f_blocks;
}
/** return the percentage of usage on filesystem containing file named /file/ */
int
percent_used ( const char *file )
{
const size_t ts = total_space( file );
return 100 - ( ts ? free_space( file ) * 100 / ts : 0 );
}

View File

@ -31,3 +31,6 @@ char * backwards_fgets ( char *s, int size, FILE *fp );
void touch ( int fd );
void write_line ( const char *dir, const char *name, const char *value );
void read_line ( const char *dir, const char *name, char **value );
size_t free_space ( const char *file );
size_t total_space ( const char *file );
int percent_used ( const char *file );