Gtk::Dialog question.



Hi to everybody

I want to create an pop up Dialog with an progress bar that will show
the progress of some computational process.
This means that I'll need the dialog  pops up without blocking the program.
At first I thought that the only way to call an dialog was with run()
method and because of that I would need to create a new thread to pop up
the dialog.
Then I found that we can do it using the show()/show_all(), that  this
will pop up the dialog as non blocking.

So I tried to create a simple dialog with an progress bar and a button
(only to test this solution).

class ProgressBarDialog : public Gtk::Dialog
{
public:
    ProgressBarDialog ();
    ~ProgressBarDialog (){};
    void PopUP ();
protected:
private:

    Gtk::ProgressBar mProgressBar;
};

ProgressBarDialog::ProgressBarDialog()
{
    Gtk::VBox* dialogVbox;
    dialogVbox = get_vbox();

   
    mProgressBar.set_fraction (0.98); //only for test purpose
    mProgressBar.set_text ("My progress bar");
    mProgressBar.show ();
   
    add_button ("CANCEL", Gtk::RESPONSE_CANCEL);

    dialogVbox->pack_start (mProgressBar);

}

void
ProgressBarDialog::PopUP ()
{
    show_all();
}

Now I use it like this:

SomeHandler ()
{
    ProgressBarDialog progressDialog;
   
     //..... SOME Computational process here

    progressDialog.hide ();
}
Of course the progress bar in this case its expected to be static
because I didn't create a way to update it.

The problem is that when I call the PopUP function it shows the dialog
and runs the computational functions, however the window that appear
does not show the Button neither the progress bar, it shows only the
window top bar with the title and the border, inside of the window it is
transparent.

If I use run() instead of show_all () it shows the button and the
progress bar but it blocks the program until I interact with the dialog
(as it was supposed to do).

So my question is why it does not show the widgets.  What must I do to
force it to draw the widgets before of starting the computation.

Oh, I almost forgotten, when I tried to force the widget to stay after
the process, to see what happens, removing the progressDialog.hide () 
after the calculations, the dialog flashed for 1msecond and hided itself.

Well I will appreciate some help on this issue because I'm not very
familiar to threads in WindowsOS neither with gtkmm threads.

Thanks in advance
Filipe Apóstolo



 


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