[gnome-builder/wip/gtk4-port: 734/1774] libide/sourceview: add back IdeGutter interface




commit c247c42c98ec6ee4a9ec6c3e870a026d3efe5236
Author: Christian Hergert <chergert redhat com>
Date:   Tue Apr 26 15:46:45 2022 -0700

    libide/sourceview: add back IdeGutter interface
    
    We will continue to use this, at least for the porting effort to make
    things a bit easier to manage.

 src/libide/sourceview/ide-gutter.c        | 152 ++++++++++++++++++++++++++++++
 src/libide/sourceview/ide-gutter.h        |  68 +++++++++++++
 src/libide/sourceview/libide-sourceview.h |   1 +
 src/libide/sourceview/meson.build         |   2 +
 4 files changed, 223 insertions(+)
---
diff --git a/src/libide/sourceview/ide-gutter.c b/src/libide/sourceview/ide-gutter.c
new file mode 100644
index 000000000..d54449909
--- /dev/null
+++ b/src/libide/sourceview/ide-gutter.c
@@ -0,0 +1,152 @@
+/* ide-gutter.c
+ *
+ * Copyright 2018-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 "ide-gutter"
+
+#include "config.h"
+
+#include "ide-gutter.h"
+
+G_DEFINE_INTERFACE (IdeGutter, ide_gutter, GTK_SOURCE_TYPE_GUTTER_RENDERER)
+
+enum {
+  STYLE_CHANGED,
+  N_SIGNALS
+};
+
+static guint signals [N_SIGNALS];
+
+static void
+ide_gutter_default_init (IdeGutterInterface *iface)
+{
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boolean ("show-line-changes",
+                                                             "Show Line Changes",
+                                                             "If line changes should be displayed",
+                                                             FALSE,
+                                                             (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boolean ("show-line-diagnostics",
+                                                             "Show Line Diagnostics",
+                                                             "If line diagnostics should be displayed",
+                                                             FALSE,
+                                                             (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boolean ("show-line-numbers",
+                                                             "Show Line Numbers",
+                                                             "If line numbers should be displayed",
+                                                             FALSE,
+                                                             (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boolean ("show-relative-line-numbers",
+                                                             "Show Relative Line Numbers",
+                                                             "If line numbers should be displayed relative 
to the cursor line",
+                                                             FALSE,
+                                                             (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+  signals [STYLE_CHANGED] =
+    g_signal_new ("style-changed",
+                  G_TYPE_FROM_INTERFACE (iface),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (IdeGutterInterface, style_changed),
+                  NULL,
+                  NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+}
+
+void
+ide_gutter_style_changed (IdeGutter *self)
+{
+  g_return_if_fail (IDE_IS_GUTTER (self));
+
+  g_signal_emit (self, signals [STYLE_CHANGED], 0);
+}
+
+gboolean
+ide_gutter_get_show_line_changes (IdeGutter *self)
+{
+  gboolean ret;
+  g_object_get (self, "show-line-changes", &ret, NULL);
+  return ret;
+}
+
+gboolean
+ide_gutter_get_show_line_numbers (IdeGutter *self)
+{
+  gboolean ret;
+  g_object_get (self, "show-line-numbers", &ret, NULL);
+  return ret;
+}
+
+gboolean
+ide_gutter_get_show_relative_line_numbers (IdeGutter *self)
+{
+  gboolean ret;
+  g_object_get (self, "show-relative-line-numbers", &ret, NULL);
+  return ret;
+}
+
+gboolean
+ide_gutter_get_show_line_diagnostics (IdeGutter *self)
+{
+  gboolean ret;
+  g_object_get (self, "show-line-diagnostics", &ret, NULL);
+  return ret;
+}
+
+void
+ide_gutter_set_show_line_changes (IdeGutter *self,
+                                  gboolean   show_line_changes)
+{
+  g_return_if_fail (IDE_IS_GUTTER (self));
+
+  g_object_set (self, "show-line-changes", show_line_changes, NULL);
+}
+
+void
+ide_gutter_set_show_line_numbers (IdeGutter *self,
+                                  gboolean   show_line_numbers)
+{
+  g_return_if_fail (IDE_IS_GUTTER (self));
+
+  g_object_set (self, "show-line-numbers", show_line_numbers, NULL);
+}
+
+void
+ide_gutter_set_show_relative_line_numbers (IdeGutter *self,
+                                           gboolean   show_relative_line_numbers)
+{
+  g_return_if_fail (IDE_IS_GUTTER (self));
+
+  g_object_set (self, "show-relative-line-numbers", show_relative_line_numbers, NULL);
+}
+
+void
+ide_gutter_set_show_line_diagnostics (IdeGutter *self,
+                                      gboolean   show_line_diagnostics)
+{
+  g_return_if_fail (IDE_IS_GUTTER (self));
+
+  g_object_set (self, "show-line-diagnostics", show_line_diagnostics, NULL);
+}
diff --git a/src/libide/sourceview/ide-gutter.h b/src/libide/sourceview/ide-gutter.h
new file mode 100644
index 000000000..80cc52b97
--- /dev/null
+++ b/src/libide/sourceview/ide-gutter.h
@@ -0,0 +1,68 @@
+/* ide-gutter.h
+ *
+ * Copyright 2018-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
+
+#if !defined (IDE_SOURCEVIEW_INSIDE) && !defined (IDE_SOURCEVIEW_COMPILATION)
+# error "Only <libide-sourceview.h> can be included directly."
+#endif
+
+#include <gtksourceview/gtksource.h>
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_GUTTER (ide_gutter_get_type())
+
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (IdeGutter, ide_gutter, IDE, GUTTER, GtkSourceGutterRenderer)
+
+struct _IdeGutterInterface
+{
+  GTypeInterface parent_class;
+
+  void (*style_changed) (IdeGutter *self);
+};
+
+IDE_AVAILABLE_IN_ALL
+gboolean ide_gutter_get_show_line_changes          (IdeGutter *self);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_gutter_get_show_line_numbers          (IdeGutter *self);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_gutter_get_show_relative_line_numbers (IdeGutter *self);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_gutter_get_show_line_diagnostics      (IdeGutter *self);
+IDE_AVAILABLE_IN_ALL
+void     ide_gutter_set_show_line_changes          (IdeGutter *self,
+                                                    gboolean   show_line_changes);
+IDE_AVAILABLE_IN_ALL
+void     ide_gutter_set_show_line_numbers          (IdeGutter *self,
+                                                    gboolean   show_line_numbers);
+IDE_AVAILABLE_IN_ALL
+void     ide_gutter_set_show_relative_line_numbers (IdeGutter *self,
+                                                    gboolean   show_relative_line_numbers);
+IDE_AVAILABLE_IN_ALL
+void     ide_gutter_set_show_line_diagnostics      (IdeGutter *self,
+                                                    gboolean   show_line_diagnostics);
+IDE_AVAILABLE_IN_ALL
+void     ide_gutter_style_changed                  (IdeGutter *self);
+
+G_END_DECLS
diff --git a/src/libide/sourceview/libide-sourceview.h b/src/libide/sourceview/libide-sourceview.h
index 13ed96cdb..1ef4234fb 100644
--- a/src/libide/sourceview/libide-sourceview.h
+++ b/src/libide/sourceview/libide-sourceview.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
 #define IDE_SOURCEVIEW_INSIDE
 
 #include "ide-line-change-gutter-renderer.h"
+#include "ide-gutter.h"
 #include "ide-source-style-scheme.h"
 #include "ide-source-view.h"
 #include "ide-text-util.h"
diff --git a/src/libide/sourceview/meson.build b/src/libide/sourceview/meson.build
index 3dea3b5d7..c19dac47f 100644
--- a/src/libide/sourceview/meson.build
+++ b/src/libide/sourceview/meson.build
@@ -15,6 +15,7 @@ libide_sourceview_private_headers = [
 
 libide_sourceview_public_headers = [
   'ide-line-change-gutter-renderer.h',
+  'ide-gutter.h',
   'ide-source-style-scheme.h',
   'ide-source-view.h',
   'ide-text-util.h',
@@ -37,6 +38,7 @@ libide_sourceview_private_sources = [
 
 libide_sourceview_public_sources = [
   'ide-line-change-gutter-renderer.c',
+  'ide-gutter.c',
   'ide-source-style-scheme.c',
   'ide-source-view.c',
   'ide-text-util.c',


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