RE: ProgressBar and error handling



Title: RE: ProgressBar and error handling

Thanks for ur response Paul. Here is more explanation on what I am doing.

onTimeOut() method is called every 0.5s. Mean while, I do not know when the error will happen. If the error happens, I open a new CErrorWindow window (Plz note CErrorWindow is not a Dialog, but a subclass derived from window and is displayed in place of CProgressBar window. My application design is such that I can't use regular dialog window).

"Is there a reason you're passing the progress bar to the error dialog?"

Yes, In CErrorWindow, on clicking "Continue" button, I am showing the CProgressBar window using the reference passed to CErrorWindow, by calling

void CErrorWindow :: continueAction() {
 this->hide();
 Gtk::Main::run(m_handleToProgressBar);
 present();
}

What I am trying to achieve here is to get back to the same CProgresBar object where I got interrupted and resume from there.

This is my first ever Gtk app. I am sure, there must be better design out there to do the same. Also, I am not using glade to manage my windows. Everytime I need to navigate from one window to the other (at the click of a button), I do something similar to above or something like
      
        this->hide();
        CSomeWindow *some = new CSomeWindow(parameters);
        Gtk::Main::run(*some);
        present();

I am really worried about "N" objects being created and lying there without destructor being invoked. Is there a better way of doing all the above without using glade?

Thanks
Sirisha


-----Original Message-----
From: paul joseph davis gmail com on behalf of Paul Davis
Sent: Mon 2/26/2007 6:23 PM
To: Sirisha Muppavarapu
Cc: gtkmm-list gnome org
Subject: Re: ProgressBar and error handling

On 2/26/07, Sirisha Muppavarapu <sirisha muppavarapu veralight com> wrote:
>
>
>
>
> Hi All
>
>  I have this ProgressBar Window which is running a task and updates
> itself(using set_fraction) and it uses signal_timeout()(and onTimeOut()
> callback) method. During this backend processing before updating itself,if
> it encounters an error, it should show another window with the error msg. On
> clicking continue on the error message, the task should continue its
> progress and the progress bar should show progress from where it left.
>
>  I am able to continue running the task at the back end but how to continue
> the progress bar's progress from where I left? say it encountered an error
> at 24% and on clicking continue, the progress should proceed from 24%
>
>  Any ideas on how to achieve this?
>
>  Thanks a ton in advance
>  Sirisha
>
>  Code Snippet
>  -------------
>
>  class CProgressBar : public Gtk::Window {
>
>  public:
>  bool onTimeOut();
>
>  }
>
>  CProgressBar {
>  //someother initializations and logic
>  Glib::signal_timeout().connect( sigc::mem_fun(*this,
> &CGProgressBar::onTimeout), 500 );
>  }
>
>  bool CProgressBar::onTimeOut() {
>
>  //update the progress bar using set_fraction

When you come back into onTimeOut, this logic should figure out where
to start from. You can get the current progress bar value with
get_fraction() IIRC.

>  //and wait for error to happen in the backend
>
>     if(error) {
>      this->hide();
>      //pass the CProgressBar reference to CErrorWindow object

Is there a reason you're passing the progress bar to the error dialog?


>      CErrorWindow *error = new CErrorWindow(*this);
>      Gtk::Main::run(*error);
>      present();
>      return false;
>     }
>  return true;
>  }//end of method
>
>
>
>
>  int main() {
>
>  CProgressBar *pg = new CProgressBar();
>  Gtk::Main::run(*pg);
>  present();
>  }
>
>
>  In CErrorWindow, there are 2 button "CONTINUE" and "CANCEL"
>
>  clicking on continue should take you back to CProgressBar and resume from
> where it left.
>
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>

You should just be able to call back to onTimeOut unless I'm missing
something important.  The progress bar will know what fraction its at,
but its your job to tell it how to update, which includes continuing
from 25% or what not.

HTH,
Paul Davis



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