progress
A simple Time slider, using a progress bar.

We use the gtk_timeout_add() function to add 
timeouts. Timeouts are functions that get executed
as and when the timer expires. We can set the function
to be called again and again if we return value TRUE
from the callback, else if we return FALSE the timeout
function is killed.


The way to set the progress bar is using these calls.

Create a progress bar.
Set format strings. These follow printf syntaxes.
 Using %% we can get a % and using %V we can have the
 absolute value of the scale, %P gives the percentage
 scale etc.

Set the value of the scale using configure;its max & min
values.

We also set the orientation, it can be Top to bottom,
left to right, and vice versa.

Also enble the text showing property to be true.

  x=gtk_progress_bar_new();
  gtk_progress_set_format_string(GTK_PROGRESS(x),"%V %%"); 
  gtk_progress_configure(GTK_PROGRESS(x),0.0,0.0,200.0);
  gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(x),GTK_PROGRESS_LEFT_TO_RIGHT);
  gtk_progress_set_show_text(GTK_PROGRESS(x),TRUE);

We can update the progress bar like this.
Get its value, and after an event it over, we
set its value to give the user some feedback of
the progressbar's status.

  val=gtk_progress_get_value(GTK_PROGRESS(x));
  val+=1;
  gtk_progress_set_value(GTK_PROGRESS(x),val);

By default the progressbar gets values from 0 to 100.



Suggested uses of the slider are for an application Launcher, 
like the one we most often encounter with setup programs,
and application loading windows like the GIMP startup window,
which shows interactively the time left for startup and
gives feedback on the type of application plugins being 
loaded.

see also: adjustable, scrollbar



Last Modified on Sun Jul 3 23:41:40 IST 2005
This is part of the GtkBook project Hosted Here
This code, documents and images are © Muthiah Annamalai
This document is under Creative Commons License given by LICENSE