[gnome-builder] libide: add IdeLineDiagnosticsGutterRenderer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add IdeLineDiagnosticsGutterRenderer
- Date: Mon, 23 Mar 2015 23:43:59 +0000 (UTC)
commit 39c980f604107dd3c5093b9273b12046caf3b764
Author: Christian Hergert <christian hergert me>
Date: Wed Feb 25 20:33:45 2015 -0800
libide: add IdeLineDiagnosticsGutterRenderer
This will use the IdeBuffer line information to render gutter marks such
as a warning, stop, or note icon.
libide/Makefile.am | 2 +
libide/ide-line-diagnostics-gutter-renderer.c | 78 +++++++++++++++++++++++++
libide/ide-line-diagnostics-gutter-renderer.h | 51 ++++++++++++++++
3 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index f4802e0..491c2ce 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -195,6 +195,8 @@ libide_1_0_la_SOURCES = \
libide/ide-internal.h \
libide/ide-line-change-gutter-renderer.c \
libide/ide-line-change-gutter-renderer.h \
+ libide/ide-line-diagnostics-gutter-renderer.c \
+ libide/ide-line-diagnostics-gutter-renderer.h \
libide/ide-search-reducer.c \
libide/ide-search-reducer.h \
libide/ide-source-snippet-completion-item.c \
diff --git a/libide/ide-line-diagnostics-gutter-renderer.c b/libide/ide-line-diagnostics-gutter-renderer.c
new file mode 100644
index 0000000..863c1f4
--- /dev/null
+++ b/libide/ide-line-diagnostics-gutter-renderer.c
@@ -0,0 +1,78 @@
+/* ide-line-diagnostics-gutter-renderer.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#include "ide-buffer.h"
+#include "ide-line-diagnostics-gutter-renderer.h"
+
+G_DEFINE_TYPE (IdeLineDiagnosticsGutterRenderer,
+ ide_line_diagnostics_gutter_renderer,
+ GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF)
+
+static void
+ide_line_diagnostics_gutter_renderer_query_data (GtkSourceGutterRenderer *renderer,
+ GtkTextIter *begin,
+ GtkTextIter *end,
+ GtkSourceGutterRendererState state)
+{
+ GtkTextBuffer *buffer;
+ IdeBufferLineFlags flags;
+ const gchar *icon_name = NULL;
+ guint line;
+
+ g_return_if_fail (IDE_IS_LINE_DIAGNOSTICS_GUTTER_RENDERER (renderer));
+ g_return_if_fail (begin);
+ g_return_if_fail (end);
+
+ buffer = gtk_text_iter_get_buffer (begin);
+
+ if (!IDE_IS_BUFFER (buffer))
+ return;
+
+ line = gtk_text_iter_get_line (begin);
+ flags = ide_buffer_get_line_flags (IDE_BUFFER (buffer), line);
+ flags &= IDE_BUFFER_LINE_FLAGS_DIAGNOSTICS_MASK;
+
+ if (flags == 0)
+ icon_name = NULL;
+ else if ((flags & IDE_BUFFER_LINE_FLAGS_ERROR) != 0)
+ icon_name = "process-stop-symbolic";
+ else if ((flags & IDE_BUFFER_LINE_FLAGS_WARNING) != 0)
+ icon_name = "dialog-warning-symbolic";
+ else if ((flags & IDE_BUFFER_LINE_FLAGS_NOTE) != 0)
+ icon_name = "dialog-information-symbolic";
+ else
+ icon_name = NULL;
+
+ if (icon_name)
+ g_object_set (renderer, "icon-name", icon_name, NULL);
+ else
+ g_object_set (renderer, "pixbuf", NULL, NULL);
+}
+
+static void
+ide_line_diagnostics_gutter_renderer_class_init (IdeLineDiagnosticsGutterRendererClass *klass)
+{
+ GtkSourceGutterRendererClass *renderer_class = GTK_SOURCE_GUTTER_RENDERER_CLASS (klass);
+
+ renderer_class->query_data = ide_line_diagnostics_gutter_renderer_query_data;
+}
+
+static void
+ide_line_diagnostics_gutter_renderer_init (IdeLineDiagnosticsGutterRenderer *self)
+{
+}
diff --git a/libide/ide-line-diagnostics-gutter-renderer.h b/libide/ide-line-diagnostics-gutter-renderer.h
new file mode 100644
index 0000000..2189d24
--- /dev/null
+++ b/libide/ide-line-diagnostics-gutter-renderer.h
@@ -0,0 +1,51 @@
+/* ide-line-diagnostics-gutter-renderer.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#ifndef IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_H
+#define IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_H
+
+#include <gtksourceview/gtksource.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER
(ide_line_diagnostics_gutter_renderer_get_type())
+#define IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER, IdeLineDiagnosticsGutterRenderer))
+#define IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER, IdeLineDiagnosticsGutterRenderer const))
+#define IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER, IdeLineDiagnosticsGutterRendererClass))
+#define IDE_IS_LINE_DIAGNOSTICS_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER))
+#define IDE_IS_LINE_DIAGNOSTICS_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER))
+#define IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_LINE_DIAGNOSTICS_GUTTER_RENDERER, IdeLineDiagnosticsGutterRendererClass))
+
+typedef struct _IdeLineDiagnosticsGutterRenderer IdeLineDiagnosticsGutterRenderer;
+typedef struct _IdeLineDiagnosticsGutterRendererClass IdeLineDiagnosticsGutterRendererClass;
+
+struct _IdeLineDiagnosticsGutterRenderer
+{
+ GtkSourceGutterRendererPixbuf parent;
+};
+
+struct _IdeLineDiagnosticsGutterRendererClass
+{
+ GtkSourceGutterRendererPixbufClass parent_class;
+};
+
+GType ide_line_diagnostics_gutter_renderer_get_type (void);
+
+G_END_DECLS
+
+#endif /* IDE_LINE_DIAGNOSTICS_GUTTER_RENDERER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]