ide-build-panel.c 21.2 KB
Newer Older
1
/* ide-build-panel.c
2
 *
3
 * Copyright © 2015 Christian Hergert <chergert@redhat.com>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

19 20
#define G_LOG_DOMAIN "ide-build-panel"

21
#include <glib/gi18n.h>
22
#include <ide.h>
23

24
#include "buildsystem/ide-build-stage-private.h"
25
#include "buildui/ide-build-panel.h"
26
#include "buildui/ide-build-stage-row.h"
27 28
#include "util/ide-fancy-tree-view.h"
#include "util/ide-cell-renderer-fancy.h"
29

30
struct _IdeBuildPanel
31
{
32
  DzlDockWidget        parent_instance;
33

34
  /* Owned references */
35
  GHashTable          *diags_hash;
36
  IdeBuildPipeline    *pipeline;
37

38 39 40 41 42 43 44 45
  /* Template widgets */
  GtkLabel            *build_status_label;
  GtkLabel            *time_completed_label;
  GtkNotebook         *notebook;
  GtkScrolledWindow   *errors_page;
  IdeFancyTreeView    *errors_tree_view;
  GtkScrolledWindow   *warnings_page;
  IdeFancyTreeView    *warnings_tree_view;
46
  GtkListStore        *diagnostics_store;
47
  GtkListBox          *stages_list_box;
48 49 50

  guint                error_count;
  guint                warning_count;
51 52
};

53
G_DEFINE_TYPE (IdeBuildPanel, ide_build_panel, DZL_TYPE_DOCK_WIDGET)
54

55 56 57 58 59
enum {
  COLUMN_DIAGNOSTIC,
  LAST_COLUMN
};

60 61 62 63 64 65 66
enum {
  PROP_0,
  PROP_PIPELINE,
  N_PROPS
};

static GParamSpec *properties [N_PROPS];
67

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
static void
set_warnings_label (IdeBuildPanel *self,
                    const gchar   *label)
{
  gtk_container_child_set (GTK_CONTAINER (self->notebook), GTK_WIDGET (self->warnings_page),
                           "tab-label", label,
                           NULL);
}

static void
set_errors_label (IdeBuildPanel *self,
                  const gchar   *label)
{
  gtk_container_child_set (GTK_CONTAINER (self->notebook), GTK_WIDGET (self->errors_page),
                           "tab-label", label,
                           NULL);
}

86
static void
87
ide_build_panel_diagnostic (IdeBuildPanel    *self,
88 89
                            IdeDiagnostic    *diagnostic,
                            IdeBuildPipeline *pipeline)
90
{
91
  IdeDiagnosticSeverity severity;
92 93 94
  guint hash;

  IDE_ENTRY;
95

96
  g_assert (IDE_IS_BUILD_PANEL (self));
97
  g_assert (diagnostic != NULL);
98
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
99

100 101 102 103
  severity = ide_diagnostic_get_severity (diagnostic);

  if (severity == IDE_DIAGNOSTIC_WARNING)
    {
104
      g_autofree gchar *label = NULL;
105

106
      self->warning_count++;
107

108 109
      label = g_strdup_printf ("%s (%u)", _("Warnings"), self->warning_count);
      set_warnings_label (self, label);
110
    }
111
  else if (severity == IDE_DIAGNOSTIC_ERROR || severity == IDE_DIAGNOSTIC_FATAL)
112
    {
113
      g_autofree gchar *label = NULL;
114

115
      self->error_count++;
116

117 118 119 120 121 122
      label = g_strdup_printf ("%s (%u)", _("Errors"), self->error_count);
      set_errors_label (self, label);
    }
  else
    {
      /* TODO: Figure out design for "Others" Column like Notes? */
123 124
    }

125 126 127 128 129 130
  hash = ide_diagnostic_hash (diagnostic);

  if (g_hash_table_insert (self->diags_hash, GUINT_TO_POINTER (hash), NULL))
    {
      GtkTreeIter iter;

131 132 133 134 135 136
      dzl_gtk_list_store_insert_sorted (self->diagnostics_store,
                                        &iter,
                                        diagnostic,
                                        COLUMN_DIAGNOSTIC,
                                        (GCompareDataFunc)ide_diagnostic_compare,
                                        NULL);
137
      gtk_list_store_set (self->diagnostics_store, &iter,
138
                          COLUMN_DIAGNOSTIC, diagnostic,
139 140 141 142
                          -1);
    }

  IDE_EXIT;
143 144
}

