[gnome-builder] plugins/rust-analyzer: add rust-analyzer tweaks under Build



commit 85ba93bd54498da47f69b1cb89e998df63edf2a3
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 19 17:49:54 2022 -0700

    plugins/rust-analyzer: add rust-analyzer tweaks under Build
    
    I think we could probably land a number of other tweaks in new subpages
    here as well, so that we don't make the top too heavy.

 src/plugins/buildui/tweaks.ui                      | 196 +++++++++++----------
 src/plugins/rust-analyzer/meson.build              |   1 +
 src/plugins/rust-analyzer/rust-analyzer-plugin.c   |   4 +
 .../rust-analyzer/rust-analyzer-tweaks-addin.c     |  44 +++++
 .../rust-analyzer/rust-analyzer-tweaks-addin.h     |  31 ++++
 .../rust-analyzer/rust-analyzer.gresource.xml      |   1 +
 src/plugins/rust-analyzer/rust-analyzer.plugin     |   1 +
 src/plugins/rust-analyzer/tweaks.ui                |  50 ++++++
 8 files changed, 233 insertions(+), 95 deletions(-)
---
diff --git a/src/plugins/buildui/tweaks.ui b/src/plugins/buildui/tweaks.ui
index 1b1559b7f..27dceab42 100644
--- a/src/plugins/buildui/tweaks.ui
+++ b/src/plugins/buildui/tweaks.ui
@@ -14,109 +14,115 @@
             <property name="icon-name">builder-build-symbolic</property>
             <property name="title" translatable="yes">Build</property>
             <child>
-              <object class="IdeTweaksGroup">
-                <property name="title" translatable="yes">History</property>
+              <object class="IdeTweaksPage" id="build_general_page">
+                <property name="icon-name">builder-build-symbolic</property>
+                <property name="title" translatable="yes">General</property>
                 <child>
-                  <object class="IdeTweaksSwitch">
-                    <property name="title" translatable="yes">Clear Expired Artifacts</property>
-                    <property name="subtitle" translatable="yes">Artifacts which have expired will be 
deleted when Builder is started</property>
-                    <property name="action-name">settings.org.gnome.builder.clear-cache-at-startup</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="IdeTweaksSwitch">
-                    <property name="title" translatable="yes">Clear Build Logs</property>
-                    <property name="subtitle" translatable="yes">Clear the build log history when a new 
build begins</property>
-                    <property 
name="action-name">settings.org.gnome.builder.build.clear-build-log-pane</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="IdeTweaksGroup">
-                <property name="title" translatable="yes">Workers</property>
-                <child>
-                  <object class="IdeTweaksCombo">
-                    <property name="title" translatable="yes">Build Parallelism</property>
-                    <property name="subtitle" translatable="yes">Number of workers to use when performing 
builds</property>
-                    <property name="settings">settings_org_gnome_builder_build</property>
-                    <property name="key">parallel</property>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">Default</property>
-                        <property name="action-target">-1</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">1 per CPU</property>
-                        <property name="action-target">0</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">1</property>
-                        <property name="action-target">1</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">2</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
+                  <object class="IdeTweaksGroup">
+                    <property name="title" translatable="yes">History</property>
                     <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">4</property>
-                        <property name="action-target">2</property>
+                      <object class="IdeTweaksSwitch">
+                        <property name="title" translatable="yes">Clear Expired Artifacts</property>
+                        <property name="subtitle" translatable="yes">Artifacts which have expired will be 
deleted when Builder is started</property>
+                        <property 
name="action-name">settings.org.gnome.builder.clear-cache-at-startup</property>
                       </object>
                     </child>
                     <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">6</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">8</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">16</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">32</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">64</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">128</property>
-                        <property name="action-target">2</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">256</property>
-                        <property name="action-target">2</property>
+                      <object class="IdeTweaksSwitch">
+                        <property name="title" translatable="yes">Clear Build Logs</property>
+                        <property name="subtitle" translatable="yes">Clear the build log history when a new 
build begins</property>
+                        <property 
name="action-name">settings.org.gnome.builder.build.clear-build-log-pane</property>
                       </object>
                     </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="IdeTweaksGroup">
+                    <property name="title" translatable="yes">Workers</property>
                     <child>
-                      <object class="IdeTweaksChoice">
-                        <property name="title" translatable="yes">512</property>
-                        <property name="action-target">2</property>
+                      <object class="IdeTweaksCombo">
+                        <property name="title" translatable="yes">Build Parallelism</property>
+                        <property name="subtitle" translatable="yes">Number of workers to use when 
performing builds</property>
+                        <property name="settings">settings_org_gnome_builder_build</property>
+                        <property name="key">parallel</property>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">Default</property>
+                            <property name="action-target">-1</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">1 per CPU</property>
+                            <property name="action-target">0</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">1</property>
+                            <property name="action-target">1</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">2</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">4</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">6</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">8</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">16</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">32</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">64</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">128</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">256</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title" translatable="yes">512</property>
+                            <property name="action-target">2</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/src/plugins/rust-analyzer/meson.build b/src/plugins/rust-analyzer/meson.build
index da249d876..6a344df3b 100644
--- a/src/plugins/rust-analyzer/meson.build
+++ b/src/plugins/rust-analyzer/meson.build
@@ -14,6 +14,7 @@ plugins_sources += files([
   'rust-analyzer-search-provider.c',
   'rust-analyzer-service.c',
   'rust-analyzer-symbol-resolver.c',
+  'rust-analyzer-tweaks-addin.c',
 ])
 
 plugin_rust_analyzer_resources = gnome.compile_resources(
diff --git a/src/plugins/rust-analyzer/rust-analyzer-plugin.c 
b/src/plugins/rust-analyzer/rust-analyzer-plugin.c
index c64bc15eb..b7be7d12e 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-plugin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-plugin.c
@@ -36,6 +36,7 @@
 #include "rust-analyzer-search-provider.h"
 #include "rust-analyzer-service.h"
 #include "rust-analyzer-symbol-resolver.h"
+#include "rust-analyzer-tweaks-addin.h"
 
 _IDE_EXTERN void
 _rust_analyzer_register_types (PeasObjectModule *module)
@@ -76,4 +77,7 @@ _rust_analyzer_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_PREFERENCES_ADDIN,
                                               RUST_TYPE_ANALYZER_PREFERENCES_ADDIN);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_TWEAKS_ADDIN,
