Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 == "stop": |
| 33 | rcstyle.bg[3] = gtk.gdk.Color(HobColors.WARNING) |
| 34 | elif status == "fail": |
| 35 | rcstyle.bg[3] = gtk.gdk.Color(HobColors.ERROR) |
| 36 | else: |
| 37 | rcstyle.bg[3] = gtk.gdk.Color(HobColors.RUNNING) |
| 38 | self.modify_style(rcstyle) |
| 39 | |
| 40 | def set_title(self, text=None): |
| 41 | if not text: |
| 42 | text = "" |
| 43 | text += " %.0f%%" % self.percentage |
| 44 | self.set_text(text) |
| 45 | |
| 46 | def set_stop_title(self, text=None): |
| 47 | if not text: |
| 48 | text = "" |
| 49 | self.set_text(text) |
| 50 | |
| 51 | def reset(self): |
| 52 | self.set_fraction(0) |
| 53 | self.set_text("") |
| 54 | self.set_rcstyle(True) |
| 55 | self.percentage = 0 |
| 56 | |
| 57 | def update(self, fraction): |
| 58 | self.percentage = int(fraction * 100) |
| 59 | self.set_fraction(fraction) |