[gnome-builder/wip/libide] libide: add IdeBuffer:highlight-diagnostics gproperty



commit 4361ad73825d51c880cb47992c86339cebb1da9b
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 25 16:05:33 2015 -0800

    libide: add IdeBuffer:highlight-diagnostics gproperty
    
    A future commit will hook this property up to the diagnostician.

 libide/ide-buffer.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++---
 libide/ide-buffer.h |   21 +++++++++++----------
 2 files changed, 57 insertions(+), 13 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 8c44afb..5d3090a 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -25,10 +25,10 @@
 #include "ide-file.h"
 #include "ide-file-settings.h"
 
-struct _IdeBufferClass
+typedef struct _IdeBufferClass
 {
-  GtkSourceBufferClass parent_class;
-};
+  GtkSourceBufferClass parent;
+} IdeBufferClass;
 
 struct _IdeBuffer
 {
@@ -36,6 +36,8 @@ struct _IdeBuffer
 
   IdeContext      *context;
   IdeFile         *file;
+
+  guint            highlight_diagnostics : 1;
 };
 
 G_DEFINE_TYPE (IdeBuffer, ide_buffer, GTK_SOURCE_TYPE_BUFFER)
@@ -44,6 +46,7 @@ enum {
   PROP_0,
   PROP_CONTEXT,
   PROP_FILE,
+  PROP_HIGHLIGHT_DIAGNOSTICS,
   LAST_PROP
 };
 
@@ -113,6 +116,10 @@ ide_buffer_get_property (GObject    *object,
       g_value_set_object (value, ide_buffer_get_file (self));
       break;
 
+    case PROP_HIGHLIGHT_DIAGNOSTICS:
+      g_value_set_boolean (value, ide_buffer_get_highlight_diagnostics (self));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -136,6 +143,10 @@ ide_buffer_set_property (GObject      *object,
       ide_buffer_set_file (self, g_value_get_object (value));
       break;
 
+    case PROP_HIGHLIGHT_DIAGNOSTICS:
+      ide_buffer_set_highlight_diagnostics (self, g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -168,6 +179,15 @@ ide_buffer_class_init (IdeBufferClass *klass)
                          IDE_TYPE_FILE,
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (object_class, PROP_FILE, gParamSpecs [PROP_FILE]);
+
+  gParamSpecs [PROP_HIGHLIGHT_DIAGNOSTICS] =
+    g_param_spec_boolean ("highlight-diagnostics",
+                          _("Highlight Diagnostics"),
+                          _("If diagnostic warnings and errors should be highlighted."),
+                          FALSE,
+                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_HIGHLIGHT_DIAGNOSTICS,
+                                   gParamSpecs [PROP_HIGHLIGHT_DIAGNOSTICS]);
 }
 
 static void
@@ -259,3 +279,26 @@ ide_buffer_get_line_flags (IdeBuffer *self,
   /* TODO: Coordinate with Vcs */
   return IDE_BUFFER_LINE_FLAGS_ADDED;
 }
+
+gboolean
+ide_buffer_get_highlight_diagnostics (IdeBuffer *self)
+{
+  g_return_val_if_fail (IDE_IS_BUFFER (self), FALSE);
+
+  return self->highlight_diagnostics;
+}
+
+void
+ide_buffer_set_highlight_diagnostics (IdeBuffer *self,
+                                      gboolean   highlight_diagnostics)
+{
+  g_return_if_fail (IDE_IS_BUFFER (self));
+
+  highlight_diagnostics = !!highlight_diagnostics;
+
+  if (highlight_diagnostics != self->highlight_diagnostics)
+    {
+      self->highlight_diagnostics = highlight_diagnostics;
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_HIGHLIGHT_DIAGNOSTICS]);
+    }
+}
diff --git a/libide/ide-buffer.h b/libide/ide-buffer.h
index 3314b08..6bade54 100644
--- a/libide/ide-buffer.h
+++ b/libide/ide-buffer.h
@@ -33,8 +33,6 @@ G_BEGIN_DECLS
 #define IDE_IS_BUFFER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  IDE_TYPE_BUFFER))
 #define IDE_BUFFER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  IDE_TYPE_BUFFER, IdeBufferClass))
 
-typedef struct _IdeBufferClass  IdeBufferClass;
-
 typedef enum
 {
   IDE_BUFFER_LINE_FLAGS_NONE     = 0,
@@ -46,14 +44,17 @@ typedef enum
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeBuffer, g_object_unref)
 
-GType               ide_buffer_line_flags_get_type (void);
-GType               ide_buffer_get_type            (void);
-IdeContext         *ide_buffer_get_context         (IdeBuffer *self);
-IdeFile            *ide_buffer_get_file            (IdeBuffer *self);
-void                ide_buffer_set_file            (IdeBuffer *self,
-                                                    IdeFile   *file);
-IdeBufferLineFlags  ide_buffer_get_line_flags      (IdeBuffer *buffer,
-                                                    guint      line);
+GType               ide_buffer_line_flags_get_type       (void);
+GType               ide_buffer_get_type                  (void);
+IdeContext         *ide_buffer_get_context               (IdeBuffer *self);
+IdeFile            *ide_buffer_get_file                  (IdeBuffer *self);
+void                ide_buffer_set_file                  (IdeBuffer *self,
+                                                          IdeFile   *file);
+gboolean            ide_buffer_get_highlight_diagnostics (IdeBuffer *self);
+void                ide_buffer_set_highlight_diagnostics (IdeBuffer *self,
+                                                          gboolean   highlight_diagnostics);
+IdeBufferLineFlags  ide_buffer_get_line_flags            (IdeBuffer *buffer,
+                                                          guint      line);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]