[gnome-builder/wip/gtk4-port: 470/736] plugins/clang: finish porting clang plugin




commit 960f87566fc330a52a2bd0d350b47b3021e1e4aa
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 6 20:25:24 2022 -0700

    plugins/clang: finish porting clang plugin

 src/plugins/clang/clang.plugin                  |   1 -
 src/plugins/clang/ide-clang-preferences-addin.c | 137 +++++++++++-------------
 src/plugins/meson.build                         |   2 +-
 3 files changed, 62 insertions(+), 78 deletions(-)
---
diff --git a/src/plugins/clang/clang.plugin b/src/plugins/clang/clang.plugin
index a465f76c2..13070895d 100644
--- a/src/plugins/clang/clang.plugin
+++ b/src/plugins/clang/clang.plugin
@@ -3,7 +3,6 @@ Authors=Christian Hergert <christian hergert me>
 Builtin=true
 Copyright=Copyright © 2015 Christian Hergert
 Description=Provides integration with Clang
-Depends=editor;
 Embedded=_ide_clang_register_types
 Module=clang
 Name=Clang
diff --git a/src/plugins/clang/ide-clang-preferences-addin.c b/src/plugins/clang/ide-clang-preferences-addin.c
index 35a60e8a0..fedc86c47 100644
--- a/src/plugins/clang/ide-clang-preferences-addin.c
+++ b/src/plugins/clang/ide-clang-preferences-addin.c
@@ -18,7 +18,12 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
+#define G_LOG_DOMAIN "ide-clang-preferences-addin"
+
+#include "config.h"
+
 #include <glib/gi18n.h>
+
 #include <libide-code.h>
 #include <libide-gui.h>
 
@@ -33,96 +38,63 @@ struct _IdeClangPreferencesAddin
   guint   params_id;
 };
 
-static void preferences_addin_iface_init (IdePreferencesAddinInterface *iface);
+static const IdePreferenceGroupEntry groups[] = {
+  { "insight", "clang", 1000, N_("Clang") },
+};
 
-G_DEFINE_TYPE_EXTENDED (IdeClangPreferencesAddin, ide_clang_preferences_addin, G_TYPE_OBJECT, 
G_TYPE_FLAG_FINAL,
-                        G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN,
-                                               preferences_addin_iface_init))
+static const IdePreferenceItemEntry items[] = {
+  { "insight", "diagnostics-providers", "clang", 0, ide_preferences_window_toggle,
+    N_("Use Clang for Diagnostics"),
+    N_("Clang will be queried for diagnostics within C, C++, and Objective-C sources"),
+    "org.gnome.builder.extension-type",
+    "/org/gnome/builder/extension-types/clang/IdeDiagnosticProvider/",
+    "enabled" },
+
+  { "insight", "completion-providers", "clang", 0, ide_preferences_window_toggle,
+    N_("Use Clang for Completions"),
+    N_("Clang will be queried for completions within C, C++, and Objective-C sources"),
+    "org.gnome.builder.extension-type",
+    "/org/gnome/builder/extension-types/clang/GtkSourceCompletionProvider/",
+    "enabled" },
+
+  { "insight", "clang", "parens", 0, ide_preferences_window_toggle,
+    N_("Complete Parenthesis"),
+    N_("Include parenthesis when completing clang proposals"),
+    "org.gnome.builder.clang", NULL, "complete-parens" },
+
+  { "insight", "clang", "params", 0, ide_preferences_window_toggle,
+    N_("Complete Parameters"),
+    N_("Include parameters and types when completing clang proposals"),
+    "org.gnome.builder.clang", NULL, "complete-params" },
+};
 
 static void
-ide_clang_preferences_addin_class_init (IdeClangPreferencesAddinClass *klass)
+ide_clang_preferences_addin_load (IdePreferencesAddin  *addin,
+                                  IdePreferencesWindow *window)
 {
-}
+  IDE_ENTRY;
 
-static void
-ide_clang_preferences_addin_init (IdeClangPreferencesAddin *self)
-{
-}
+  g_assert (IDE_IS_CLANG_PREFERENCES_ADDIN (addin));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
 
