blob: 43e14cc00e09a8c8e9a46879dda521bb80fd57b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// progress.cc
//
// Copyright 1999-2009 Daniel Burrows
// Copyright 2008 Obey Arthur Liu
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include "gtk/progress.h"
#include "gui.h"
namespace gui
{
static double sanitizePercentFraction(float percent)
{
double rval = (double)percent / 100;
if (rval < 0)
rval = 0;
if (rval > 1)
rval = 1;
return rval;
}
guiOpProgress::guiOpProgress()
: destroyed(false)
{
pMainWindow->get_progress_bar()->show();
}
guiOpProgress::~guiOpProgress()
{
destroy();
}
void guiOpProgress::Update()
{
if (CheckChange(0.1))
{
pMainWindow->get_progress_bar()->set_text(Op);
pMainWindow->get_progress_bar()->set_fraction(sanitizePercentFraction(Percent));
gtk_update();
}
}
void guiOpProgress::destroy()
{
if(!destroyed)
{
destroyed = true;
pMainWindow->get_progress_bar()->set_text("");
pMainWindow->get_progress_bar()->set_fraction(0);
pMainWindow->get_progress_bar()->hide();
}
}
gtkEntryOpProgress::gtkEntryOpProgress(Gtk::Entry &entry)
: set_progress_fraction(sigc::mem_fun(entry, &Gtk::Entry::set_progress_fraction)),
destroyed(false)
{
}
gtkEntryOpProgress::~gtkEntryOpProgress()
{
destroy();
}
void gtkEntryOpProgress::Update()
{
if(!destroyed)
{
if(CheckChange(0.1))
{
set_progress_fraction(sanitizePercentFraction(Percent));
gtk_update();
}
}
}
void gtkEntryOpProgress::destroy()
{
if(!destroyed)
{
destroyed = true;
set_progress_fraction(0);
}
}
}
|