145
static void
146
ide_build_panel_update_running_time (IdeBuildPanel *self)
147
{
148 149
  g_autofree gchar *text = NULL;

150
  g_assert (IDE_IS_BUILD_PANEL (self));
151

152
  if (self->pipeline != NULL)
153
    {
154 155
      IdeBuildManager *build_manager;
      IdeContext *context;
156 157
      GTimeSpan span;

158 159
      context = ide_widget_get_context (GTK_WIDGET (self));
      build_manager = ide_context_get_build_manager (context);
160

161
      span = ide_build_manager_get_running_time (build_manager);
162
      text = dzl_g_time_span_to_label (span);
163
      gtk_label_set_label (self->time_completed_label, text);
164
    }
165 166
  else
    gtk_label_set_label (self->time_completed_label, "—");
167 168 169
}

static void
170
ide_build_panel_started (IdeBuildPanel    *self,
171
                         IdeBuildPhase     phase,
172 173 174 175
                         IdeBuildPipeline *pipeline)
{
  IDE_ENTRY;

176
  g_assert (IDE_IS_BUILD_PANEL (self));
177 178
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));

179 180 181 182
  if (phase >= IDE_BUILD_PHASE_BUILD)
    {
      self->error_count = 0;
      self->warning_count = 0;
183

184 185
      set_warnings_label (self, _("Warnings"));
      set_errors_label (self, _("Errors"));
186

187 188 189
      gtk_list_store_clear (self->diagnostics_store);
      g_hash_table_remove_all (self->diags_hash);
    }
190 191 192 193

  IDE_EXIT;
}

194 195 196 197 198 199 200 201 202 203 204 205 206 207
static void
ide_build_panel_connect_stage_cb (gpointer data,
                                  gpointer user_data)
{
  IdeBuildStage *stage = data;
  IdeBuildPanel *self = user_data;

  g_assert (IDE_IS_BUILD_STAGE (stage));
  g_assert (IDE_IS_BUILD_PANEL (self));

  gtk_container_add (GTK_CONTAINER (self->stages_list_box),
                     ide_build_stage_row_new (stage));
}

208
static void
209
ide_build_panel_connect (IdeBuildPanel    *self,
210
                         IdeBuildPipeline *pipeline)
