ide-build-panel.c 22.1 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 22
#include "config.h"

23
#include <glib/gi18n.h>
24
#include <ide.h>
25

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

32
struct _IdeBuildPanel
33
{
34
  DzlDockWidget        parent_instance;
35

36
  /* Owned references */
37
  GHashTable          *diags_hash;
38
  IdeBuildPipeline    *pipeline;
39
  DzlSignalGroup      *pipeline_signals;
40

41 42 43 44 45 46 47 48
  /* 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;
49
  GtkListStore        *diagnostics_store;
50
  GtkListBox          *stages_list_box;
51 52 53

  guint                error_count;
  guint                warning_count;
54 55
};

56
G_DEFINE_TYPE (IdeBuildPanel, ide_build_panel, DZL_TYPE_DOCK_WIDGET)
57

58 59 60 61 62
enum {
  COLUMN_DIAGNOSTIC,
  LAST_COLUMN
};

63 64 65 66 67 68 69
enum {
  PROP_0,
  PROP_PIPELINE,
  N_PROPS
};

static GParamSpec *properties [N_PROPS];
70

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
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);
}

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

  IDE_ENTRY;
98

99
  g_assert (IDE_IS_BUILD_PANEL (self));
100
  g_assert (diagnostic != NULL);
101
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
102

103 104 105 106
  severity = ide_diagnostic_get_severity (diagnostic);

  if (severity == IDE_DIAGNOSTIC_WARNING)
    {
107
      g_autofree gchar *label = NULL;
108

109
      self->warning_count++;
110

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

118
      self->error_count++;
119

120 121 122 123 124 125
      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? */
126 127
    }

128 129 130 131 132 133
  hash = ide_diagnostic_hash (diagnostic);

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

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

  IDE_EXIT;
146 147
}

148
static void
149
ide_build_panel_update_running_time (IdeBuildPanel *self)
150
{
151 152
  g_autofree gchar *text = NULL;

153
  g_assert (IDE_IS_BUILD_PANEL (self));
154

155
  if (self->pipeline != NULL)
156
    {
157 158
      IdeBuildManager *build_manager;
      IdeContext *context;
159 160
      GTimeSpan span;

161 162
      context = ide_widget_get_context (GTK_WIDGET (self));
      build_manager = ide_context_get_build_manager (context);
163

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

static void
173
ide_build_panel_started (IdeBuildPanel    *self,
174
                         IdeBuildPhase     phase,
175 176 177 178
                         IdeBuildPipeline *pipeline)
{
  IDE_ENTRY;

179
  g_assert (IDE_IS_BUILD_PANEL (self));
180 181
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));

182 183 184 185
  if (phase >= IDE_BUILD_PHASE_BUILD)
    {
      self->error_count = 0;
      self->warning_count = 0;
186

187 188
      set_warnings_label (self, _("Warnings"));
      set_errors_label (self, _("Errors"));
189

190 191 192
      gtk_list_store_clear (self->diagnostics_store);
      g_hash_table_remove_all (self->diags_hash);
    }
193 194 195 196

  IDE_EXIT;
}

197 198 199
static GtkWidget *
ide_build_panel_create_stage_row_cb (gpointer data,
                                     gpointer user_data)
200 201 202 203
{
  IdeBuildStage *stage = data;

  g_assert (IDE_IS_BUILD_STAGE (stage));
204
  g_assert (IDE_IS_BUILD_PANEL (user_data));
205

206
  return ide_build_stage_row_new (stage);
207 208
}

209
static void
210 211 212
ide_build_panel_bind_pipeline (IdeBuildPanel    *self,
                               IdeBuildPipeline *pipeline,
                               DzlSignalGroup   *signals)
213
{
214 215 216 217 218
  g_assert (IDE_IS_BUILD_PANEL (self));
  g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
  g_assert (G_IS_LIST_MODEL (pipeline));
  g_assert (self->pipeline == NULL);
  g_assert (DZL_IS_SIGNAL_GROUP (signals));
219

220
  self->pipeline = g_object_ref (pipeline);
221 222 223
  self->error_count = 0;
  self->warning_count = 0;

224 225 226 227 228
  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, "—");
229

230 231 232 233
  gtk_list_box_bind_model (self->stages_list_box,
                           G_LIST_MODEL (pipeline),
                           ide_build_panel_create_stage_row_cb,
                           self, NULL);
234

235
  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PIPELINE]);
236 237 238
}

static void
239 240
ide_build_panel_unbind_pipeline (IdeBuildPanel  *self,
                                 DzlSignalGroup *signals)
241
{
242
  g_return_if_fail (IDE_IS_BUILD_PANEL (self));
243
  g_return_if_fail (!self->pipeline || IDE_IS_BUILD_PIPELINE (self->pipeline));
244 245

  g_clear_object (&self->pipeline);
246

247 248 249 250 251 252 253 254 255
  if (!gtk_widget_in_destruction (GTK_WIDGET (self)))
    {
      g_hash_table_remove_all (self->diags_hash);
      gtk_list_store_clear (self->diagnostics_store);
      gtk_container_foreach (GTK_CONTAINER (self->stages_list_box),
                             (GtkCallback) gtk_widget_destroy,
                             NULL);
      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PIPELINE]);
    }
