Patchwork [bitbake-devel,3/3] Hob: show indicators on the tabs of the Hob notebook

login
register
mail settings
Submitter Shane Wang
Date March 12, 2012, 1:23 p.m.
Message ID <291c138d68bb9ae807842b03d43dd848684b7279.1331558221.git.shane.wang@intel.com>
Download mbox | patch
Permalink /patch/23031/
State New
Headers show

Comments

Shane Wang - March 12, 2012, 1:23 p.m.
This patch is to show the indicators (e.g., the number of the issues) in the build details page to highlight.

Signed-off-by: Liming An <limingx.l.an@intel.com>
Signed-off-by: Shane Wang <shane.wang@intel.com>
---
 bitbake/lib/bb/ui/crumbs/builddetailspage.py |   10 ++++++++++
 bitbake/lib/bb/ui/crumbs/builder.py          |    5 +++++
 bitbake/lib/bb/ui/crumbs/hobwidget.py        |   14 ++++++++++++++
 bitbake/lib/bb/ui/crumbs/runningbuild.py     |    4 ++++
 4 files changed, 33 insertions(+), 0 deletions(-)
Joshua Lock - March 13, 2012, 6:12 p.m.
On 12/03/12 06:23, Shane Wang wrote:
> This patch is to show the indicators (e.g., the number of the issues) in the build details page to highlight.


My understanding of the design is that warnings are an "Issue" too, can 
we emit the signal for a warning too?

> Signed-off-by: Liming An<limingx.l.an@intel.com>
> Signed-off-by: Shane Wang<shane.wang@intel.com>
> ---
>   bitbake/lib/bb/ui/crumbs/builddetailspage.py |   10 ++++++++++
>   bitbake/lib/bb/ui/crumbs/builder.py          |    5 +++++
>   bitbake/lib/bb/ui/crumbs/hobwidget.py        |   14 ++++++++++++++
>   bitbake/lib/bb/ui/crumbs/runningbuild.py     |    4 ++++
>   4 files changed, 33 insertions(+), 0 deletions(-)
>
> diff --git a/bitbake/lib/bb/ui/crumbs/builddetailspage.py b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
> index 8ebcf08..4a9f658 100755
> --- a/bitbake/lib/bb/ui/crumbs/builddetailspage.py
> +++ b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
> @@ -37,6 +37,8 @@ class BuildDetailsPage (HobPage):
>       def __init__(self, builder):
>           super(BuildDetailsPage, self).__init__(builder, "Building ...")
>
> +        self.num_of_issues = 0
> +
>           # create visual elements
>           self.create_visual_elements()
>
> @@ -80,6 +82,14 @@ class BuildDetailsPage (HobPage):
>           self.back_button.connect("clicked", self.back_button_clicked_cb)
>           self.button_box.pack_start(self.back_button, expand=False, fill=False)
>
> +    def show_issues(self):
> +        self.num_of_issues += 1
> +        self.notebook.show_indicator_icon("Issues", self.num_of_issues)
> +
> +    def reset_issues(self):
> +        self.num_of_issues = 0
> +        self.notebook.hide_indicator_icon("Issues")
> +
>       def _remove_all_widget(self):
>           children = self.vbox.get_children() or []
>           for child in children:
> diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
> index a905030..be8abd9 100755
> --- a/bitbake/lib/bb/ui/crumbs/builder.py
> +++ b/bitbake/lib/bb/ui/crumbs/builder.py
> @@ -212,6 +212,7 @@ class Builder(gtk.Window):
>           self.handler.build.connect("build-succeeded",    self.handler_build_succeeded_cb)
>           self.handler.build.connect("build-failed",       self.handler_build_failed_cb)
>           self.handler.build.connect("task-started",       self.handler_task_started_cb)
> +        self.handler.build.connect("log-error",          self.handler_build_failure_cb)
>           self.handler.connect("generating-data",          self.handler_generating_data_cb)
>           self.handler.connect("data-generated",           self.handler_data_generated_cb)
>           self.handler.connect("command-succeeded",        self.handler_command_succeeded_cb)
> @@ -518,6 +519,7 @@ class Builder(gtk.Window):
>           elif self.current_step == self.PACKAGE_GENERATING:
>               fraction = 0
>           self.build_details_page.update_progress_bar("Build Started: ", fraction)
> +        self.build_details_page.reset_issues()
>
>       def build_succeeded(self):
>           if self.current_step == self.FAST_IMAGE_GENERATING:
> @@ -585,6 +587,9 @@ class Builder(gtk.Window):
>                   fraction = 0.2 + 0.8 * fraction
>           self.build_details_page.update_progress_bar(title + ": ", fraction)
>
> +    def handler_build_failure_cb(self, running_build):
> +        self.build_details_page.show_issues()
> +
>       def destroy_window_cb(self, widget, event):
>           lbl = "<b>Do you really want to exit the Hob image creator?</b>"
>           dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
> diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
> index 9af19f6..d1557a8 100644
> --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
> +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
> @@ -619,6 +619,20 @@ class HobNotebook(gtk.VBox):
>
>           self.tb.show()
>
> +    def show_indicator_icon(self, title, number):
> +        for i in range(len(self.tabbar.children)):
> +            if self.tabbar.children[i]["toggled_page"] == -1:
> +                continue
> +            if self.tabbar.children[i]["title"] == title:
> +                self.tabbar.show_indicator_icon(i, number)
> +
> +    def hide_indicator_icon(self, title):
> +        for i in range(len(self.tabbar.children)):
> +            if self.tabbar.children[i]["toggled_page"] == -1:
> +                continue
> +            if self.tabbar.children[i]["title"] == title:
> +                self.tabbar.hide_indicator_icon(i)
> +
>       def tab_switched_cb(self, widget, page):
>           self.notebook.set_current_page(page)
>
> diff --git a/bitbake/lib/bb/ui/crumbs/runningbuild.py b/bitbake/lib/bb/ui/crumbs/runningbuild.py
> index eedd8d9..ddac232 100644
> --- a/bitbake/lib/bb/ui/crumbs/runningbuild.py
> +++ b/bitbake/lib/bb/ui/crumbs/runningbuild.py
> @@ -84,6 +84,9 @@ class RunningBuild (gobject.GObject):
>             'task-started'   : (gobject.SIGNAL_RUN_LAST,
>                                 gobject.TYPE_NONE,
>                                 (gobject.TYPE_PYOBJECT,)),
> +          'log-error'      : (gobject.SIGNAL_RUN_LAST,
> +                              gobject.TYPE_NONE,
> +                              ()),
>             }
>       pids_to_task = {}
>       tasks_to_iter = {}
> @@ -134,6 +137,7 @@ class RunningBuild (gobject.GObject):
>               if event.levelno>= logging.ERROR:
>                   icon = "dialog-error"
>                   color = HobColors.ERROR
> +                self.emit("log-error")
>               elif event.levelno>= logging.WARNING:
>                   icon = "dialog-warning"
>                   color = HobColors.WARNING

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/builddetailspage.py b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
index 8ebcf08..4a9f658 100755
--- a/bitbake/lib/bb/ui/crumbs/builddetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/builddetailspage.py
@@ -37,6 +37,8 @@  class BuildDetailsPage (HobPage):
     def __init__(self, builder):
         super(BuildDetailsPage, self).__init__(builder, "Building ...")
 
