28 using namespace GtkCRN;
36 autoclose(auto_close),
37 terminate_on_exception(
true),
38 #ifdef CRN_USING_GTKMM3
39 vbox(Gtk::ORIENTATION_VERTICAL),
42 closebut(Gtk::Stock::CLOSE)
48 set_transient_for (*parent);
49 set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
56 set_transient_for (*mainwin);
57 set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
60 set_position(Gtk::WIN_POS_CENTER);
64 set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
66 signal_delete_event().connect(sigc::mem_fun(
this, &ProgressWindow::no_close));
68 closebut.signal_clicked().connect(sigc::mem_fun(
this, &ProgressWindow::on_close));
69 closebut.set_sensitive(
false);
74 #ifdef CRN_USING_GTKMM3
75 Gtk::Box *hbox = Gtk::manage(
new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
76 hbox->set_halign(Gtk::ALIGN_END);
77 vbox.pack_end(*hbox,
false,
false, 0);
78 hbox->pack_end(closebut,
false,
false, 0);
81 Gtk::Alignment *al = Gtk::manage(
new Gtk::Alignment(Gtk::ALIGN_RIGHT));
82 vbox.pack_end(*al,
false,
false, 0);
83 Gtk::HBox *hbox = Gtk::manage(
new Gtk::HBox());
85 hbox->pack_end(closebut,
false,
false, 0);
99 progbars.push_back(std::make_shared<Progress>(name, maxcount));
100 vbox.pack_start(progbars.back()->GetProgressBar());
101 return progbars.size() - 1;
114 if (
id >= progbars.size())
116 return progbars[id].get();
129 if (
id >= progbars.size())
131 return progbars[id]->GetProgressBar();
140 Glib::Thread *thread = Glib::Thread::create(sigc::bind(sigc::mem_fun(
this, &ProgressWindow::do_run), func),
true);
142 Glib::Thread::create(sigc::bind(sigc::mem_fun(
this, &ProgressWindow::wait), thread),
false);
145 Gtk::Main::iteration();
149 bool ProgressWindow::no_close(GdkEventAny *ev)
154 void ProgressWindow::do_run(sigc::slot<void> func)
164 catch (std::exception &ex)
174 void ProgressWindow::wait(Glib::Thread *thread)
177 g_idle_add(GSourceFunc(ProgressWindow::end),
this);
180 void ProgressWindow::on_close()
188 pw->closebut.set_sensitive(
true);
Gtk::ProgressBar & get_gtk_progressbar(size_t id)
Gets an existing progress bar widget.
Base class for a progress display.
A UTF32 character string class.
crn::Progress * get_crn_progress(size_t id)
Gets an existing progress bar.
Splash window with progress bars.
ProgressWindow(const Glib::ustring title, Gtk::Window *parent=nullptr, bool auto_close=false)
Constructor.
static Gtk::Window * get_main_window()
Gets a pointer to the main window.
void run(sigc::slot< void > func)
Executes a processing.
static void show_exception(crn::Exception &ex, bool kill_app=true)
Displays an exception.
A character string class.
Base class for exceptions.
size_t add_progress_bar(const crn::String &name, size_t maxcount=100)
Adds a progress bar to the window.