256 257 258
}

void
259
ide_build_panel_set_pipeline (IdeBuildPanel    *self,
260
                              IdeBuildPipeline *pipeline)
261
{
262
  g_return_if_fail (IDE_IS_BUILD_PANEL (self));
263
  g_return_if_fail (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline));
264

265 266
  if (self->pipeline_signals != NULL)
    dzl_signal_group_set_target (self->pipeline_signals, pipeline);
267 268
}

269
static void
270
ide_build_panel_diagnostic_activated (IdeBuildPanel     *self,
271 272 273
                                      GtkTreePath       *path,
                                      GtkTreeViewColumn *colun,
                                      GtkTreeView       *tree_view)
274
{
275
  g_autoptr(IdeDiagnostic) diagnostic = NULL;
276 277 278
  g_autoptr(IdeUri) uri = NULL;
  IdeSourceLocation *loc;
  IdeWorkbench *workbench;
279 280 281 282
  GtkTreeModel *model;
  GtkTreeIter iter;

  IDE_ENTRY;
283

284
  g_assert (IDE_IS_BUILD_PANEL (self));
285 286 287
  g_assert (path != NULL);
  g_assert (GTK_IS_TREE_VIEW_COLUMN (colun));
  g_assert (GTK_IS_TREE_VIEW (tree_view));
288

289 290 291 292
  model = gtk_tree_view_get_model (tree_view);
  if (!gtk_tree_model_get_iter (model, &iter, path))
    IDE_EXIT;

293 294 295 296
  gtk_tree_model_get (model, &iter,
                      COLUMN_DIAGNOSTIC, &diagnostic,
                      -1);

297 298 299
  if (diagnostic == NULL ||
      NULL == (loc = ide_diagnostic_get_location (diagnostic)) ||
      NULL == (uri = ide_source_location_get_uri (loc)))
300
    IDE_EXIT;
301 302 303

  workbench = ide_widget_get_workbench (GTK_WIDGET (self));

304 305 306 307
  ide_workbench_open_uri_async (workbench,
                                uri,
                                "editor",
                                IDE_WORKBENCH_OPEN_FLAGS_NONE,
308
                                NULL, NULL, NULL);
309

310
  IDE_EXIT;
311 312 313
}

static void
314
ide_build_panel_text_func (GtkCellLayout   *layout,
315 316 317 318
                           GtkCellRenderer *renderer,
                           GtkTreeModel    *model,
                           GtkTreeIter     *iter,
                           gpointer         user_data)
319
{
320
  IdeCellRendererFancy *fancy = (IdeCellRendererFancy *)renderer;
321
  g_autoptr(IdeDiagnostic) diagnostic = NULL;
322

323 324 325 326 327
  gtk_tree_model_get (model, iter,
                      COLUMN_DIAGNOSTIC, &diagnostic,
                      -1);

  if G_LIKELY (diagnostic != NULL)
328
    {
329
      g_autofree gchar *title = NULL;
330 331
      g_autofree gchar *name = NULL;
      IdeSourceLocation *location;
332
      const gchar *text;
333 334 335
      GFile *gfile = NULL;
      guint line = 0;
      guint column = 0;
336

337
      location = ide_diagnostic_get_location (diagnostic);
338

339
      if (location != NULL)
340
        {
341 342 343 344 345 346 347 348 349 350 351 352
          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);
                }
            }

353
        }
354

355 356
      title = g_strdup_printf ("%s:%u:%u", name ?: "", line + 1, column + 1);
      ide_cell_renderer_fancy_take_title (fancy, g_steal_pointer (&title));
357 358

      text = ide_diagnostic_get_text (diagnostic);
359
      ide_cell_renderer_fancy_set_body (fancy, text);
360
    }
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
  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;
376

377 378 379 380 381 382 383 384 385 386 387 388 389 390
  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);
391 392
}

393
static void
394
ide_build_panel_context_handler (GtkWidget  *widget,
395 396
                                 IdeContext *context)
{
397
  IdeBuildPanel *self = (IdeBuildPanel *)widget;
398 399 400 401
  IdeBuildManager *build_manager;

  IDE_ENTRY;

402
  g_assert (IDE_IS_BUILD_PANEL (self));
403 404 405 406 407 408 409
  g_assert (!context || IDE_IS_CONTEXT (context));

  if (context == NULL)
    IDE_EXIT;

  build_manager = ide_context_get_build_manager (context);

410 411 412 413 414
  g_signal_connect_object (build_manager,
                           "notify::message",
                           G_CALLBACK (ide_build_panel_notify_message),
                           self,
                           G_CONNECT_SWAPPED);
415 416 417

  g_signal_connect_object (build_manager,
                           "notify::running-time",
418
                           G_CALLBACK (ide_build_panel_update_running_time),
419 420 421 422 423
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-started",
424
                           G_CALLBACK (ide_build_panel_update_running_time),
425 426 427 428 429
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-finished",
430
                           G_CALLBACK (ide_build_panel_update_running_time),
431 432 433 434 435
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (build_manager,
                           "build-failed",
436
                           G_CALLBACK (ide_build_panel_update_running_time),
437 438 439 440 441 442
                           self,
                           G_CONNECT_SWAPPED);

  IDE_EXIT;
}

443 444 445 446 447 448 449 450 451 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
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;
}

