Ardour  9.0-pre0-582-g084a23a80d
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 <gtkmm/button.h>
23 #include <gtkmm/messagedialog.h>
24 #include <gtkmm/progressbar.h>
25 #include <gtkmm/stock.h>
26 
27 #include "ardour/types.h"
28 
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();
40 
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) {
53  }
54  }
55 private:
57 };
58 #endif
void pack_start(Widget &child, bool expand, bool fill, guint padding=0)
Glib::SignalProxy0< void > signal_clicked()
VBox * get_vbox()
Button * add_button(const Glib::ustring &button_text, int response_id)
MessageDialog(const Glib::ustring &message, bool use_markup=false, MessageType type=MESSAGE_INFO, ButtonsType buttons=BUTTONS_OK, bool modal=false)
void set_fraction(double fraction)
void set_size_request(int width=-1, int height=-1)
void set_title(const Glib::ustring &title)
void update_progress(ARDOUR::samplecnt_t c, ARDOUR::samplecnt_t t)
SimpleProgressDialog(std::string title, const Glib::SignalProxy0< void >::SlotType &cancel)
@ BUTTONS_NONE
Definition: messagedialog.h:55
@ RESPONSE_CANCEL
Definition: dialog.h:65
gboolean gtk_main_iteration(void)
gboolean gtk_events_pending(void)
Temporal::samplecnt_t samplecnt_t
GTKMM_API const Gtk::BuiltinStockID CANCEL
Definition: ardour_ui.h:188
T * manage(T *obj)
Definition: object.h:58