blob: 3e2c660e4ae1c8202246425d28921aebd30eec18 (
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
|
# BitBake Graphical GTK User Interface
#
# Copyright (C) 2011 Intel Corporation
#
# Authored by Shane Wang <shane.wang@intel.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import gtk
from bb.ui.crumbs.hobcolor import HobColors
class HobProgressBar (gtk.ProgressBar):
def __init__(self):
gtk.ProgressBar.__init__(self)
self.set_rcstyle(True)
self.percentage = 0
def set_rcstyle(self, status):
rcstyle = gtk.RcStyle()
rcstyle.fg[2] = gtk.gdk.Color(HobColors.BLACK)
if status == "stop":
rcstyle.bg[3] = gtk.gdk.Color(HobColors.WARNING)
elif status == "fail":
rcstyle.bg[3] = gtk.gdk.Color(HobColors.ERROR)
else:
rcstyle.bg[3] = gtk.gdk.Color(HobColors.RUNNING)
self.modify_style(rcstyle)
def set_title(self, text=None):
if not text:
text = ""
text += " %.0f%%" % self.percentage
self.set_text(text)
def set_stop_title(self, text=None):
if not text:
text = ""
self.set_text(text)
def reset(self):
self.set_fraction(0)
self.set_text("")
self.set_rcstyle(True)
self.percentage = 0
def update(self, fraction):
self.percentage = int(fraction * 100)
self.set_fraction(fraction)
|