211
{
212
  g_return_if_fail (IDE_IS_BUILD_PANEL (self));
213 214
  g_return_if_fail (IDE_IS_BUILD_PIPELINE (pipeline));
  g_return_if_fail (self->pipeline == NULL);
215

216
  self->pipeline = g_object_ref (pipeline);
217 218 219
  self->error_count = 0;
  self->warning_count = 0;

220 221 222 223 224
  set_warnings_label (self, _("Warnings"));
  set_errors_label (self, _("Errors"));

  gtk_label_set_label (self->time_completed_label, "—");
  gtk_label_set_label (self->build_status_label, "—");
225

226 227
  g_signal_connect_object (pipeline,
                           "diagnostic",
228
                           G_CALLBACK (ide_build_panel_diagnostic),
229 230 231 232 233
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (pipeline,
                           "started",
234
                           G_CALLBACK (ide_build_panel_started),
235 236
                           self,
                           G_CONNECT_SWAPPED);
237 238 239 240

  ide_build_pipeline_foreach_stage (pipeline,
                                    ide_build_panel_connect_stage_cb,
                                    self);
241 242 243
}

static void
244
ide_build_panel_disconnect (IdeBuildPanel *self)
245
{
246
  g_return_if_fail (IDE_IS_BUILD_PANEL (self));
247 248 249
  g_return_if_fail (IDE_IS_BUILD_PIPELINE (self->pipeline));

  g_signal_handlers_disconnect_by_func (self->pipeline,
250
                                        G_CALLBACK (ide_build_panel_diagnostic),
251 252
                                        self);
  g_clear_object (&self->pipeline);
253

254 255
  g_hash_table_remove_all (self->diags_hash);
  gtk_list_store_clear (self->diagnostics_store);
256 257 258
  gtk_container_foreach (GTK_CONTAINER (self->stages_list_box),
                         (GtkCallback) gtk_widget_destroy,
                         NULL);
259 260 261
}

void
262
ide_build_panel_set_pipeline (IdeBuildPanel    *self,
263
                              IdeBuildPipeline *pipeline)
264
{
265
  g_return_if_fail (IDE_IS_BUILD_PANEL (self));
266
  g_return_if_fail (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline));
267

268
  if (pipeline != self->pipeline)
269
    {
270
      if (self->pipeline)
271
        ide_build_panel_disconnect (self);
272

273
      if (pipeline)
274
        ide_build_panel_connect (self, pipeline);
275 276 277
    }
}

278
static void
279
ide_build_panel_diagnostic_activated (IdeBuildPanel     *self,
280 281 282
                                      GtkTreePath       *path,
                                      GtkTreeViewColumn *colun,
                                      GtkTreeView       *tree_view)
283
{
284
  g_autoptr(IdeDiagnostic) diagnostic = NULL;
285 286 287
  g_autoptr(IdeUri) uri = NULL;
  IdeSourceLocation *loc;
  IdeWorkbench *workbench;
288 289 290 291
  GtkTreeModel *model;
  GtkTreeIter iter;

  IDE_ENTRY;
292

293
  g_assert (IDE_IS_BUILD_PANEL (self));
294 295 296
  g_assert (path != NULL);
  g_assert (GTK_IS_TREE_VIEW_COLUMN (colun));
  g_assert (GTK_IS_TREE_VIEW (tree_view));
297

298 299 300 301
  model = gtk_tree_view_get_model (tree_view);
  if (!gtk_tree_model_get_iter (model, &iter, path))
    IDE_EXIT;

302 303 304 305
  gtk_tree_model_get (model, &iter,
                      COLUMN_DIAGNOSTIC, &diagnostic,
                      -1);

306 307 308
  if (diagnostic == NULL ||
      NULL == (loc = ide_diagnostic_get_location (diagnostic)) ||
      NULL == (uri = ide_source_location_get_uri (loc)))
309
    IDE_EXIT;
310 311 312

  workbench = ide_widget_get_workbench (GTK_WIDGET (self));

313 314 315 316
  ide_workbench_open_uri_async (workbench,
                                uri,
                                "editor",
                                IDE_WORKBENCH_OPEN_FLAGS_NONE,
317
                                NULL, NULL, NULL);
318

319
  IDE_EXIT;
320 321 322
}

static void
323
ide_build_panel_text_func (GtkCellLayout   *layout,
324 325 326 327
                           GtkCellRenderer *renderer,
                           GtkTreeModel    *model,
                           GtkTreeIter     *iter,
                           gpointer         user_data)
