I cannnot update progressbar..

I was starting gtk 2weeks ago so I'm beginer.
And I'm sorry my poor English.

I'm trying updating progressbar. But it is not success.
FAQ says "use while( gtk_main_iteration() );".
I try it and I read archives of mailing list.
But I cannot find my mistake.

Please teach me something wrong...
Calling this function, the dialog is appeared.
But label and progress bar show after for loop finished.

void progressbar_test()
    GtkWidget       *dlg;
    GtkWidget       *vbox;
    GtkWidget       *lbl;
    GtkWidget       *pbar;
    int             val;
    gfloat          gflt;
    char    buf[MAX_BUF];

    //create dlg
    dlg = gtk_dialog_new();
    gtk_window_set_title( GTK_WINDOW( dlg ), "ProgressBar" );
    gtk_widget_set_usize( dlg, 200, 100 );
    vbox = GTK_DIALOG( dlg )->vbox;

    //create lbl
    lbl = gtk_label_new( "progressbar!" );
    gtk_box_pack_start( GTK_BOX(vbox), lbl, TRUE, TRUE, 1 );
    gtk_widget_show( lbl );

    //progress bar
    pbar = gtk_progress_bar_new();
    gtk_box_pack_start( GTK_BOX( GTK_DIALOG( dlg )->action_area ),
                         pbar, TRUE, TRUE, 2 );
    gtk_progress_set_format_string( GTK_PROGRESS( pbar ), "%p%%" );
    gtk_widget_show( pbar );

    //show dialog
    gtk_widget_show( dlg );

    //update progress bar
    for( gflt=0; gflt<=1;  ){
        gtk_progress_bar_update( (GtkProgressBar*)pbar, gflt );
        gflt += 0.1;
        if ( gflt > 1 ) break;
        while( gtk_main_iteration() );

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