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