Ardour  9.0-pre0-822-g12e3bc5c20
simple_progress_dialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _ardour_gtk_simpple_progress_dialog_h_
20 #define _ardour_gtk_simpple_progress_dialog_h_
21 
22 #include <ytkmm/button.h>
23 #include <ytkmm/messagedialog.h>
24 #include <ytkmm/progressbar.h>
25 #include <ytkmm/stock.h>
26 
27 #include "ardour/types.h"
28 
29 class SimpleProgressDialog : public Gtk::MessageDialog
30 {
31 public:
32  SimpleProgressDialog (std::string title, const Glib::SignalProxy0< void >::SlotType & cancel)
33  : MessageDialog (title, false, Gtk::MESSAGE_OTHER, Gtk::BUTTONS_NONE, true)
34  {
35  get_vbox()->set_size_request(400,-1);
36  set_title (title);
37  pbar = manage (new Gtk::ProgressBar());
38  pbar->show();
39  get_vbox()->pack_start (*pbar, Gtk::PACK_SHRINK, 4);
40 
41  Gtk::Button *cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
42  cancel_button->signal_clicked().connect (cancel);
43  cancel_button->show();
44  get_vbox()->pack_start (*cancel_button, Gtk::PACK_SHRINK);
45  }
46 
48  pbar->set_fraction ((float) c / (float) t);
49  // see also ARDOUR_UI::gui_idle_handler();
50  int timeout = 30;
51  while (gtk_events_pending() && --timeout) {
52  gtk_main_iteration ();
53  }
54  }
55 private:
56  Gtk::ProgressBar *pbar;
57 };
58 #endif
void update_progress(ARDOUR::samplecnt_t c, ARDOUR::samplecnt_t t)
SimpleProgressDialog(std::string title, const Glib::SignalProxy0< void >::SlotType &cancel)
Temporal::samplecnt_t samplecnt_t
Definition: ardour_ui.h:189