libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GtkCRNProgressWindow.h
Go to the documentation of this file.
1 /* Copyright 2010-2015 CoReNum, INSA-Lyon
2  *
3  * This file is part of libgtkcrnmm.
4  *
5  * libgtkcrnmm is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libgtkcrnmm is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libgtkcrnmm. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: GtkCRNProgressWindow.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef GtkCRNProgressWindow_HEADER
23 #define GtkCRNProgressWindow_HEADER
24 
25 #include <libgtkcrnmm_config.h>
26 #include <GtkCRNProgress.h>
27 #include <gtkmm.h>
28 
29 namespace GtkCRN
30 {
34  class ProgressWindow : public Gtk::Window
35  {
36  public:
38  ProgressWindow(const Glib::ustring title, Gtk::Window *parent = nullptr, bool auto_close = false);
39  virtual ~ProgressWindow() override {}
40 
42  size_t add_progress_bar(const crn::String &name, size_t maxcount = 100);
44  crn::Progress* get_crn_progress(size_t id);
46  Gtk::ProgressBar& get_gtk_progressbar(size_t id);
47 
49  void set_terminate_on_exception(bool term) { terminate_on_exception = term; }
50 
52  void run(sigc::slot<void> func);
54  template<typename T> inline T run(sigc::slot<T> func)
55  {
56  T retval;
57  run(sigc::bind(sigc::mem_fun(this, &ProgressWindow::wrap_run<T>), func, &retval));
58  return retval;
59  }
60 
62  sigc::signal<void> signal_done() { return done; }
63 
64  private:
65  template<typename T> void wrap_run(sigc::slot<T> func, T *retval)
66  {
67  *retval = func();
68  }
69  bool no_close(GdkEventAny *ev);
70  void do_run(sigc::slot<void> func);
71  void wait(Glib::Thread *thread);
72  void on_close();
73  static gboolean end(ProgressWindow *pw);
74  bool working;
75 
76  bool autoclose;
77  std::vector<std::shared_ptr<Progress> > progbars;
78 
79  bool terminate_on_exception;
80 
81 #ifdef CRN_USING_GTKMM3
82  Gtk::Box vbox;
83 #else
84  Gtk::VBox vbox;
85 #endif
86  Gtk::Button closebut;
87 
88  sigc::signal<void> done;
89  };
90 }
91 
92 #endif
93 
T run(sigc::slot< T > func)
Executes a processing.
Gtk::ProgressBar & get_gtk_progressbar(size_t id)
Gets an existing progress bar widget.
sigc::signal< void > signal_done()
Signals that the progress reached 100%. Connect to void on_done().
virtual ~ProgressWindow() override
Base class for a progress display.
Definition: CRNProgress.h:39
void set_terminate_on_exception(bool term)
Shall the application be terminated if the processing throws an exception?
A UTF32 character string class.
Definition: CRNString.h:61
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.
void run(sigc::slot< void > func)
Executes a processing.
size_t add_progress_bar(const crn::String &name, size_t maxcount=100)
Adds a progress bar to the window.