Re: progress bar not updating in gtk+-2.14.5



It works here with the latest Ubuntu (gtk+ 2.14.4), so if it is a
regression, it was introduced in 2.14.5. (Or Ubuntu has a patch that
covers it up.)  A quick glance at the changelog for 2.14.5 didn't show
anything obvious to me, but I'm far from an expert.

Chisheng:
Try a gtk_widget_queue_draw(GTK_WIDGET(pbar)) after your call to
set_fraction and see if that helps.  Also, I'm assuming your callback is
working properly (you see the numbers scrolling in the console).


-Larry

On Tue, 2008-12-23 at 12:24 -0800, Chisheng Huang wrote:
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;
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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