diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/progressbar.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/progressbar.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/progressbar.py b/bitbake/lib/bb/ui/crumbs/progressbar.py new file mode 100644 index 0000000000..882d461711 --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/progressbar.py | |||
@@ -0,0 +1,52 @@ | |||
1 | # BitBake Graphical GTK User Interface | ||
2 | # | ||
3 | # Copyright (C) 2011 Intel Corporation | ||
4 | # | ||
5 | # Authored by Shane Wang <shane.wang@intel.com> | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License version 2 as | ||
9 | # published by the Free Software Foundation. | ||
10 | # | ||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License along | ||
17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | |||
20 | import gtk | ||
21 | from bb.ui.crumbs.hobcolor import HobColors | ||
22 | |||
23 | class HobProgressBar (gtk.ProgressBar): | ||
24 | def __init__(self): | ||
25 | gtk.ProgressBar.__init__(self) | ||
26 | self.set_rcstyle(True) | ||
27 | self.percentage = 0 | ||
28 | |||
29 | def set_rcstyle(self, status): | ||
30 | rcstyle = gtk.RcStyle() | ||
31 | rcstyle.fg[2] = gtk.gdk.Color(HobColors.BLACK) | ||
32 | if status: | ||
33 | rcstyle.bg[3] = gtk.gdk.Color(HobColors.RUNNING) | ||
34 | else: | ||
35 | rcstyle.bg[3] = gtk.gdk.Color(HobColors.ERROR) | ||
36 | self.modify_style(rcstyle) | ||
37 | |||
38 | def set_title(self, text=None): | ||
39 | if not text: | ||
40 | text = "" | ||
41 | text += " %.0f%%" % self.percentage | ||
42 | self.set_text(text) | ||
43 | |||
44 | def reset(self): | ||
45 | self.set_fraction(0) | ||
46 | self.set_text("") | ||
47 | self.set_rcstyle(True) | ||
48 | self.percentage = 0 | ||
49 | |||
50 | def update(self, fraction): | ||
51 | self.percentage = int(fraction * 100) | ||
52 | self.set_fraction(fraction) | ||