+        self.num_of_issues = 0
+
         # create visual elements
         self.create_visual_elements()
 
@@ -80,6 +82,14 @@  class BuildDetailsPage (HobPage):
         self.back_button.connect("clicked", self.back_button_clicked_cb)
         self.button_box.pack_start(self.back_button, expand=False, fill=False)
 
+    def show_issues(self):
+        self.num_of_issues += 1
+        self.notebook.show_indicator_icon("Issues", self.num_of_issues)
+
+    def reset_issues(self):
+        self.num_of_issues = 0
+        self.notebook.hide_indicator_icon("Issues")
+
     def _remove_all_widget(self):
         children = self.vbox.get_children() or []
         for child in children:
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index a905030..be8abd9 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -212,6 +212,7 @@  class Builder(gtk.Window):
         self.handler.build.connect("build-succeeded",    self.handler_build_succeeded_cb)
         self.handler.build.connect("build-failed",       self.handler_build_failed_cb)
         self.handler.build.connect("task-started",       self.handler_task_started_cb)
+        self.handler.build.connect("log-error",          self.handler_build_failure_cb)
         self.handler.connect("generating-data",          self.handler_generating_data_cb)
         self.handler.connect("data-generated",           self.handler_data_generated_cb)
         self.handler.connect("command-succeeded",        self.handler_command_succeeded_cb)
@@ -518,6 +519,7 @@  class Builder(gtk.Window):
         elif self.current_step == self.PACKAGE_GENERATING:
             fraction = 0
         self.build_details_page.update_progress_bar("Build Started: ", fraction)
+        self.build_details_page.reset_issues()
 
     def build_succeeded(self):
         if self.current_step == self.FAST_IMAGE_GENERATING:
@@ -585,6 +587,9 @@  class Builder(gtk.Window):
                 fraction = 0.2 + 0.8 * fraction
         self.build_details_page.update_progress_bar(title + ": ", fraction)
 
+    def handler_build_failure_cb(self, running_build):
+        self.build_details_page.show_issues()
+
     def destroy_window_cb(self, widget, event):
         lbl = "<b>Do you really want to exit the Hob image creator?</b>"
         dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 9af19f6..d1557a8 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -619,6 +619,20 @@  class HobNotebook(gtk.VBox):
  
         self.tb.show()
 
+    def show_indicator_icon(self, title, number):
+        for i in range(len(self.tabbar.children)):
+            if self.tabbar.children[i]["toggled_page"] == -1:
+                continue
+            if self.tabbar.children[i]["title"] == title:
+                self.tabbar.show_indicator_icon(i, number)
+
+    def hide_indicator_icon(self, title):
+        for i in range(len(self.tabbar.children)):
+            if self.tabbar.children[i]["toggled_page"] == -1:
+                continue
+            if self.tabbar.children[i]["title"] == title:
+                self.tabbar.hide_indicator_icon(i)
+
     def tab_switched_cb(self, widget, page):
         self.notebook.set_current_page(page)
 
diff --git a/bitbake/lib/bb/ui/crumbs/runningbuild.py b/bitbake/lib/bb/ui/crumbs/runningbuild.py
index eedd8d9..ddac232 100644
--- a/bitbake/lib/bb/ui/crumbs/runningbuild.py
+++ b/bitbake/lib/bb/ui/crumbs/runningbuild.py
@@ -84,6 +84,9 @@  class RunningBuild (gobject.GObject):
           'task-started'   : (gobject.SIGNAL_RUN_LAST,
                               gobject.TYPE_NONE,
                               (gobject.TYPE_PYOBJECT,)),
+          'log-error'      : (gobject.SIGNAL_RUN_LAST,
+                              gobject.TYPE_NONE,
+                              ()),
           }
     pids_to_task = {}
     tasks_to_iter = {}
@@ -134,6 +137,7 @@  class RunningBuild (gobject.GObject):
             if event.levelno >= logging.ERROR:
                 icon = "dialog-error"
                 color = HobColors.ERROR
+                self.emit("log-error")
             elif event.levelno >= logging.WARNING:
                 icon = "dialog-warning"
                 color = HobColors.WARNING