Commit 7f7220c8 authored by Christian Hergert's avatar Christian Hergert

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.
parent 9f784ff1
......@@ -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)))
{
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment