progress bar not updating in gtk+-2.14.5



Hi,

The attached code will pop up a window with a progress bar in it.
The fill fraction goes from 0.0 to 1.0 gradually and is reset to 0.0
when it's bigger than 1.0.  With GTK+ 2.12.10, the appearance of the
progress bar is constantly updated.  However, with GTK+ 2.14.5, the
progress bar always remains empty.  Is this change of updating behaviour
from 2.12.10 to 2.14.5 a bug or an intended feature?  If it's a feature,
what extra functions do I have to call to make a progess bar update?

Best wishes,

-cph

--------------------------------- cut ---------------------------------
#include <gtk/gtk.h>

static void destroy( GtkWidget *widget,
                     gpointer   timeout)
{
  g_source_remove (GPOINTER_TO_UINT (timeout));
  gtk_main_quit ();
}

static gboolean
update_pbar (GtkProgressBar *pbar)
{
  gdouble frac = gtk_progress_bar_get_fraction (pbar) + 0.01;
  if (frac > 1.0) 
    frac = 0.0;
  g_print ("%f\n", frac);
  gtk_progress_bar_set_fraction (pbar, frac);
  return TRUE;
}

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *pbar;
    guint timeout_id;
    
    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (destroy), &timeout_id);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    
    pbar = gtk_progress_bar_new (); 
    timeout_id = g_timeout_add (100, (GSourceFunc) update_pbar, pbar);
    gtk_container_add (GTK_CONTAINER (window), pbar);

    gtk_widget_show (pbar);
    gtk_widget_show (window);
    gtk_main ();

    return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]