From 26ba6356442ef9c6da722a1a7fa2aaf41f00edba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 30 Jun 2026 14:49:49 +0300 Subject: [PATCH] [Gtk4] Fix missing space between TreeItem icon and label Measuring the allocation of GtkSeparator before it's realized always gives 0x0 so icon and label are really glued. Use gtk_cell_renderer_get_padding to query the cell renderer for that info. Gtk 3 could use same code but I decided to not do it as separator has bigger width than cellrenderer padding and I don't want to change Gtk 3 visual behavior (make trees more "condensed"). --- .../org/eclipse/swt/widgets/TableItem.java | 20 +++++++------------ .../gtk/org/eclipse/swt/widgets/TreeItem.java | 14 ++++--------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java index 6d990c8c6a4..591facfa44c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2025 IBM Corporation and others. + * Copyright (c) 2000, 2026 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -336,16 +336,13 @@ Rectangle getBoundsinPixels () { rect.width = w [0]; int horizontalSeparator; + int[] buffer = new int[1]; if (GTK.GTK4) { - long separator = GTK.gtk_separator_new(GTK.GTK_ORIENTATION_HORIZONTAL); - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation(separator, allocation); - horizontalSeparator = allocation.height; + GTK.gtk_cell_renderer_get_padding(textRenderer, buffer, null); } else { - int[] buffer = new int[1]; GTK3.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0); - horizontalSeparator = buffer[0]; } + horizontalSeparator = buffer[0]; rect.x += horizontalSeparator; gtk_tree_view_column_cell_get_position (column, textRenderer, x, null); @@ -769,16 +766,13 @@ public Rectangle getTextBounds (int index) { parent.ignoreSize = false; int horizontalSeparator; + int[] buffer = new int[1]; if (GTK.GTK4) { - long separator = GTK.gtk_separator_new(GTK.GTK_ORIENTATION_HORIZONTAL); - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation(separator, allocation); - horizontalSeparator = allocation.height; + GTK.gtk_cell_renderer_get_padding(textRenderer, buffer, null); } else { - int[] buffer = new int[1]; GTK3.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0); - horizontalSeparator = buffer[0]; } + horizontalSeparator = buffer[0]; rect.x += horizontalSeparator; gtk_tree_view_column_cell_get_position (column, textRenderer, x, null); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java index 5879b0b68ba..65c7136b33e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java @@ -481,14 +481,11 @@ public Rectangle getBounds () { int horizontalSeparator; if (GTK.GTK4) { - long separator = GTK.gtk_separator_new(GTK.GTK_ORIENTATION_HORIZONTAL); - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation(separator, allocation); - horizontalSeparator = allocation.height; + GTK.gtk_cell_renderer_get_padding(textRenderer, buffer, null); } else { GTK3.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0); - horizontalSeparator = buffer[0]; } + horizontalSeparator = buffer[0]; rect.x += horizontalSeparator; gtk_tree_view_column_cell_get_position (column, textRenderer, x, null); @@ -948,14 +945,11 @@ public Rectangle getTextBounds (int index) { int horizontalSeparator; if (GTK.GTK4) { - long separator = GTK.gtk_separator_new(GTK.GTK_ORIENTATION_HORIZONTAL); - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation(separator, allocation); - horizontalSeparator = allocation.height; + GTK.gtk_cell_renderer_get_padding(textRenderer, buffer, null); } else { GTK3.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0); - horizontalSeparator = buffer[0]; } + horizontalSeparator = buffer[0]; rect.x += horizontalSeparator; gtk_tree_view_column_cell_get_position (column, textRenderer, x, null); /*