[gnome-builder] codeui: add tree addin to render files with errors as squiggles
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] codeui: add tree addin to render files with errors as squiggles
- Date: Wed, 16 Jan 2019 20:54:38 +0000 (UTC)
commit 466fd434aa775936d52959f0dcb7d2530f6615ea
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 16 12:54:15 2019 -0800
codeui: add tree addin to render files with errors as squiggles
src/plugins/codeui/codeui-plugin.c | 5 ++
src/plugins/codeui/gbp-codeui-tree-addin.c | 89 ++++++++++++++++++++++++++++++
src/plugins/codeui/gbp-codeui-tree-addin.h | 31 +++++++++++
src/plugins/codeui/meson.build | 1 +
4 files changed, 126 insertions(+)
---
diff --git a/src/plugins/codeui/codeui-plugin.c b/src/plugins/codeui/codeui-plugin.c
index 099edef6f..ca837a85a 100644
--- a/src/plugins/codeui/codeui-plugin.c
+++ b/src/plugins/codeui/codeui-plugin.c
@@ -23,8 +23,10 @@
#include <libpeas/peas.h>
#include <libide-code.h>
#include <libide-foundry.h>
+#include <libide-tree.h>
#include "gbp-codeui-buffer-addin.h"
+#include "gbp-codeui-tree-addin.h"
_IDE_EXTERN void
_gbp_codeui_register_types (PeasObjectModule *module)
@@ -32,4 +34,7 @@ _gbp_codeui_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_BUFFER_ADDIN,
GBP_TYPE_CODEUI_BUFFER_ADDIN);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_TREE_ADDIN,
+ GBP_TYPE_CODEUI_TREE_ADDIN);
}
diff --git a/src/plugins/codeui/gbp-codeui-tree-addin.c b/src/plugins/codeui/gbp-codeui-tree-addin.c
new file mode 100644
index 000000000..6c1d106eb
--- /dev/null
+++ b/src/plugins/codeui/gbp-codeui-tree-addin.c
@@ -0,0 +1,89 @@
+/* gbp-codeui-tree-addin.c
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-codeui-tree-addin"
+
+#include "config.h"
+
+#include <libide-code.h>
+#include <libide-projects.h>
+#include <libide-tree.h>
+
+#include "gbp-codeui-tree-addin.h"
+
+struct _GbpCodeuiTreeAddin
+{
+ GObject parent_instance;
+};
+
+static void
+gbp_codeui_tree_addin_cell_data_func (IdeTreeAddin *addin,
+ IdeTreeNode *node,
+ GtkCellRenderer *cell)
+{
+ g_autoptr(IdeDiagnostics) diagnostics = NULL;
+ g_autoptr(IdeContext) context = NULL;
+ g_autoptr(GFile) file = NULL;
+ IdeDiagnosticsManager *diagmgr;
+ IdeProjectFile *project_file;
+ gboolean has_error = FALSE;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (GBP_IS_CODEUI_TREE_ADDIN (addin));
+ g_assert (IDE_IS_TREE_NODE (node));
+ g_assert (GTK_IS_CELL_RENDERER (cell));
+
+ if (!GTK_IS_CELL_RENDERER_TEXT (cell) ||
+ !ide_tree_node_holds (node, IDE_TYPE_PROJECT_FILE))
+ return;
+
+ project_file = ide_tree_node_get_item (node);
+ file = ide_project_file_ref_file (project_file);
+ context = ide_object_ref_context (IDE_OBJECT (project_file));
+ diagmgr = ide_diagnostics_manager_from_context (context);
+ diagnostics = ide_diagnostics_manager_get_diagnostics_for_file (diagmgr, file);
+
+ if (diagnostics != NULL)
+ {
+ if (ide_diagnostics_get_has_errors (diagnostics))
+ has_error = TRUE;
+ }
+
+ ide_tree_node_set_has_error (node, has_error);
+}
+
+static void
+tree_addin_iface_init (IdeTreeAddinInterface *iface)
+{
+ iface->cell_data_func = gbp_codeui_tree_addin_cell_data_func;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GbpCodeuiTreeAddin, gbp_codeui_tree_addin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_TREE_ADDIN, tree_addin_iface_init))
+
+static void
+gbp_codeui_tree_addin_class_init (GbpCodeuiTreeAddinClass *klass)
+{
+}
+
+static void
+gbp_codeui_tree_addin_init (GbpCodeuiTreeAddin *self)
+{
+}
diff --git a/src/plugins/codeui/gbp-codeui-tree-addin.h b/src/plugins/codeui/gbp-codeui-tree-addin.h
new file mode 100644
index 000000000..441bc3fd4
--- /dev/null
+++ b/src/plugins/codeui/gbp-codeui-tree-addin.h
@@ -0,0 +1,31 @@
+/* gbp-codeui-tree-addin.h
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_CODEUI_TREE_ADDIN (gbp_codeui_tree_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpCodeuiTreeAddin, gbp_codeui_tree_addin, GBP, CODEUI_TREE_ADDIN, GObject)
+
+G_END_DECLS
diff --git a/src/plugins/codeui/meson.build b/src/plugins/codeui/meson.build
index c374a40cb..751517423 100644
--- a/src/plugins/codeui/meson.build
+++ b/src/plugins/codeui/meson.build
@@ -1,6 +1,7 @@
plugins_sources += files([
'codeui-plugin.c',
'gbp-codeui-buffer-addin.c',
+ 'gbp-codeui-tree-addin.c',
])
plugin_codeui_resources = gnome.compile_resources(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]