[gnome-builder/wip/gtk4-port: 431/736] plugins/editorui: tweak styling for scheme previews




commit f652ed5f51207a58a4ee51090bef1e98af88cfbe
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 6 12:56:12 2022 -0700

    plugins/editorui: tweak styling for scheme previews

 .../editorui/gbp-editorui-preferences-addin.c      | 23 +++++++++++-----------
 src/plugins/editorui/style.css                     | 14 ++++++++++---
 2 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/editorui/gbp-editorui-preferences-addin.c 
b/src/plugins/editorui/gbp-editorui-preferences-addin.c
index 07049d1ce..e78a002e9 100644
--- a/src/plugins/editorui/gbp-editorui-preferences-addin.c
+++ b/src/plugins/editorui/gbp-editorui-preferences-addin.c
@@ -189,26 +189,23 @@ ide_preferences_builtin_add_schemes (const char                   *page_name,
   const char * const *scheme_ids;
   GtkFlowBox *flowbox;
   GtkWidget *preview;
-  GtkFrame *frame;
 
   g_assert (IDE_IS_PREFERENCES_WINDOW (window));
   g_assert (entry != NULL);
   g_assert (ADW_IS_PREFERENCES_GROUP (group));
 
   preview = gbp_editorui_preview_new ();
-  frame = g_object_new (GTK_TYPE_FRAME,
-                        "child", preview,
-                        "margin-bottom", 12,
-                        NULL);
-  adw_preferences_group_add (group, GTK_WIDGET (frame));
+  gtk_widget_add_css_class (GTK_WIDGET (preview), "card");
+  gtk_widget_set_margin_bottom (preview, 12);
+  adw_preferences_group_add (group, preview);
 
   manager = gtk_source_style_scheme_manager_get_default ();
   scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
 
   flowbox = g_object_new (GTK_TYPE_FLOW_BOX,
                           "activate-on-single-click", TRUE,
-                          "column-spacing", 6,
-                          "row-spacing", 6,
+                          "column-spacing", 12,
+                          "row-spacing", 12,
                           "max-children-per-line", 4,
                           NULL);
   gtk_widget_add_css_class (GTK_WIDGET (flowbox), "style-schemes");
@@ -216,12 +213,14 @@ ide_preferences_builtin_add_schemes (const char                   *page_name,
   for (guint i = 0; scheme_ids[i]; i++)
     {
       GtkSourceStyleScheme *scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_ids[i]);
-      GtkWidget *selector = gtk_source_style_scheme_preview_new (scheme);
+      GtkSourceStyleSchemePreview *selector;
 
-      gtk_actionable_set_action_name (GTK_ACTIONABLE (selector), "app.style-scheme-name");
+      selector = g_object_new (GTK_SOURCE_TYPE_STYLE_SCHEME_PREVIEW,
+                               "action-name", "app.style-scheme-name",
+                               "scheme", scheme,
+                               NULL);
       gtk_actionable_set_action_target (GTK_ACTIONABLE (selector), "s", scheme_ids[i]);
-
-      gtk_flow_box_append (flowbox, selector);
+      gtk_flow_box_append (flowbox, GTK_WIDGET (selector));
     }
 
   g_signal_connect_object (IDE_APPLICATION_DEFAULT,
diff --git a/src/plugins/editorui/style.css b/src/plugins/editorui/style.css
index 9059ff9ec..2bce7c332 100644
--- a/src/plugins/editorui/style.css
+++ b/src/plugins/editorui/style.css
@@ -1,6 +1,14 @@
 window.preferences preferencesgroup flowbox.style-schemes flowboxchild {
-  outline-offset: -3px;
-  border-radius: 14px;
+  outline-offset: 2px;
+  border-radius: 12px;
   outline-width: 2px;
+  padding: 0;
+}
+window.preferences preferencesgroup flowbox.style-schemes flowboxchild GtkSourceStyleSchemePreview {
+  margin: 0;
+}
+window.preferences preferencesgroup flowbox.style-schemes flowboxchild 
GtkSourceStyleSchemePreview:not(.selected) {
+  box-shadow: 0 0 0 1px alpha(black, 0.03),
+              0 1px 3px 1px alpha(black, .07),
+              0 2px 6px 2px alpha(black, .03);
 }
-


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