Refreshing GUI and Progressbar

Hi,

I am programming an application with ruby-gnome. My application is
downloading some data and I wanna display a download-dialog, while the
downloading is running. So I created a GUI, the download-dialog. This
dialog should be displayed, when the download begins. A progressbar shows
the current download-state. Now my problem is, that the GUI is not really
refreshed. At my first try the download-dialog became displayed, when the
download was finished *g* Now I added a:

      begin
        Gtk.main_iteration
      end while(Gtk.events_pending?)

every time a part of the gui changes. This let the download-dialog
display, when the download starts. But it does not really work as I wish.
The progressbar becomes not refreshed in the way I hope. Maybe I did
something wrong:

If I wanna download 50 elements I wanna go the progressbar one step
further, when one element is downloaded.

So: count = 50

Then I do:

progressbar_download.pulse_step = (1 / count)

And every time an element is downloaded I do a:

progressbar_download.pulse

Is this correct? Or did I understand something wrong?

The progressbar becomes displayed and the first steps work, then it does
not change, or maybe it only does not refresh. Maybe you have some hints
for me.

Greetings

Mike

Michael Gebhart wrote:

      begin
        Gtk.main_iteration
      end while(Gtk.events_pending?)

And every time an element is downloaded I do a:

progressbar_download.pulse

Is this correct? Or did I understand something wrong?

You might try this question on a Gtk+ mailing list.

The utterly generic advise is to start a window timer, and set it to a short
or 0 duration. In it, pump one main_iteration and one progress bar update.

···

--
  Phlip
  http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces

Hi,

···

On Apr 11, 2005 4:19 AM, Michael Gebhart <mail@miketech.net> wrote:

I am programming an application with ruby-gnome. My application is
downloading some data and I wanna display a download-dialog, while the
downloading is running. So I created a GUI, the download-dialog. This
dialog should be displayed, when the download begins. A progressbar shows
the current download-state. Now my problem is, that the GUI is not really
refreshed. At my first try the download-dialog became displayed, when the

(you should use ruby-gnome2-devel-en mailing-list)

Ruby threads, being entirely in the interpreter, are in my opinion a
particularly elegant solution for the problem of refreshing a gtk2
application performing intensive tasks (gtk will never even see that
multiple "threads" are executing). Check the following short example.

-=-=-=---=-=-=---=-=-=---=-=-=---=-=-=---=-=-=--
require 'gtk2'

Gtk.init

v = Gtk::VBox.new
v.add(l = Gtk::Label.new('ready'))
v.add(b = Gtk::Button.new('start'))
w = Gtk::Window.new.add(v).show_all

b.signal_connect('clicked') {
    Thread.new {
        1.upto(4) { |i|
            l.label = "downloading part #{i}"
            sleep 2
        }
        l.label = 'ready'
    }
}

Gtk.main
-=-=-=---=-=-=---=-=-=---=-=-=---=-=-=---=-=-=--

--
Guillaume Cottenceau - http://zarb.org/~gc/