[gtksourceview/gtksourceview-5-4] styleschemepreview: Simplify layout and use box-shadow for styles
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-5-4] styleschemepreview: Simplify layout and use box-shadow for styles
- Date: Thu, 21 Apr 2022 20:07:31 +0000 (UTC)
commit 9da1c1dc4c244742d91c1f4e5b3275de76f21302
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Apr 6 22:57:42 2022 +0400
styleschemepreview: Simplify layout and use box-shadow for styles
Make it more flexible so apps can e.g. add .card and get libadwaita styles
on it.
gtksourceview/GtkSourceView.css | 13 ++++++-------
gtksourceview/gtksourcestyleschemepreview.c | 17 +++++------------
2 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/gtksourceview/GtkSourceView.css b/gtksourceview/GtkSourceView.css
index e049364c..fb684fe3 100644
--- a/gtksourceview/GtkSourceView.css
+++ b/gtksourceview/GtkSourceView.css
@@ -150,14 +150,13 @@ GtkSourceAssistant.informative.question image {
background-color: @borders;
}
-GtkSourceStyleSchemePreview frame {
- margin: 1px;
- border-radius: 11px;
+GtkSourceStyleSchemePreview {
+ border-radius: 12px;
+ box-shadow: 0 0 0 1px @borders;
+ margin: 2px;
}
-GtkSourceStyleSchemePreview.selected frame {
- border-color: @theme_selected_bg_color;
- border-width: 2px;
- margin: 0;
+GtkSourceStyleSchemePreview.selected {
+ box-shadow: 0 0 0 2px @theme_selected_bg_color;
}
GtkSourceStyleSchemePreview.selected image {
border-radius: 9999px;
diff --git a/gtksourceview/gtksourcestyleschemepreview.c b/gtksourceview/gtksourcestyleschemepreview.c
index d90e0dc7..082d0f92 100644
--- a/gtksourceview/gtksourcestyleschemepreview.c
+++ b/gtksourceview/gtksourcestyleschemepreview.c
@@ -259,10 +259,8 @@ gtk_source_style_scheme_preview_constructed (GObject *object)
GtkSourceStyleSchemePreview *self = (GtkSourceStyleSchemePreview *)object;
GtkSourceBuffer *buffer;
GtkSourceView *view;
- GtkOverlay *overlay;
const char *name;
GtkLabel *label;
- GtkFrame *frame;
G_OBJECT_CLASS (gtk_source_style_scheme_preview_parent_class)->constructed (object);
@@ -278,10 +276,6 @@ gtk_source_style_scheme_preview_constructed (GObject *object)
name = gtk_source_style_scheme_get_name (self->scheme);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), name);
- frame = g_object_new (GTK_TYPE_FRAME,
- "can-focus", FALSE,
- "focusable", FALSE,
- NULL);
view = g_object_new (GTK_SOURCE_TYPE_VIEW,
"focusable", FALSE,
"can-focus", FALSE,
@@ -295,7 +289,6 @@ gtk_source_style_scheme_preview_constructed (GObject *object)
"width-request", 120,
"right-margin", 9,
NULL);
- overlay = g_object_new (GTK_TYPE_OVERLAY, NULL);
label = g_object_new (GTK_TYPE_LABEL, NULL);
self->image = g_object_new (GTK_TYPE_IMAGE,
"icon-name", "object-select-symbolic",
@@ -311,11 +304,11 @@ gtk_source_style_scheme_preview_constructed (GObject *object)
add_text (buffer, self->scheme);
load_override_font (view);
- gtk_frame_set_child (frame, GTK_WIDGET (overlay));
- gtk_overlay_set_child (overlay, GTK_WIDGET (view));
- gtk_overlay_add_overlay (overlay, GTK_WIDGET (label));
- gtk_overlay_add_overlay (overlay, GTK_WIDGET (self->image));
- gtk_widget_set_parent (GTK_WIDGET (frame), GTK_WIDGET (self));
+ gtk_widget_set_parent (GTK_WIDGET (view), GTK_WIDGET (self));
+ gtk_widget_set_parent (GTK_WIDGET (label), GTK_WIDGET (self));
+ gtk_widget_set_parent (GTK_WIDGET (self->image), GTK_WIDGET (self));
+
+ gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]