-static void
-ide_clang_preferences_addin_load (IdePreferencesAddin *addin,
-                                  DzlPreferences      *preferences)
-{
-  IdeClangPreferencesAddin *self = (IdeClangPreferencesAddin *)addin;
+  ide_preferences_window_add_groups (window, groups, G_N_ELEMENTS (groups), NULL);
+  ide_preferences_window_add_items (window, items, G_N_ELEMENTS (items), window, NULL);
 
-  g_assert (IDE_IS_CLANG_PREFERENCES_ADDIN (addin));
-  g_assert (DZL_IS_PREFERENCES (preferences));
-
-  self->diagnose_id = dzl_preferences_add_switch (preferences,
-                                                  "code-insight",
-                                                  "diagnostics",
-                                                  "org.gnome.builder.extension-type",
-                                                  "enabled",
-                                                  
"/org/gnome/builder/extension-types/clang-plugin/IdeDiagnosticProvider/",
-                                                  NULL,
-                                                  _("Clang"),
-                                                  _("Show errors and warnings provided by Clang"),
-                                                  /* translators: keywords used when searching for 
preferences */
-                                                  _("clang diagnostics warnings errors"),
-                                                  50);
-
-  self->completion_id = dzl_preferences_add_switch (preferences,
-                                                    "completion",
-                                                    "providers",
-                                                    "org.gnome.builder.extension-type",
-                                                    "enabled",
-                                                    
"/org/gnome/builder/extension-types/clang-plugin/IdeCompletionProvider/",
-                                                    NULL,
-                                                    _("Suggest completions using Clang"),
-                                                    _("Use Clang to suggest completions for C and C++ 
languages"),
-                                                    NULL,
-                                                    20);
-
-  dzl_preferences_add_list_group (preferences, "completion", "clang", _("Clang Options"), 
GTK_SELECTION_NONE, 300);
-
-  self->parens_id = dzl_preferences_add_switch (preferences,
-                                                "completion",
-                                                "clang",
-                                                "org.gnome.builder.clang",
-                                                "complete-parens",
-                                                NULL,
-                                                NULL,
-                                                _("Complete Parenthesis"),
-                                                _("Include parenthesis when completing clang proposals"),
-                                                NULL,
-                                                0);
-
-  self->params_id = dzl_preferences_add_switch (preferences,
-                                                "completion",
-                                                "clang",
-                                                "org.gnome.builder.clang",
-                                                "complete-params",
-                                                NULL,
-                                                NULL,
-                                                _("Complete Parameters"),
-                                                _("Include parameters and types when completing clang 
proposals"),
-                                                NULL,
-                                                10);
+  IDE_EXIT;
 }
 
 static void
-ide_clang_preferences_addin_unload (IdePreferencesAddin *addin,
-                                    DzlPreferences      *preferences)
+ide_clang_preferences_addin_unload (IdePreferencesAddin  *addin,
+                                    IdePreferencesWindow *window)
 {
-  IdeClangPreferencesAddin *self = (IdeClangPreferencesAddin *)addin;
+  IDE_ENTRY;
 
   g_assert (IDE_IS_CLANG_PREFERENCES_ADDIN (addin));
-  g_assert (DZL_IS_PREFERENCES (preferences));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
+
+  /* TODO: Remove gsettings switches */
 
-  dzl_preferences_remove_id (preferences, self->completion_id);
-  dzl_preferences_remove_id (preferences, self->diagnose_id);
-  dzl_preferences_remove_id (preferences, self->parens_id);
-  dzl_preferences_remove_id (preferences, self->params_id);
+  IDE_EXIT;
 }
 
 static void
@@ -131,3 +103,16 @@ preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
   iface->load = ide_clang_preferences_addin_load;
   iface->unload = ide_clang_preferences_addin_unload;
 }
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (IdeClangPreferencesAddin, ide_clang_preferences_addin, G_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, 
preferences_addin_iface_init))
+
+static void
+ide_clang_preferences_addin_class_init (IdeClangPreferencesAddinClass *klass)
+{
+}
+
+static void
+ide_clang_preferences_addin_init (IdeClangPreferencesAddin *self)
+{
+}
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 0bd0153bd..ac3b7d013 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -44,7 +44,7 @@ subdir('buildsystem')
 #subdir('buildui')
 subdir('buffer-monitor')
 subdir('cargo')
-#subdir('clang')
+subdir('clang')
 subdir('clangd')
 subdir('clang-format')
 subdir('cmake')


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