[gnome-builder] build-panel: update errors/warnings count



commit f9e172d86469ce00ee5675cf80bb65966d7dd3f1
Author: Christian Hergert <chergert redhat com>
Date:   Fri Dec 18 04:24:43 2015 -0800

    build-panel: update errors/warnings count
    
    When we get a diagnostic from the build-result, update the label for
    warnings and errors.

 plugins/build-tools/gbp-build-panel.c  |   35 ++++++++++++++++++++++++++++++++
 plugins/build-tools/gbp-build-panel.ui |   29 +++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/plugins/build-tools/gbp-build-panel.c b/plugins/build-tools/gbp-build-panel.c
index c10b4ce..60d560a 100644
--- a/plugins/build-tools/gbp-build-panel.c
+++ b/plugins/build-tools/gbp-build-panel.c
@@ -43,8 +43,13 @@ struct _GbpBuildPanel
   GtkLabel         *device_label;
   GtkListBox       *devices;
   GtkPopover       *device_popover;
+  GtkLabel         *errors_label;
+  GtkLabel         *warnings_label;
 
   guint             running_time_source;
+
+  guint             error_count;
+  guint             warning_count;
 };
 
 G_DEFINE_TYPE (GbpBuildPanel, gbp_build_panel, GTK_TYPE_BIN)
@@ -140,12 +145,31 @@ gbp_build_panel_diagnostic (GbpBuildPanel  *self,
                             IdeDiagnostic  *diagnostic,
                             IdeBuildResult *result)
 {
+  IdeDiagnosticSeverity severity;
   GtkWidget *row;
+  gchar *str;
 
   g_assert (GBP_IS_BUILD_PANEL (self));
   g_assert (diagnostic != NULL);
   g_assert (IDE_IS_BUILD_RESULT (result));
 
+  severity = ide_diagnostic_get_severity (diagnostic);
+
+  if (severity == IDE_DIAGNOSTIC_WARNING)
+    {
+      self->warning_count++;
+      str = g_strdup_printf (ngettext ("%d warning", "%d warnings", self->warning_count), 
self->warning_count);
+      gtk_label_set_label (self->warnings_label, str);
+      g_free (str);
+    }
+  else if (severity == IDE_DIAGNOSTIC_ERROR)
+    {
+      self->error_count++;
+      str = g_strdup_printf (ngettext ("%d error", "%d errors", self->error_count), self->error_count);
+      gtk_label_set_label (self->errors_label, str);
+      g_free (str);
+    }
+
   row = g_object_new (GBP_TYPE_BUILD_PANEL_ROW,
                       "diagnostic", diagnostic,
                       "visible", TRUE,
@@ -189,6 +213,11 @@ gbp_build_panel_connect (GbpBuildPanel  *self,
   g_return_if_fail (self->result == NULL);
 
   self->result = g_object_ref (result);
+  self->error_count = 0;
+  self->warning_count = 0;
+
+  gtk_label_set_label (self->warnings_label, _("No warnings"));
+  gtk_label_set_label (self->errors_label, _("No errors"));
 
   egg_signal_group_set_target (self->signals, result);
   egg_binding_group_set_source (self->bindings, result);
@@ -230,6 +259,10 @@ gbp_build_panel_set_result (GbpBuildPanel  *self,
 
       if (result)
         gbp_build_panel_connect (self, result);
+
+      gtk_container_foreach (GTK_CONTAINER (self->diagnostics),
+                             (GtkCallback)gtk_widget_destroy,
+                             NULL);
     }
 }
 
@@ -402,9 +435,11 @@ gbp_build_panel_class_init (GbpBuildPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, device_popover);
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, devices);
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, diagnostics);
+  gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, errors_label);
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, running_time_label);
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, status_label);
   gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, status_revealer);
+  gtk_widget_class_bind_template_child (widget_class, GbpBuildPanel, warnings_label);
 }
 
 static void
diff --git a/plugins/build-tools/gbp-build-panel.ui b/plugins/build-tools/gbp-build-panel.ui
index e928112..3e8203a 100644
--- a/plugins/build-tools/gbp-build-panel.ui
+++ b/plugins/build-tools/gbp-build-panel.ui
@@ -267,6 +267,33 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkLabel">
+                        <property name="label" translatable="yes">Errors:</property>
+                        <property name="xalign">1.0</property>
+                        <property name="visible">true</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="errors_label">
+                        <property name="xalign">0.0</property>
+                        <property name="visible">true</property>
+                      </object>
+                      <packing>
+                        <property name="left-attach">1</property>
+                        <property name="top-attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkBox">
                         <property name="visible">true</property>
                         <property name="margin-top">6</property>
@@ -304,7 +331,7 @@
                       </object>
                       <packing>
                         <property name="left-attach">0</property>
-                        <property name="top-attach">3</property>
+                        <property name="top-attach">4</property>
                         <property name="width">2</property>
                       </packing>
                     </child>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]