Add API allowing plugin preset load to affect automation
[ardour.git] / gtk2_ardour / simple_progress_dialog.h
1 #ifndef _ardour_gtk_simpple_progress_dialog_h_
2 #define _ardour_gtk_simpple_progress_dialog_h_
3
4 #include <gtkmm/messagedialog.h>
5 #include <gtkmm/button.h>
6 #include <gtkmm/progressbar.h>
7
8 #include "ardour/types.h"
9
10 class SimpleProgressDialog : public Gtk::MessageDialog
11 {
12 public:
13         SimpleProgressDialog (std::string title, const Glib::SignalProxy0< void >::SlotType & cancel)
14                 : MessageDialog (title, false, MESSAGE_OTHER, BUTTONS_NONE, true)
15         {
16                 get_vbox()->set_size_request(400,-1);
17                 set_title (title);
18                 pbar = manage (new Gtk::ProgressBar());
19                 pbar->show();
20                 get_vbox()->pack_start (*pbar, PACK_SHRINK, 4);
21
22                 Gtk::Button *cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
23                 cancel_button->signal_clicked().connect (cancel);
24                 cancel_button->show();
25                 get_vbox()->pack_start (*cancel_button, PACK_SHRINK);
26         }
27
28         void update_progress (framecnt_t c, framecnt_t t) {
29                 pbar->set_fraction ((float) c / (float) t);
30                 // see also ARDOUR_UI::gui_idle_handler();
31                 int timeout = 30;
32                 while (gtk_events_pending() && --timeout) {
33                         gtk_main_iteration ();
34                 }
35         }
36 private:
37         Gtk::ProgressBar *pbar;
38 };
39 #endif