libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GtkCRNProgress.cpp
Go to the documentation of this file.
1 /* Copyright 2010-2015 CoReNum
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: GtkCRNProgress.cpp
19  * \author Yann LEYDIER
20  */
21 
22 #include <GtkCRNProgress.h>
23 
24 using namespace GtkCRN;
25 
30 GtkCRN::Progress::Progress(const crn::String &name, size_t maxcount):
31  crn::Progress(name, maxcount),
32  has_ended(false)
33 {
34  pb.show();
35  display(name);
36 }
37 
43 GtkCRN::Progress::Progress(const crn::String &name, sigc::slot<void> execute_at_end, size_t maxcount):
44  crn::Progress(name, maxcount),
45  has_ended(false)
46 {
47  progress_end.connect(execute_at_end);
48  pb.show();
49  display(name);
50 }
51 
56 {
57  PM *data(new PM(this, msg));
58  g_idle_add(GSourceFunc(Progress::ts_display), data);
59 }
60 
61 gboolean Progress::ts_display(PM *data)
62 {
63  data->prog->pb.set_text(data->msg.CStr());
64  data->prog->pb.set_fraction(double(data->prog->current) / data->prog->end);
65  if ((data->prog->current >= data->prog->end) && !data->prog->has_ended)
66  {
67  data->prog->has_ended = true;
68  data->prog->progress_end.emit();
69  }
70  delete data;
71  return FALSE;
72 }
73 
Progress object associated with a widget.
Progress(const crn::String &name, size_t maxcount=100)
Constructor.
A UTF32 character string class.
Definition: CRNString.h:61
virtual void display(const crn::String &msg) override
Displays current progress on Gtk progress bar (thread safe)
#define false
Definition: ConvertUTF.cpp:56