+                                              RUST_TYPE_ANALYZER_TWEAKS_ADDIN);
 }
diff --git a/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.c 
b/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.c
new file mode 100644
index 000000000..eadd1069b
--- /dev/null
+++ b/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.c
@@ -0,0 +1,44 @@
+/* rust-analyzer-tweaks-addin.c
+ *
+ * Copyright 2022 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 "rust-analyzer-tweaks-addin"
+
+#include "config.h"
+
+#include "rust-analyzer-tweaks-addin.h"
+
+struct _RustAnalyzerTweaksAddin
+{
+  IdeTweaksAddin parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (RustAnalyzerTweaksAddin, rust_analyzer_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
+
+static void
+rust_analyzer_tweaks_addin_class_init (RustAnalyzerTweaksAddinClass *klass)
+{
+}
+
+static void
+rust_analyzer_tweaks_addin_init (RustAnalyzerTweaksAddin *self)
+{
+  ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
+                                       IDE_STRV_INIT ("/plugins/rust-analyzer/tweaks.ui"));
+}
diff --git a/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.h 
b/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.h
new file mode 100644
index 000000000..333d6830a
--- /dev/null
+++ b/src/plugins/rust-analyzer/rust-analyzer-tweaks-addin.h
@@ -0,0 +1,31 @@
+/* rust-analyzer-tweaks-addin.h
+ *
+ * Copyright 2022 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 <libide-tweaks.h>
+
+G_BEGIN_DECLS
+
+#define RUST_TYPE_ANALYZER_TWEAKS_ADDIN (rust_analyzer_tweaks_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (RustAnalyzerTweaksAddin, rust_analyzer_tweaks_addin, RUST, ANALYZER_TWEAKS_ADDIN, 
IdeTweaksAddin)
+
+G_END_DECLS
diff --git a/src/plugins/rust-analyzer/rust-analyzer.gresource.xml 
b/src/plugins/rust-analyzer/rust-analyzer.gresource.xml
index 79bbf331a..743e1b749 100644
--- a/src/plugins/rust-analyzer/rust-analyzer.gresource.xml
+++ b/src/plugins/rust-analyzer/rust-analyzer.gresource.xml
@@ -2,5 +2,6 @@
 <gresources>
   <gresource prefix="/plugins/rust-analyzer">
     <file>rust-analyzer.plugin</file>
+    <file preprocess="xml-stripblanks">tweaks.ui</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/rust-analyzer/rust-analyzer.plugin b/src/plugins/rust-analyzer/rust-analyzer.plugin
index 7439f15dc..ef9dc55d3 100644
--- a/src/plugins/rust-analyzer/rust-analyzer.plugin
+++ b/src/plugins/rust-analyzer/rust-analyzer.plugin
@@ -2,6 +2,7 @@
 Authors=Günther Wagner <info gunibert de>
 Builtin=true
 Copyright=Copyright © 2020 Günther Wagner
+Depends=buildui;
 Description=Provides integration with the rust-analyzer language server
 Module=rust-analyzer
 Embedded=_rust_analyzer_register_types
diff --git a/src/plugins/rust-analyzer/tweaks.ui b/src/plugins/rust-analyzer/tweaks.ui
new file mode 100644
index 000000000..03f9d5b9a
--- /dev/null
+++ b/src/plugins/rust-analyzer/tweaks.ui
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="IdeTweaks">
+    <child>
+      <object class="IdeTweaksSettings" id="settings_org_gnome_builder_rust_analyzer">
+        <property name="schema-id">org.gnome.builder.rust-analyzer</property>
+        <property name="application-only">true</property>
+      </object>
+    </child>
+    <child internal-child="foundry_section">
+      <object class="IdeTweaksSection">
+        <child internal-child="build_page">
+          <object class="IdeTweaksPage">
+            <child>
+              <object class="IdeTweaksPage" id="build_rust_analyzer_page">
+                <property name="icon-name">text-rust-symbolic</property>
+                <property name="title" translatable="yes">Rust Analyzer</property>
+                <child>
+                  <object class="IdeTweaksGroup" id="rust_analyzer_clippy_group">
+                    <property name="title" translatable="yes">Cargo</property>
+                    <child>
+                      <object class="IdeTweaksCombo" id="rust_analyzer_clippy_combo">
+                        <property name="title" translatable="yes">Cargo Command</property>
+                        <property name="subtitle" translatable="yes">The default cargo command to run with 
rust-analyzer</property>
+                        <property name="settings">settings_org_gnome_builder_rust_analyzer</property>
+                        <property name="key">cargo-command</property>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title">check</property>
+                            <property name="action-target">'check'</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="IdeTweaksChoice">
+                            <property name="title">clippy</property>
+                            <property name="action-target">'clippy'</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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