[gnome-builder] plugins/editorui: start on editorui tweaks addin



commit 6f23720e487172082cb5295a8d01830d28e6f812
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 12 13:55:41 2022 -0700

    plugins/editorui: start on editorui tweaks addin

 src/plugins/editorui/editorui-plugin.c           |  4 ++
 src/plugins/editorui/editorui.gresource.xml      |  3 +-
 src/plugins/editorui/editorui.plugin             |  1 +
 src/plugins/editorui/gbp-editorui-tweaks-addin.c | 70 ++++++++++++++++++++++++
 src/plugins/editorui/gbp-editorui-tweaks-addin.h | 31 +++++++++++
 src/plugins/editorui/meson.build                 |  1 +
 src/plugins/editorui/tweaks.ui                   | 23 ++++++++
 7 files changed, 132 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/editorui/editorui-plugin.c b/src/plugins/editorui/editorui-plugin.c
index b8edfbcd2..96dcaed89 100644
--- a/src/plugins/editorui/editorui-plugin.c
+++ b/src/plugins/editorui/editorui-plugin.c
@@ -28,6 +28,7 @@
 
 #include "gbp-editorui-application-addin.h"
 #include "gbp-editorui-preferences-addin.h"
+#include "gbp-editorui-tweaks-addin.h"
 #include "gbp-editorui-workbench-addin.h"
 #include "gbp-editorui-workspace-addin.h"
 #include "gbp-editorui-resources.h"
@@ -43,6 +44,9 @@ _gbp_editorui_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_PREFERENCES_ADDIN,
                                               GBP_TYPE_EDITORUI_PREFERENCES_ADDIN);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_TWEAKS_ADDIN,
+                                              GBP_TYPE_EDITORUI_TWEAKS_ADDIN);
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_WORKBENCH_ADDIN,
                                               GBP_TYPE_EDITORUI_WORKBENCH_ADDIN);
diff --git a/src/plugins/editorui/editorui.gresource.xml b/src/plugins/editorui/editorui.gresource.xml
index 9b7ceea9d..d9f1fd160 100644
--- a/src/plugins/editorui/editorui.gresource.xml
+++ b/src/plugins/editorui/editorui.gresource.xml
@@ -3,8 +3,9 @@
   <gresource prefix="/plugins/editorui">
     <file>editorui.plugin</file>
     <file>style.css</file>
-    <file preprocess="xml-stripblanks">gtk/menus.ui</file>
     <file>gtk/keybindings.json</file>
+    <file preprocess="xml-stripblanks">gtk/menus.ui</file>
     <file preprocess="xml-stripblanks">gbp-editorui-position-label.ui</file>
+    <file preprocess="xml-stripblanks">tweaks.ui</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/editorui/editorui.plugin b/src/plugins/editorui/editorui.plugin
index 7e5b62421..005b0d990 100644
--- a/src/plugins/editorui/editorui.plugin
+++ b/src/plugins/editorui/editorui.plugin
@@ -2,6 +2,7 @@
 Authors=Christian Hergert <christian hergert me>
 Builtin=true
 Copyright=Copyright © 2014-2022 Christian Hergert
+Depends=platformui;
 Embedded=_gbp_editorui_register_types
 Hidden=true
 Module=editorui
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c 
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
new file mode 100644
index 000000000..230b80773
--- /dev/null
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -0,0 +1,70 @@
+/* gbp-editorui-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 "gbp-editorui-tweaks-addin"
+
+#include "config.h"
+
+#include "gbp-editorui-preview.h"
+#include "gbp-editorui-tweaks-addin.h"
+
+struct _GbpEditoruiTweaksAddin
+{
+  IdeTweaksAddin parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpEditoruiTweaksAddin, gbp_editorui_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
+
+static GtkWidget *
+editorui_create_style_scheme_selector (GbpEditoruiTweaksAddin *self,
+                                       IdeTweaksWidget        *widget)
+{
+  GbpEditoruiPreview *preview;
+  GtkBox *box;
+
+  g_assert (GBP_IS_EDITORUI_TWEAKS_ADDIN (self));
+  g_assert (IDE_IS_TWEAKS_WIDGET (widget));
+
+  box = g_object_new (GTK_TYPE_BOX,
+                      "orientation", GTK_ORIENTATION_VERTICAL,
+                      "spacing", 12,
+                      "margin-bottom", 12,
+                      NULL);
+  preview = g_object_new (GBP_TYPE_EDITORUI_PREVIEW,
+                          "css-classes", IDE_STRV_INIT ("card"),
+                          NULL);
+  gtk_box_append (box, GTK_WIDGET (preview));
+
+  return GTK_WIDGET (box);
+}
+
+static void
+gbp_editorui_tweaks_addin_class_init (GbpEditoruiTweaksAddinClass *klass)
+{
+}
+
+static void
+gbp_editorui_tweaks_addin_init (GbpEditoruiTweaksAddin *self)
+{
+  ide_tweaks_addin_set_resource_path (IDE_TWEAKS_ADDIN (self),
+                                      "/plugins/editorui/tweaks.ui");
+  ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
+                                  editorui_create_style_scheme_selector);
+}
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.h 
b/src/plugins/editorui/gbp-editorui-tweaks-addin.h
new file mode 100644
index 000000000..6684ad56f
--- /dev/null
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.h
@@ -0,0 +1,31 @@
+/* gbp-editorui-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 GBP_TYPE_EDITORUI_TWEAKS_ADDIN (gbp_editorui_tweaks_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpEditoruiTweaksAddin, gbp_editorui_tweaks_addin, GBP, EDITORUI_TWEAKS_ADDIN, 
IdeTweaksAddin)
+
+G_END_DECLS
diff --git a/src/plugins/editorui/meson.build b/src/plugins/editorui/meson.build
index 94ce0eee2..6444f5cb0 100644
--- a/src/plugins/editorui/meson.build
+++ b/src/plugins/editorui/meson.build
@@ -4,6 +4,7 @@ plugins_sources += files([
   'gbp-editorui-position-label.c',
   'gbp-editorui-preferences-addin.c',
   'gbp-editorui-preview.c',
+  'gbp-editorui-tweaks-addin.c',
   'gbp-editorui-workbench-addin.c',
   'gbp-editorui-workspace-addin.c',
 ])
diff --git a/src/plugins/editorui/tweaks.ui b/src/plugins/editorui/tweaks.ui
new file mode 100644
index 000000000..46370bd80
--- /dev/null
+++ b/src/plugins/editorui/tweaks.ui
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="IdeTweaks">
+    <child internal-child="visual_section">
+      <object class="IdeTweaksSection">
+        <child internal-child="appearance_page">
+          <object class="IdeTweaksPage">
+            <child>
+              <object class="IdeTweaksGroup" id="appearance_page_color_group">
+                <property name="title" translatable="yes">Color</property>
+                <child>
+                  <object class="IdeTweaksWidget" id="style_scheme_selector">
+                    <signal name="create" handler="editorui_create_style_scheme_selector" 
object="GbpEditoruiTweaksAddin" swapped="true"/>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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