progress bar for Linux partially done: no indeterminate progress bar yet.

This commit is contained in:
Thai Pangsakulyanont
2011-06-12 13:24:39 +07:00
parent 6c32ca085e
commit c057b23ab3
3 changed files with 35 additions and 3 deletions
@@ -5,6 +5,7 @@
static GtkWidget *label;
static GtkWidget *window;
static GtkWidget *progressBar;
extern "C" const char *Init( int *argc, char ***argv )
{
@@ -22,9 +23,12 @@ extern "C" const char *Init( int *argc, char ***argv )
loadimage = gtk_image_new_from_file(splash_image_path);
label = gtk_label_new(NULL);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_CENTER);
progressBar = gtk_progress_bar_new();
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), 0.0 );
vbox = gtk_vbox_new(FALSE,5);
gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_box_pack_start(GTK_BOX(vbox),loadimage,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(vbox),progressBar,TRUE,TRUE,0);
gtk_box_pack_end(GTK_BOX(vbox),label,TRUE,TRUE,0);
gtk_widget_show_all(window);
@@ -47,6 +51,21 @@ extern "C" void SetText( const char *s )
gtk_main_iteration_do(FALSE);
}
extern "C" void SetProgress( int progress, int totalWork )
{
gdouble fraction = ( totalWork > 0 ? progress / (gdouble)totalWork : 0 );
if( fraction > 1.0 ) fraction = 1.0;
if( fraction < 0.0 ) fraction = 0.0;
gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(progressBar), fraction );
gtk_main_iteration_do(FALSE);
}
extern "C" void SetIndeterminate( bool indeterminate )
{
// TODO: Implement this!
gtk_main_iteration_do(FALSE);
}
/*
* (c) 2003-2004 Glenn Maynard, Sean Burke
* All rights reserved.