Commit f9e172d8 authored by Christian Hergert's avatar Christian Hergert
Browse files

build-panel: update errors/warnings count

When we get a diagnostic from the build-result, update the label for
warnings and errors.
parent 17b7d331
......@@ -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
......
......@@ -266,6 +266,33 @@
<property name="top-attach">2</property>
</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>
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment