[gtksourceview/wip/chergert/gsv-gtk4: 103/131] styleschemechooser: port to GTK 4



commit 9669fafb7316753d7e2a26b70665dfb733dbb4f8
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 15 14:31:08 2020 -0800

    styleschemechooser: port to GTK 4
    
    Instead of an event box to hijack input, we can just place a label over
    the sourceview.
    
    Setting show-line-numbers causes a number of issues with Pango, which
    needs further investigation.

 gtksourceview/gtksourcestyleschemechooserbutton.c |  4 ++--
 gtksourceview/gtksourcestyleschemechooserwidget.c | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gtksourceview/gtksourcestyleschemechooserbutton.c 
b/gtksourceview/gtksourcestyleschemechooserbutton.c
index fb69c0cb..4fe70d83 100644
--- a/gtksourceview/gtksourcestyleschemechooserbutton.c
+++ b/gtksourceview/gtksourcestyleschemechooserbutton.c
@@ -176,7 +176,7 @@ ensure_dialog (GtkSourceStyleSchemeChooserButton *button)
                return;
        }
 
-       parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+       parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
 
        /* TODO: have a ChooserDialog? */
        priv->dialog = dialog = gtk_dialog_new_with_buttons (_("Select a Style"),
@@ -203,7 +203,7 @@ ensure_dialog (GtkSourceStyleSchemeChooserButton *button)
 
        gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (priv->chooser));
 
-       if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
+       if (GTK_IS_ROOT (parent) && GTK_IS_WINDOW (parent))
        {
                if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
                {
diff --git a/gtksourceview/gtksourcestyleschemechooserwidget.c 
b/gtksourceview/gtksourcestyleschemechooserwidget.c
index 68175b51..0d997184 100644
--- a/gtksourceview/gtksourcestyleschemechooserwidget.c
+++ b/gtksourceview/gtksourcestyleschemechooserwidget.c
@@ -134,9 +134,10 @@ make_row (GtkSourceStyleScheme *scheme,
 {
        GtkWidget *row;
        AtkObject *accessible;
-       GtkWidget *event;
        GtkSourceBuffer *buffer;
        GtkWidget *view;
+       GtkWidget *overlay;
+       GtkWidget *label;
        gchar *text;
 
        row = gtk_list_box_row_new ();
@@ -147,11 +148,6 @@ make_row (GtkSourceStyleScheme *scheme,
 
        g_object_set_data (G_OBJECT (row), "scheme", scheme);
 
-       event = gtk_event_box_new ();
-       gtk_event_box_set_above_child (GTK_EVENT_BOX (event), TRUE);
-       gtk_widget_show (event);
-       gtk_container_add (GTK_CONTAINER (row), event);
-
        buffer = gtk_source_buffer_new_with_language (language);
        gtk_source_buffer_set_highlight_matching_brackets (buffer, FALSE);
        gtk_source_buffer_set_style_scheme (buffer, scheme);
@@ -161,18 +157,27 @@ make_row (GtkSourceStyleScheme *scheme,
        gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer), text, -1);
        g_free (text);
 
+       overlay = gtk_overlay_new ();
+       gtk_container_add (GTK_CONTAINER (row), overlay);
+
        view = g_object_new (GTK_SOURCE_TYPE_VIEW,
                             "buffer", buffer,
                             "can-focus", FALSE,
                             "cursor-visible", FALSE,
                             "editable", FALSE,
                             "visible", TRUE,
-                            "show-line-numbers", TRUE,
                             "right-margin-position", 30,
                             "show-right-margin", TRUE,
                             "margin", 2,
                             NULL);
-       gtk_container_add (GTK_CONTAINER (event), view);
+       gtk_container_add (GTK_CONTAINER (overlay), view);
+
+       label = g_object_new (GTK_TYPE_LABEL,
+                             "can-focus", FALSE,
+                             "expand", TRUE,
+                             "selectable", FALSE,
+                             NULL);
+       gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label);
 
        return row;
 }


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