515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
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);
}

540
static void
541
ide_build_panel_destroy (GtkWidget *widget)
542
{
543
  IdeBuildPanel *self = (IdeBuildPanel *)widget;
544

545 546
  if (self->pipeline_signals != NULL)
    dzl_signal_group_set_target (self->pipeline_signals, NULL);
547

548
  g_clear_pointer (&self->diags_hash, g_hash_table_unref);
549

550 551 552
  g_clear_object (&self->pipeline_signals);
  g_clear_object (&self->pipeline);

553
  GTK_WIDGET_CLASS (ide_build_panel_parent_class)->destroy (widget);
554 555 556
}

static void
557
ide_build_panel_get_property (GObject    *object,
558 559 560 561
                              guint       prop_id,
                              GValue     *value,
                              GParamSpec *pspec)
{
562
  IdeBuildPanel *self = IDE_BUILD_PANEL (object);
563 564 565

  switch (prop_id)
    {
566 567
    case PROP_PIPELINE:
      g_value_set_object (value, self->pipeline);
568 569 570
      break;

    default:
571
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
572 573 574 575
    }
}

static void
576
ide_build_panel_set_property (GObject      *object,
577 578 579 580
                              guint         prop_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
581
  IdeBuildPanel *self = IDE_BUILD_PANEL (object);
582 583 584

  switch (prop_id)
    {
585
    case PROP_PIPELINE:
586
      ide_build_panel_set_pipeline (self, g_value_get_object (value));
587 588 589
      break;

    default:
590
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
591 592 593 594
    }
}

static void
595
ide_build_panel_class_init (IdeBuildPanelClass *klass)
596 597 598 599
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

600
  widget_class->destroy = ide_build_panel_destroy;
601

602 603
  object_class->get_property = ide_build_panel_get_property;
  object_class->set_property = ide_build_panel_set_property;
604

605 606 607 608 609 610
  properties [PROP_PIPELINE] =
    g_param_spec_object ("pipeline",
                         NULL,
                         NULL,
                         IDE_TYPE_BUILD_PIPELINE,
                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
611

612
  g_object_class_install_properties (object_class, N_PROPS, properties);
613

614 615
  gtk_widget_class_set_template_from_resource (widget_class,
                                               "/org/gnome/builder/plugins/buildui/ide-build-panel.ui");
616
  gtk_widget_class_set_css_name (widget_class, "buildpanel");
617 618 619 620 621 622 623
  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);
624
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, diagnostics_store);
625
  gtk_widget_class_bind_template_child (widget_class, IdeBuildPanel, stages_list_box);
626

627
  g_type_ensure (IDE_TYPE_CELL_RENDERER_FANCY);
628
  g_type_ensure (IDE_TYPE_DIAGNOSTIC);
629
  g_type_ensure (IDE_TYPE_FANCY_TREE_VIEW);
630 631 632
}

static void
633
ide_build_panel_init (IdeBuildPanel *self)
634
{
635 636
  GtkTreeModel *filter;

637 638
  gtk_widget_init_template (GTK_WIDGET (self));

639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
  self->pipeline_signals = dzl_signal_group_new (IDE_TYPE_BUILD_PIPELINE);

  g_signal_connect_object (self->pipeline_signals,
                           "bind",
                           G_CALLBACK (ide_build_panel_bind_pipeline),
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (self->pipeline_signals,
                           "unbind",
                           G_CALLBACK (ide_build_panel_unbind_pipeline),
                           self,
                           G_CONNECT_SWAPPED);

  dzl_signal_group_connect_object (self->pipeline_signals,
                                   "diagnostic",
                                   G_CALLBACK (ide_build_panel_diagnostic),
                                   self,
                                   G_CONNECT_SWAPPED);

  dzl_signal_group_connect_object (self->pipeline_signals,
                                   "started",
                                   G_CALLBACK (ide_build_panel_started),
                                   self,
                                   G_CONNECT_SWAPPED);

665 666
  self->diags_hash = g_hash_table_new (NULL, NULL);

667
  g_object_set (self, "title", _("Build Issues"), NULL);
668

669
  ide_widget_set_context_handler (self, ide_build_panel_context_handler);
670

671
  g_signal_connect_swapped (self->warnings_tree_view,
672
                           "row-activated",
673
                           G_CALLBACK (ide_build_panel_diagnostic_activated),
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
                           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);
705

706
  ide_fancy_tree_view_set_data_func (IDE_FANCY_TREE_VIEW (self->errors_tree_view),
707
                                     ide_build_panel_text_func, self, NULL);
708 709 710 711 712

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