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
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
47
void
update_progress
(
ARDOUR::samplecnt_t
c,
ARDOUR::samplecnt_t
t) {
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
types.h
Gtk::Box::pack_start
void pack_start(Widget &child, bool expand, bool fill, guint padding=0)
Gtk::Button
Definition:
tk/ytkmm/ytkmm/gtkmm/button.h:60
Gtk::Button::signal_clicked
Glib::SignalProxy0< void > signal_clicked()
Gtk::Dialog::get_vbox
VBox * get_vbox()
Gtk::Dialog::add_button
Button * add_button(const Glib::ustring &button_text, int response_id)
Gtk::MessageDialog
Definition:
messagedialog.h:97
Gtk::MessageDialog::MessageDialog
MessageDialog(const Glib::ustring &message, bool use_markup=false, MessageType type=MESSAGE_INFO, ButtonsType buttons=BUTTONS_OK, bool modal=false)
Gtk::ProgressBar
Definition:
progressbar.h:109
Gtk::ProgressBar::set_fraction
void set_fraction(double fraction)
Gtk::Widget::set_size_request
void set_size_request(int width=-1, int height=-1)
Gtk::Widget::show
void show()
Gtk::Window::set_title
void set_title(const Glib::ustring &title)
SimpleProgressDialog
Definition:
simple_progress_dialog.h:30
SimpleProgressDialog::update_progress
void update_progress(ARDOUR::samplecnt_t c, ARDOUR::samplecnt_t t)
Definition:
simple_progress_dialog.h:47
SimpleProgressDialog::SimpleProgressDialog
SimpleProgressDialog(std::string title, const Glib::SignalProxy0< void >::SlotType &cancel)
Definition:
simple_progress_dialog.h:32
SimpleProgressDialog::pbar
Gtk::ProgressBar * pbar
Definition:
simple_progress_dialog.h:56
Gtk::BUTTONS_NONE
@ BUTTONS_NONE
Definition:
messagedialog.h:55
Gtk::RESPONSE_CANCEL
@ RESPONSE_CANCEL
Definition:
dialog.h:65
Gtk::PACK_SHRINK
@ PACK_SHRINK
Definition:
tk/ytkmm/ytkmm/gtkmm/box.h:94
Gtk::MESSAGE_OTHER
@ MESSAGE_OTHER
Definition:
libs/tk/ytkmm/ytkmm/gtkmm/enums.h:601
gtk_main_iteration
gboolean gtk_main_iteration(void)
gtk_events_pending
gboolean gtk_events_pending(void)
messagedialog.h
ARDOUR::samplecnt_t
Temporal::samplecnt_t samplecnt_t
Definition:
ardour/ardour/types.h:89
Gtk::Stock::CANCEL
GTKMM_API const Gtk::BuiltinStockID CANCEL
Gtk
Definition:
ardour_ui.h:188
Gtk::manage
T * manage(T *obj)
Definition:
object.h:58
progressbar.h
stock.h
button.h
gtk2_ardour
simple_progress_dialog.h
Generated on Wed Dec 25 2024 05:44:48 for Ardour by
1.9.1