[gnome-builder] plugins/platformui: add new plugin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/platformui: add new plugin
- Date: Fri, 12 Aug 2022 20:09:28 +0000 (UTC)
commit 7aeb558bf5ad2dd906e5be6abc70280c91a0abf1
Author: Christian Hergert <chergert redhat com>
Date: Fri Aug 12 13:09:19 2022 -0700
plugins/platformui: add new plugin
This plugin is going to host various platform integration features such as
the Adwaita style selector (light, dark, etc) and other platform features
which are not necessarily "toggle'able".
po/POTFILES.in | 1 +
src/plugins/meson.build | 1 +
.../platformui/gbp-platformui-tweaks-addin.c | 119 +++++++++++++++++++++
.../platformui/gbp-platformui-tweaks-addin.h | 31 ++++++
src/plugins/platformui/meson.build | 12 +++
src/plugins/platformui/platformui-plugin.c | 38 +++++++
src/plugins/platformui/platformui.gresource.xml | 8 ++
src/plugins/platformui/platformui.plugin | 9 ++
src/plugins/platformui/style.css | 10 ++
src/plugins/platformui/tweaks.ui | 22 ++++
10 files changed, 251 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 96facc35f..f6b6dfe50 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -236,6 +236,7 @@ src/plugins/notification/ide-notification-addin.c
src/plugins/npm/gbp-npm-pipeline-addin.c
src/plugins/open-with-external/gtk/menus.ui
src/plugins/phpize/gbp-phpize-pipeline-addin.c
+src/plugins/platformui/gbp-platformui-tweaks-addin.c
src/plugins/podman/gbp-podman-runtime.c
src/plugins/project-tree/gbp-new-file-popover.c
src/plugins/project-tree/gbp-new-file-popover.ui
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index ed0f488d8..37f93e7a6 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -98,6 +98,7 @@ subdir('notification')
subdir('npm')
subdir('omni-gutter')
subdir('open-with-external')
+subdir('platformui')
subdir('phpize')
subdir('podman')
subdir('project-tree')
diff --git a/src/plugins/platformui/gbp-platformui-tweaks-addin.c
b/src/plugins/platformui/gbp-platformui-tweaks-addin.c
new file mode 100644
index 000000000..f747da77f
--- /dev/null
+++ b/src/plugins/platformui/gbp-platformui-tweaks-addin.c
@@ -0,0 +1,119 @@
+/* gbp-platformui-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-platformui-tweaks-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-gui.h>
+
+#include "gbp-platformui-tweaks-addin.h"
+
+#include "ide-style-variant-preview-private.h"
+
+struct _GbpPlatformuiTweaksAddin
+{
+ IdeTweaksAddin parent_instance;
+};
+
+G_DEFINE_FINAL_TYPE (GbpPlatformuiTweaksAddin, gbp_platformui_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
+
+static const struct {
+ const char *key;
+ AdwColorScheme color_scheme;
+ const char *title;
+} variants[] = {
+ { "default", ADW_COLOR_SCHEME_DEFAULT, N_("Follow System") },
+ { "light", ADW_COLOR_SCHEME_FORCE_LIGHT, N_("Light") },
+ { "dark", ADW_COLOR_SCHEME_FORCE_DARK, N_("Dark") },
+};
+
+static GtkWidget *
+platformui_create_style_selector (IdeTweaks *tweaks,
+ IdeTweaksWidget *widget)
+{
+ GtkBox *box;
+ GtkBox *options;
+
+ g_assert (IDE_IS_TWEAKS_WIDGET (widget));
+ g_assert (IDE_IS_TWEAKS (tweaks));
+
+ box = g_object_new (GTK_TYPE_BOX,
+ "css-name", "list",
+ NULL);
+ gtk_widget_add_css_class (GTK_WIDGET (box), "boxed-list");
+ gtk_widget_add_css_class (GTK_WIDGET (box), "style-variant");
+
+ options = g_object_new (GTK_TYPE_BOX,
+ "halign", GTK_ALIGN_CENTER,
+ NULL);
+
+ for (guint i = 0; i < G_N_ELEMENTS (variants); i++)
+ {
+ IdeStyleVariantPreview *preview;
+ GtkButton *button;
+ GtkLabel *label;
+ GtkBox *vbox;
+
+ vbox = g_object_new (GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ "spacing", 8,
+ "margin-top", 18,
+ "margin-bottom", 18,
+ "margin-start", 9,
+ "margin-end", 9,
+ NULL);
+ preview = g_object_new (IDE_TYPE_STYLE_VARIANT_PREVIEW,
+ "color-scheme", variants[i].color_scheme,
+ NULL);
+ button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
+ "action-name", "app.style-variant",
+ "child", preview,
+ NULL);
+ gtk_actionable_set_action_target (GTK_ACTIONABLE (button), "s", variants[i].key);
+ label = g_object_new (GTK_TYPE_LABEL,
+ "xalign", 0.5f,
+ "label", g_dgettext (NULL, variants[i].title),
+ NULL);
+ gtk_box_append (vbox, GTK_WIDGET (button));
+ gtk_box_append (vbox, GTK_WIDGET (label));
+ gtk_box_append (options, GTK_WIDGET (vbox));
+ }
+
+ gtk_box_append (box, GTK_WIDGET (options));
+
+ return GTK_WIDGET (box);
+}
+
+static void
+gbp_platformui_tweaks_addin_class_init (GbpPlatformuiTweaksAddinClass *klass)
+{
+}
+
+static void
+gbp_platformui_tweaks_addin_init (GbpPlatformuiTweaksAddin *self)
+{
+ ide_tweaks_addin_set_resource_path (IDE_TWEAKS_ADDIN (self),
+ "/plugins/platformui/tweaks.ui");
+ ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
+ platformui_create_style_selector);
+}
diff --git a/src/plugins/platformui/gbp-platformui-tweaks-addin.h
b/src/plugins/platformui/gbp-platformui-tweaks-addin.h
new file mode 100644
index 000000000..f5ff2221a
--- /dev/null
+++ b/src/plugins/platformui/gbp-platformui-tweaks-addin.h
@@ -0,0 +1,31 @@
+/* gbp-platformui-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_PLATFORMUI_TWEAKS_ADDIN (gbp_platformui_tweaks_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpPlatformuiTweaksAddin, gbp_platformui_tweaks_addin, GBP, PLATFORMUI_TWEAKS_ADDIN,
IdeTweaksAddin)
+
+G_END_DECLS
diff --git a/src/plugins/platformui/meson.build b/src/plugins/platformui/meson.build
new file mode 100644
index 000000000..e5f8f6494
--- /dev/null
+++ b/src/plugins/platformui/meson.build
@@ -0,0 +1,12 @@
+plugins_sources += files([
+ 'platformui-plugin.c',
+ 'gbp-platformui-tweaks-addin.c',
+])
+
+plugin_platformui_resources = gnome.compile_resources(
+ 'platformui-resources',
+ 'platformui.gresource.xml',
+ c_name: 'gbp_platformui',
+)
+
+plugins_sources += plugin_platformui_resources
diff --git a/src/plugins/platformui/platformui-plugin.c b/src/plugins/platformui/platformui-plugin.c
new file mode 100644
index 000000000..792ccac2b
--- /dev/null
+++ b/src/plugins/platformui/platformui-plugin.c
@@ -0,0 +1,38 @@
+/* platformui-plugin.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 "platformui-plugin"
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+
+#include <libide-gui.h>
+#include <libide-tweaks.h>
+
+#include "gbp-platformui-tweaks-addin.h"
+
+_IDE_EXTERN void
+_gbp_platformui_register_types (PeasObjectModule *module)
+{
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_TWEAKS_ADDIN,
+ GBP_TYPE_PLATFORMUI_TWEAKS_ADDIN);
+}
diff --git a/src/plugins/platformui/platformui.gresource.xml b/src/plugins/platformui/platformui.gresource.xml
new file mode 100644
index 000000000..e89da7fe4
--- /dev/null
+++ b/src/plugins/platformui/platformui.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/plugins/platformui">
+ <file>platformui.plugin</file>
+ <file>style.css</file>
+ <file preprocess="xml-stripblanks">tweaks.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/plugins/platformui/platformui.plugin b/src/plugins/platformui/platformui.plugin
new file mode 100644
index 000000000..444f33e80
--- /dev/null
+++ b/src/plugins/platformui/platformui.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Authors=Christian Hergert <christian hergert me>
+Builtin=true
+Copyright=Copyright © 2022 Christian Hergert
+Depends=project-tree;
+Embedded=_gbp_platformui_register_types
+Hidden=true
+Module=platformui
+Name=Platform Integration
diff --git a/src/plugins/platformui/style.css b/src/plugins/platformui/style.css
new file mode 100644
index 000000000..113c27157
--- /dev/null
+++ b/src/plugins/platformui/style.css
@@ -0,0 +1,10 @@
+.IdeTweaksWindow list.boxed-list.style-variant button {
+ padding: 0;
+ margin: 0;
+ border: 3px solid transparent;
+ border-radius: 11px;
+ background: transparent;
+}
+.IdeTweaksWindow list.boxed-list.style-variant button:checked {
+ border-color: @theme_selected_bg_color;
+}
diff --git a/src/plugins/platformui/tweaks.ui b/src/plugins/platformui/tweaks.ui
new file mode 100644
index 000000000..02482d741
--- /dev/null
+++ b/src/plugins/platformui/tweaks.ui
@@ -0,0 +1,22 @@
+<?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 internal-child="appearance_page_style_group">
+ <object class="IdeTweaksGroup">
+ <child>
+ <object class="IdeTweaksWidget" id="style_selector">
+ <signal name="create" handler="platformui_create_style_selector" object="IdeTweaks"
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]