328
{
329
  IdeCellRendererFancy *fancy = (IdeCellRendererFancy *)renderer;
330
  g_autoptr(IdeDiagnostic) diagnostic = NULL;
331

332 333 334 335 336
  gtk_tree_model_get (model, iter,
                      COLUMN_DIAGNOSTIC, &diagnostic,
                      -1);

  if G_LIKELY (diagnostic != NULL)
337
    {
338
      g_autofree gchar *title = NULL;
339 340
      g_autofree gchar *name = NULL;
      IdeSourceLocation *location;
341
      const gchar *text;
342 343 344
      GFile *gfile = NULL;
      guint line = 0;
      guint column = 0;
345

346
      location = ide_diagnostic_get_location (diagnostic);
347

348
      if (location != NULL)
349
        {
350 351 352 353 354 355 356 357 358 359 360 361
          IdeFile *file;

          if (NULL != (file = ide_source_location_get_file (location)))
            {
              if (NULL != (gfile = ide_file_get_file (file)))
                {
                  name = g_file_get_basename (gfile);
                  line = ide_source_location_get_line (location);
                  column = ide_source_location_get_line_offset (location);
                }
            }

362
        }
363

364 365
      title = g_strdup_printf ("%s:%u:%u", name ?: "", line + 1, column + 1);
      ide_cell_renderer_fancy_take_title (fancy, g_steal_pointer (&title));
366 367

      text = ide_diagnostic_get_text (diagnostic);
368
      ide_cell_renderer_fancy_set_body (fancy, text);
369
    }
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
  else
    {
      ide_cell_renderer_fancy_set_title (fancy, NULL);
      ide_cell_renderer_fancy_set_body (fancy, NULL);
    }
}

static void
ide_build_panel_notify_message (IdeBuildPanel   *self,
                                GParamSpec      *pspec,
                                IdeBuildManager *build_manager)
{
  g_autofree gchar *message = NULL;
  IdeBuildPipeline *pipeline;
  GtkStyleContext *style;
385

386 387 388 389 390 391 392 393 394 395 396 397 398 399
  g_assert (IDE_IS_BUILD_PANEL (self));
  g_assert (IDE_IS_BUILD_MANAGER (build_manager));

  message = ide_build_manager_get_message (build_manager);
  pipeline = ide_build_manager_get_pipeline (build_manager);

  gtk_label_set_label (self->build_status_label, message);

  style = gtk_widget_get_style_context (GTK_WIDGET (self->build_status_label));

  if (ide_build_pipeline_get_phase (pipeline) == IDE_BUILD_PHASE_FAILED)
    gtk_style_context_add_class (style, GTK_STYLE_CLASS_ERROR);
  else
    gtk_style_context_remove_class (style, GTK_STYLE_CLASS_ERROR);
400 401
}

402
static void
403
ide_build_panel_context_handler (GtkWidget  *widget,
404 405
                                 IdeContext *context)
{
406
  IdeBuildPanel *self = (IdeBuildPanel *)widget;
407 408 409 410
  IdeBuildManager *build_manager;

  IDE_ENTRY;

411
  g_assert (IDE_IS_BUILD_PANEL (self));
412 413 414 415 416 417 418
  g_assert (!context || IDE_IS_CONTEXT (context));

  if (context == NULL)
    IDE_EXIT;

  build_manager = ide_context_get_build_manager (context);

419 420 421 422 423
  g_signal_connect_object (build_manager,
                           "notify::message",
                           G_CALLBACK (ide_build_panel_notify_message),
                           self,
                           G_CONNECT_SWAPPED);
424 425 426

  g_signal_connect_object (build_manager,
                           "notify::running-time",
427
                           G_CALLBACK (ide_build_panel_update_running_time),
428 429 430 431 432
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-started",
433
                           G_CALLBACK (ide_build_panel_update_running_time),
434 435 436 437 438
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-finished",
439
                           G_CALLBACK (ide_build_panel_update_running_time),
440 441 442 443 444
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-failed",
445
                           G_CALLBACK (ide_build_panel_update_running_time),
446 447 448 449 450 451
                           self,
                           G_CONNECT_SWAPPED);

  IDE_EXIT;
}

452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
static gboolean
ide_build_panel_diagnostic_tooltip (IdeBuildPanel *self,
                                    gint           x,
                                    gint           y,
                                    gboolean       keyboard_mode,
                                    GtkTooltip    *tooltip,
                                    GtkTreeView   *tree_view)
{
  GtkTreeModel *model = NULL;
  GtkTreeIter iter;

  g_assert (IDE_IS_BUILD_PANEL (self));
  g_assert (GTK_IS_TOOLTIP (tooltip));
  g_assert (GTK_IS_TREE_VIEW (tree_view));

  if (gtk_tree_view_get_tooltip_context (tree_view, &x, &y, keyboard_mode, &model, NULL, &iter))
    {
      g_autoptr(IdeDiagnostic) diag = NULL;

      gtk_tree_model_get (model, &iter,
                          COLUMN_DIAGNOSTIC, &diag,
                          -1);

      if (diag != NULL)
        {
          g_autofree gchar *text = ide_diagnostic_get_text_for_display (diag);

          gtk_tooltip_set_text (tooltip, text);

          return TRUE;
        }
    }

  return FALSE;
}

static gboolean
diagnostic_is_warning (GtkTreeModel *model,
                       GtkTreeIter  *iter,
                       gpointer      user_data)
{
  g_autoptr(IdeDiagnostic) diag = NULL;
  IdeDiagnosticSeverity severity = 0;

  gtk_tree_model_get (model, iter,
                      COLUMN_DIAGNOSTIC, &diag,
                      -1);

  if (diag != NULL)
    severity = ide_diagnostic_get_severity (diag);

  return severity <= IDE_DIAGNOSTIC_WARNING;
}

static gboolean
diagnostic_is_error (GtkTreeModel *model,
                     GtkTreeIter  *iter,
                     gpointer      user_data)
{
  g_autoptr(IdeDiagnostic) diag = NULL;
  IdeDiagnosticSeverity severity = 0;

  gtk_tree_model_get (model, iter,
                      COLUMN_DIAGNOSTIC, &diag,
                      -1);

  if (diag != NULL)
    severity = ide_diagnostic_get_severity (diag);

  return severity > IDE_DIAGNOSTIC_WARNING;
}

524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
static void
ide_build_panel_stage_row_activated (IdeBuildPanel    *self,
                                     IdeBuildStageRow *row,
                                     GtkListBox       *list_box)
{
  IdeBuildStage *stage;
  IdeBuildPhase phase;

  g_assert (IDE_IS_BUILD_PANEL (self));
  g_assert (IDE_IS_BUILD_STAGE_ROW (row));
  g_assert (GTK_IS_LIST_BOX (list_box));

  if (self->pipeline == NULL)
    return;

  stage = ide_build_stage_row_get_stage (row);
  g_assert (IDE_IS_BUILD_STAGE (stage));

  phase = _ide_build_stage_get_phase (stage);

  ide_build_pipeline_build_async (self->pipeline,
                                  phase & IDE_BUILD_PHASE_MASK,
                                  NULL, NULL, NULL);
}

549
static void
550
ide_build_panel_destroy (GtkWidget *widget)
551
{
552
  IdeBuildPanel *self = (IdeBuildPanel *)widget;
553

554
  if (self->pipeline != NULL)
555
    ide_build_panel_disconnect (self);
556

557
  g_clear_pointer (&self->diags_hash, g_hash_table_unref);
558

559
  GTK_WIDGET_CLASS (ide_build_panel_parent_class)->destroy (widget);
560 561 562
}

static void
563
ide_build_panel_get_property (GObject    *object,
564 565 566 567
                              guint       prop_id,
                              GValue     *value,
                              GParamSpec *pspec)
{
568
  IdeBuildPanel *self = IDE_BUILD_PANEL (object);
569 570 571

  switch (prop_id)
    {
572 573
    case PROP_PIPELINE:
      g_value_set_object (value, self->pipeline);
574 575 576
      break;

    default:
577
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
578 579 580 581
    }
}

static void
582
ide_build_panel_set_property (GObject      *object,
583 584 585 586
                              guint         prop_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
587
  IdeBuildPanel *self = IDE_BUILD_PANEL (object);
588 589 590

  switch (prop_id)
    {
591
    case PROP_PIPELINE:
592
      ide_build_panel_set_pipeline (self, g_value_get_object (value));
593 594 595
      break;

    default:
596
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
597 598 599 600
    }
}

static void
601
ide_build_panel_class_init (IdeBuildPanelClass *klass)
602 603 604 605
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

606
  widget_class->destroy = ide_build_panel_destroy;
607

608 609
  object_class->get_property = ide_build_panel_get_property;
  object_class->set_property = ide_build_panel_set_property;
610

611 612 613 614 615 616
  properties [PROP_PIPELINE] =
    g_param_spec_object ("pipeline",
                         NULL,
                         NULL,
                         IDE_TYPE_BUILD_PIPELINE,
                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
617

618
  g_object_class_install_properties (object_class, N_PROPS, properties);
619

620 621
  gtk_widget_class_set_template_from_resource (widget_class,
                                               "/org/gnome/builder/plugins/buildui/ide-build-panel.ui");
622
  gtk_widget_class_set_css_name (widget_class, "buildpanel");
623 624 625 626 627 628 629
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, build_status_label);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, time_completed_label);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, notebook);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, errors_page);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, errors_tree_view);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, warnings_page);
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, warnings_tree_view);
630
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, diagnostics_store);
631
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, stages_list_box);
632

633
  g_type_ensure (IDE_TYPE_CELL_RENDERER_FANCY);
634
  g_type_ensure (IDE_TYPE_DIAGNOSTIC);
635
  g_type_ensure (IDE_TYPE_FANCY_TREE_VIEW);
636 637 638
}

static void
639
ide_build_panel_init (IdeBuildPanel *self)
640
{
641 642
  GtkTreeModel *filter;

643 644
  gtk_widget_init_template (GTK_WIDGET (self));

645 646
  self->diags_hash = g_hash_table_new (NULL, NULL);

647
  g_object_set (self, "title", _("Build Issues"), NULL);
648

649
  ide_widget_set_context_handler (self, ide_build_panel_context_handler);
650

651
  g_signal_connect_swapped (self->warnings_tree_view,
652
                           "row-activated",
653
                           G_CALLBACK (ide_build_panel_diagnostic_activated),
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
                           self);

  g_signal_connect_swapped (self->warnings_tree_view,
                           "query-tooltip",
                           G_CALLBACK (ide_build_panel_diagnostic_tooltip),
                           self);

  g_signal_connect_swapped (self->errors_tree_view,
                           "row-activated",
                           G_CALLBACK (ide_build_panel_diagnostic_activated),
                           self);

  g_signal_connect_swapped (self->errors_tree_view,
                           "query-tooltip",
                           G_CALLBACK (ide_build_panel_diagnostic_tooltip),
                           self);

  filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (self->diagnostics_store), NULL);
  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
                                          diagnostic_is_warning, NULL, NULL);
  gtk_tree_view_set_model (GTK_TREE_VIEW (self->warnings_tree_view), GTK_TREE_MODEL (filter));
  g_object_unref (filter);

  filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (self->diagnostics_store), NULL);
  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
                                          diagnostic_is_error, NULL, NULL);
  gtk_tree_view_set_model (GTK_TREE_VIEW (self->errors_tree_view), GTK_TREE_MODEL (filter));
  g_object_unref (filter);

  ide_fancy_tree_view_set_data_func (IDE_FANCY_TREE_VIEW (self->warnings_tree_view),
                                     ide_build_panel_text_func, self, NULL);
685

686
  ide_fancy_tree_view_set_data_func (IDE_FANCY_TREE_VIEW (self->errors_tree_view),
687
                                     ide_build_panel_text_func, self, NULL);
688 689 690 691 692

  g_signal_connect_swapped (self->stages_list_box,
                            "row-activated",
                            G_CALLBACK (ide_build_panel_stage_row_activated),
                            self);
693
}