Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-09-17 15:44:15 +0000
committerEric Williams2018-09-17 16:13:15 +0000
commit64a2735027644bacb7cbea6b8508dde7064c86c5 (patch)
treeb6596c87e820d480be1850aa53b3199aa7157a87
parent795f7d54e5379b763f4e682e19c1fd9cfa931002 (diff)
downloadeclipse.platform.swt-64a2735027644bacb7cbea6b8508dde7064c86c5.tar.gz
eclipse.platform.swt-64a2735027644bacb7cbea6b8508dde7064c86c5.tar.xz
eclipse.platform.swt-64a2735027644bacb7cbea6b8508dde7064c86c5.zip
Bug 530841: [GTK2] Remove GTK 2.x support
Remove GTK2 code from TabFolder/Item, ToolBar/Item, Tree/TableItem, and TableColumn. Change-Id: I22e99b5a420f1386e2f5fde9ae082fec8e734f88 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java93
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java164
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java187
8 files changed, 188 insertions, 322 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 08d03fcff3..64683262b3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -54,7 +54,6 @@ public class GTK extends OS {
public static final int GTK_FRAME_LABEL_SIDE_PAD = 2;
public static final int GTK_ICON_SIZE_MENU = 1;
public static final int GTK_ICON_SIZE_SMALL_TOOLBAR = 2;
- public static final int GTK_ICON_SIZE_LARGE_TOOLBAR = 3;
public static final int GTK_ICON_SIZE_DIALOG = 6;
public static final int GTK_ICON_LOOKUP_FORCE_SIZE = 4;
public static final int GTK_JUSTIFY_CENTER = 0x2;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index d590729d48..d1b7ee9c6f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -238,25 +238,23 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) {
Rectangle getClientAreaInPixels () {
Rectangle clientRectangle = super.getClientAreaInPixels ();
- if (GTK.GTK3) {
- /*
- * Bug 454936 (see also other 454936 references)
- * SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation
- * causes GTK+ to move the clientHandle's SwtFixed down by the size of the labels.
- * These calls can come up from 'shell' and TabFolder has no control over these calls.
- *
- * This is an undesired side-effect. Client handle's x & y positions should never
- * be incremented as this is an internal sub-container.
- *
- * Note: 0 by 0 was chosen as 1 by 1 shifts controls beyond their original pos.
- * The long term fix would be to not use widget_*_allocation from higher containers,
- * but this would require removal of swtFixed.
- *
- * This is Gtk3-specific for Tabfolder as the architecture is changed in gtk3 only.
- */
- clientRectangle.x = 0;
- clientRectangle.y = 0;
- }
+ /*
+ * Bug 454936 (see also other 454936 references)
+ * SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation
+ * causes GTK+ to move the clientHandle's SwtFixed down by the size of the labels.
+ * These calls can come up from 'shell' and TabFolder has no control over these calls.
+ *
+ * This is an undesired side-effect. Client handle's x & y positions should never
+ * be incremented as this is an internal sub-container.
+ *
+ * Note: 0 by 0 was chosen as 1 by 1 shifts controls beyond their original pos.
+ * The long term fix would be to not use widget_*_allocation from higher containers,
+ * but this would require removal of swtFixed.
+ *
+ * This is Gtk3-specific for Tabfolder as the architecture is changed in gtk3 only.
+ */
+ clientRectangle.x = 0;
+ clientRectangle.y = 0;
return clientRectangle;
}
@@ -374,44 +372,39 @@ long /*int*/ eventHandle () {
@Override
Control[] _getChildren() {
Control [] directChildren = super._getChildren ();
- if (GTK.GTK3) {
- int directCount = directChildren.length;
- int count = items == null ? 0 : items.length;
- Control [] children = new Control [count + directCount];
- int i = 0;
- for (int j = 0; j < count; j++) {
- TabItem tabItem = items[j];
- if (tabItem != null && !tabItem.isDisposed()) {
- long /*int*/ parentHandle = tabItem.pageHandle;
- long /*int*/ list = GTK.gtk_container_get_children (parentHandle);
- if (list != 0) {
- long /*int*/ handle = OS.g_list_data (list);
- if (handle != 0) {
- Widget widget = display.getWidget (handle);
- if (widget != null && widget != this) {
- if (widget instanceof Control) {
- children [i++] = (Control) widget;
- }
+ int directCount = directChildren.length;
+ int count = items == null ? 0 : items.length;
+ Control [] children = new Control [count + directCount];
+ int i = 0;
+ for (int j = 0; j < count; j++) {
+ TabItem tabItem = items[j];
+ if (tabItem != null && !tabItem.isDisposed()) {
+ long /*int*/ parentHandle = tabItem.pageHandle;
+ long /*int*/ list = GTK.gtk_container_get_children (parentHandle);
+ if (list != 0) {
+ long /*int*/ handle = OS.g_list_data (list);
+ if (handle != 0) {
+ Widget widget = display.getWidget (handle);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [i++] = (Control) widget;
}
}
- OS.g_list_free (list);
}
+ OS.g_list_free (list);
}
}
- if (i == count + directCount) return children;
- Control [] newChildren;
- if (i == count) {
- newChildren = children;
- } else {
- newChildren = new Control [i + directCount];
- System.arraycopy (children, 0, newChildren, 0, i);
- }
- System.arraycopy (directChildren, 0, newChildren, i, directCount);
- return newChildren;
-
+ }
+ if (i == count + directCount) return children;
+ Control [] newChildren;
+ if (i == count) {
+ newChildren = children;
} else {
- return directChildren;
+ newChildren = new Control [i + directCount];
+ System.arraycopy (children, 0, newChildren, 0, i);
}
+ System.arraycopy (directChildren, 0, newChildren, i, directCount);
+ return newChildren;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index cf8ad95a33..73071be582 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -247,12 +247,10 @@ void register () {
@Override
void release (boolean destroy) {
- if (GTK.GTK3) {
- //Since controls are now nested under the tabItem,
- //tabItem is responsible for it's release.
- if (control != null && !control.isDisposed ()) {
- control.release (destroy);
- }
+ //Since controls are now nested under the tabItem,
+ //tabItem is responsible for it's release.
+ if (control != null && !control.isDisposed ()) {
+ control.release (destroy);
}
super.release (destroy);
}
@@ -295,7 +293,7 @@ public void setControl (Control control) {
if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
}
- if (control != null && GTK.GTK3) {
+ if (control != null) {
// To understand why we reparent, see implementation note about bug 454936 at the start of TabFolder.
Control.gtk_widget_reparent (control, pageHandle);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index 0b09026023..4c1c219a55 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -444,13 +444,9 @@ public void pack () {
int width = 0;
if (buttonHandle != 0) {
GtkRequisition requisition = new GtkRequisition ();
- if (GTK.GTK3) {
- GTK.gtk_widget_show(buttonHandle);
- gtk_widget_get_preferred_size (buttonHandle, requisition);
- GTK.gtk_widget_hide(buttonHandle);
- } else {
- gtk_widget_get_preferred_size (buttonHandle, requisition);
- }
+ GTK.gtk_widget_show(buttonHandle);
+ gtk_widget_get_preferred_size (buttonHandle, requisition);
+ GTK.gtk_widget_hide(buttonHandle);
width = requisition.width;
}
if ((parent.style & SWT.VIRTUAL) != 0) {
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 7c64ecac7c..7f67760647 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
@@ -597,25 +597,21 @@ Rectangle getImageBoundsInPixels (int index) {
* yet to be sized, as per Bug 469277 & 476419. NOTE: this change has been ported to Tables since Tables/Trees both
* use the same underlying GTK structure.
*/
- if (GTK.GTK3) {
- if (parent.pixbufSizeSet) {
- if (x [0] > 0) {
- rect.x += x [0];
- }
- } else {
- /*
- * If the size of the pixbufRenderer hasn't been set, we need to take into account the
- * position of the textRenderer, to ensure images/widgets/etc. aren't placed over the TableItem's
- * text.
- */
- long /*int*/ textRenderer = parent.getTextRenderer (column);
- if (textRenderer == 0) return new Rectangle (0, 0, 0, 0);
- int [] xText = new int [1], wText = new int [1];
- gtk_tree_view_column_cell_get_position (column, textRenderer, xText, wText);
- rect.x += xText [0];
+ if (parent.pixbufSizeSet) {
+ if (x [0] > 0) {
+ rect.x += x [0];
}
} else {
- rect.x += x [0];
+ /*
+ * If the size of the pixbufRenderer hasn't been set, we need to take into account the
+ * position of the textRenderer, to ensure images/widgets/etc. aren't placed over the TableItem's
+ * text.
+ */
+ long /*int*/ textRenderer = parent.getTextRenderer (column);
+ if (textRenderer == 0) return new Rectangle (0, 0, 0, 0);
+ int [] xText = new int [1], wText = new int [1];
+ gtk_tree_view_column_cell_get_position (column, textRenderer, xText, wText);
+ rect.x += xText [0];
}
rect.width = w [0];
int width = GTK.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
@@ -767,22 +763,18 @@ Rectangle getTextBoundsInPixels (int index) {
* NOTE: this change has been ported to Tables since Tables/Trees both use the
* same underlying GTK structure.
*/
- if (GTK.GTK3) {
- Image image = _getImage(index);
- int imageWidth = 0;
- if (image != null) {
- if (DPIUtil.useCairoAutoScale()) {
- imageWidth = image.getBounds ().width;
- } else {
- imageWidth = image.getBoundsInPixels ().width;
- }
-
- }
- if (x [0] < imageWidth) {
- rect.x += imageWidth;
+ Image image = _getImage(index);
+ int imageWidth = 0;
+ if (image != null) {
+ if (DPIUtil.useCairoAutoScale()) {
+ imageWidth = image.getBounds ().width;
} else {
- rect.x += x [0];
+ imageWidth = image.getBoundsInPixels ().width;
}
+
+ }
+ if (x [0] < imageWidth) {
+ rect.x += imageWidth;
} else {
rect.x += x [0];
}
@@ -1171,95 +1163,61 @@ public void setImage (int index, Image image) {
* change has been ported to Tables since Tables/Trees both use the same
* underlying GTK structure.
*/
- if (GTK.GTK3) {
- if (DPIUtil.useCairoAutoScale()) {
- /*
- * Bug in GTK the default renderer does scale again on pixbuf.
- * Need to scaledown here and no need to scaledown id device scale is 1
- */
- if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
- Rectangle imgSize = image.getBounds();
- long /*int*/ scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
- if (scaledPixbuf !=0) {
- pixbuf = scaledPixbuf;
- }
- }
- }
- long /*int*/parentHandle = parent.handle;
- long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
- long /*int*/ pixbufRenderer = parent.getPixbufRenderer (column);
- int [] currentWidth = new int [1];
- int [] currentHeight= new int [1];
- GTK.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
- if (!parent.pixbufSizeSet) {
- if (image != null) {
- int iWidth, iHeight;
- if (DPIUtil.useCairoAutoScale()) {
- iWidth = image.getBounds ().width;
- iHeight = image.getBounds ().height;
- } else {
- iWidth = image.getBoundsInPixels ().width;
- iHeight = image.getBoundsInPixels ().height;
- }
- if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
- GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
- parent.pixbufHeight = iHeight;
- parent.pixbufWidth = iWidth;
- parent.pixbufSizeSet = true;
- }
- }
- } else {
- /*
- * We check to see if the cached value is greater than the size of the pixbufRenderer.
- * If it is, then we change the size of the pixbufRenderer accordingly.
- * Bug 489025: There is a corner case where the below is triggered when current(Width|Height) is -1,
- * which results in icons being set to 0. Fix is to compare only positive sizes.
- */
- if (parent.pixbufWidth > Math.max(currentWidth [0], 0) || parent.pixbufHeight > Math.max(currentHeight [0], 0)) {
- GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, parent.pixbufWidth, parent.pixbufHeight);
+ if (DPIUtil.useCairoAutoScale()) {
+ /*
+ * Bug in GTK the default renderer does scale again on pixbuf.
+ * Need to scaledown here and no need to scaledown id device scale is 1
+ */
+ if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
+ Rectangle imgSize = image.getBounds();
+ long /*int*/ scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
+ if (scaledPixbuf !=0) {
+ pixbuf = scaledPixbuf;
}
}
}
- int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
- GTK.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, pixbuf, -1);
- /*
- * Bug in GTK. When in fixed height mode, GTK does not recalculate the cell renderer width
- * when the image is changed in the model. The fix is to force it to recalculate the width if
- * more space is required.
- */
- if ((parent.style & SWT.VIRTUAL) != 0 && parent.currentItem == null) {
+ long /*int*/parentHandle = parent.handle;
+ long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
+ long /*int*/ pixbufRenderer = parent.getPixbufRenderer (column);
+ int [] currentWidth = new int [1];
+ int [] currentHeight= new int [1];
+ GTK.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
+ if (!parent.pixbufSizeSet) {
if (image != null) {
- long /*int*/parentHandle = parent.handle;
- long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
- int [] w = new int [1];
- long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
- gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- int iWidth;
- if (GTK.GTK3 && DPIUtil.useCairoAutoScale()) {
+ int iWidth, iHeight;
+ if (DPIUtil.useCairoAutoScale()) {
iWidth = image.getBounds ().width;
+ iHeight = image.getBounds ().height;
} else {
iWidth = image.getBoundsInPixels ().width;
+ iHeight = image.getBoundsInPixels ().height;
}
- if (w[0] < iWidth) {
- /*
- * There is no direct way to clear the cell renderer width so we
- * are relying on the fact that it is done as part of modifying
- * the style.
- */
- if (!GTK.GTK3) {
- long /*int*/ style = GTK.gtk_widget_get_modifier_style (parentHandle);
- parent.modifyStyle (parentHandle, style);
- }
+ if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
+ GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
+ parent.pixbufHeight = iHeight;
+ parent.pixbufWidth = iWidth;
+ parent.pixbufSizeSet = true;
}
}
+ } else {
+ /*
+ * We check to see if the cached value is greater than the size of the pixbufRenderer.
+ * If it is, then we change the size of the pixbufRenderer accordingly.
+ * Bug 489025: There is a corner case where the below is triggered when current(Width|Height) is -1,
+ * which results in icons being set to 0. Fix is to compare only positive sizes.
+ */
+ if (parent.pixbufWidth > Math.max(currentWidth [0], 0) || parent.pixbufHeight > Math.max(currentHeight [0], 0)) {
+ GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, parent.pixbufWidth, parent.pixbufHeight);
+ }
}
+ int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+ GTK.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, pixbuf, -1);
cached = true;
/*
* Bug 465056: single column Tables have a very small initial width.
* Fix: when text or an image is set for a Table, compute its
* width and see if it's larger than the maximum of the previous widths.
*/
- long /*int*/ column;
if (parent.columnCount == 0) {
column = GTK.gtk_tree_view_get_column (parent.handle, index);
parent.maxWidth = Math.max(parent.maxWidth, parent.calculateWidth(column, this.handle));
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 47c241079a..9e32e90650 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -136,10 +136,6 @@ void createHandle (int index) {
handle = GTK.gtk_toolbar_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
GTK.gtk_container_add (fixedHandle, handle);
- if ((style & SWT.FLAT) != 0 && !GTK.GTK3) {
- byte [] swt_toolbar_flat = Converter.wcsToMbcs ("swt-toolbar-flat", true);
- GTK.gtk_widget_set_name (handle, swt_toolbar_flat);
- }
/*
* Bug in GTK. GTK will segment fault if gtk_widget_reparent() is called
@@ -151,13 +147,11 @@ void createHandle (int index) {
* tool bar preferred size is too big with GTK_ICON_SIZE_LARGE_TOOLBAR
* when the tool bar item has no image or text.
*/
- GTK.gtk_toolbar_set_icon_size (handle, GTK.GTK3 ? GTK.GTK_ICON_SIZE_SMALL_TOOLBAR : GTK.GTK_ICON_SIZE_LARGE_TOOLBAR);
+ GTK.gtk_toolbar_set_icon_size (handle, GTK.GTK_ICON_SIZE_SMALL_TOOLBAR);
// In GTK 3 font description is inherited from parent widget which is not how SWT has always worked,
// reset to default font to get the usual behavior
- if (GTK.GTK3) {
- setFontDescription(defaultFont().handle);
- }
+ setFontDescription(defaultFont().handle);
}
@Override
@@ -615,9 +609,7 @@ void setBackgroundGdkRGBA (long /*int*/ context, long /*int*/ handle, GdkRGBA rg
@Override
void setParentBackground () {
- if (GTK.GTK3) {
- setBackgroundGdkRGBA (handle, display.getSystemColor(SWT.COLOR_TRANSPARENT).handleRGBA);
- }
+ setBackgroundGdkRGBA (handle, display.getSystemColor(SWT.COLOR_TRANSPARENT).handleRGBA);
super.setParentBackground();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index 838162d6ae..7c1c42df62 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -212,9 +212,6 @@ void createHandle (int index) {
arrowHandle = OS.g_list_nth_data (list, 1);
if (arrowHandle != 0) {
GTK.gtk_widget_set_sensitive (arrowHandle, true);
- if (!GTK.GTK3) {
- GTK.gtk_widget_set_size_request(GTK.gtk_bin_get_child(arrowHandle), 8, 6);
- }
}
break;
case SWT.RADIO:
@@ -968,32 +965,6 @@ public void setEnabled (boolean enabled) {
long /*int*/ topHandle = topHandle ();
if (GTK.gtk_widget_get_sensitive (topHandle) == enabled) return;
GTK.gtk_widget_set_sensitive (topHandle, enabled);
-
- if (!GTK.GTK3) {
- if (enabled) {
- /*
- * Bug in GTK (see Eclipse bug 82169). GtkButton requires an enter notify before it
- * allows the button to be pressed, but events are dropped when
- * widgets are insensitive. The fix is to hide and show the
- * button if the pointer is within its bounds.
- */
- int [] x = new int [1], y = new int [1];
- gdk_window_get_device_position (parent.paintWindow (), x, y, null);
- if (getBoundsInPixels ().contains (x [0], y [0])) {
- GTK.gtk_widget_hide (handle);
- GTK.gtk_widget_show (handle);
- }
- } else {
- /*
- * Bug in GTK. Starting with 2.14, if a button is disabled
- * through on a button press, the field which keeps track
- * whether the pointer is currently in the button is never updated.
- * As a result, when it is re-enabled it automatically enters
- * a PRELIGHT state. The fix is to set a NORMAL state.
- */
- GTK.gtk_widget_set_state (topHandle, GTK.GTK_STATE_NORMAL);
- }
- }
}
boolean setFocus () {
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 6fdb654e96..991186b21a 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
@@ -742,25 +742,21 @@ Rectangle getImageBoundsInPixels (int index) {
*/
int [] x = new int [1], w = new int [1];
gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
- if (GTK.GTK3) {
- if (parent.pixbufSizeSet) {
- if (x [0] > 0) {
- rect.x += x [0];
- }
- } else {
- /*
- * If the size of the pixbufRenderer hasn't been set, we need to take into account the
- * position of the textRenderer, to ensure images/widgets/etc. aren't placed over the TreeItem's
- * text.
- */
- long /*int*/ textRenderer = parent.getTextRenderer (column);
- if (textRenderer == 0) return new Rectangle (0, 0, 0, 0);
- int [] xText = new int [1], wText = new int [1];
- gtk_tree_view_column_cell_get_position (column, textRenderer, xText, wText);
- rect.x += xText [0];
+ if (parent.pixbufSizeSet) {
+ if (x [0] > 0) {
+ rect.x += x [0];
}
} else {
- rect.x += x [0];
+ /*
+ * If the size of the pixbufRenderer hasn't been set, we need to take into account the
+ * position of the textRenderer, to ensure images/widgets/etc. aren't placed over the TreeItem's
+ * text.
+ */
+ long /*int*/ textRenderer = parent.getTextRenderer (column);
+ if (textRenderer == 0) return new Rectangle (0, 0, 0, 0);
+ int [] xText = new int [1], wText = new int [1];
+ gtk_tree_view_column_cell_get_position (column, textRenderer, xText, wText);
+ rect.x += xText [0];
}
rect.width = w [0];
int width = GTK.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
@@ -986,21 +982,17 @@ Rectangle getTextBoundsInPixels (int index) {
* NOTE: this change has been ported to Tables since Tables/Trees both use the
* same underlying GTK structure.
*/
- if (GTK.GTK3) {
- Image image = _getImage(index);
- int imageWidth = 0;
- if (image != null) {
- if (DPIUtil.useCairoAutoScale()) {
- imageWidth = image.getBounds ().width;
- } else {
- imageWidth = image.getBoundsInPixels ().width;
- }
- }
- if (x [0] < imageWidth) {
- rect.x += imageWidth;
+ Image image = _getImage(index);
+ int imageWidth = 0;
+ if (image != null) {
+ if (DPIUtil.useCairoAutoScale()) {
+ imageWidth = image.getBounds ().width;
} else {
- rect.x += x [0];
+ imageWidth = image.getBoundsInPixels ().width;
}
+ }
+ if (x [0] < imageWidth) {
+ rect.x += imageWidth;
} else {
rect.x += x [0];
}
@@ -1525,104 +1517,71 @@ public void setImage (int index, Image image) {
* change has been ported to Tables since Tables/Trees both use the same
* underlying GTK structure.
*/
- if (GTK.GTK3) {
- if (DPIUtil.useCairoAutoScale()) {
- /*
- * Bug in GTK the default renderer does scale again on pixbuf.
- * Need to scaledown here and no need to scaledown id device scale is 1
- */
- if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
- Rectangle imgSize = image.getBounds();
- long /*int*/ scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
- if (scaledPixbuf !=0) {
- pixbuf = scaledPixbuf;
- }
- }
- }
- long /*int*/parentHandle = parent.handle;
- long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
- long /*int*/ pixbufRenderer = parent.getPixbufRenderer (column);
- int [] currentWidth = new int [1];
- int [] currentHeight= new int [1];
- GTK.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
- if (!parent.pixbufSizeSet) {
- if (image != null) {
- int iWidth, iHeight;
- if (DPIUtil.useCairoAutoScale()) {
- iWidth = image.getBounds ().width;
- iHeight = image.getBounds ().height;
- } else {
- iWidth = image.getBoundsInPixels ().width;
- iHeight = image.getBoundsInPixels ().height;
- }
- if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
- GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
- parent.pixbufSizeSet = true;
- parent.pixbufHeight = iHeight;
- parent.pixbufWidth = iWidth;
- /*
- * Feature in GTK: a Tree with the style SWT.VIRTUAL has
- * fixed-height-mode enabled. This will limit the size of
- * any cells, including renderers. In order to prevent
- * images from disappearing/being cropped, we re-create
- * the renderers when the first image is set. Fix for
- * bug 480261.
- */
- if ((parent.style & SWT.VIRTUAL) != 0) {
- /*
- * Only re-create SWT.CHECK renderers if this is the first column.
- * Otherwise check-boxes will be rendered in columns they are not
- * supposed to be rendered in. See bug 513761.
- */
- boolean check = modelIndex == Tree.FIRST_COLUMN && (parent.style & SWT.CHECK) != 0;
- parent.createRenderers(column, modelIndex, check, parent.style);
- }
- }
- }
- } else {
- /*
- * Bug 483112: We check to see if the cached value is greater than the size of the pixbufRenderer.
- * If it is, then we change the size of the pixbufRenderer accordingly.
- * Bug 489025: There is a corner case where the below is triggered when current(Width|Height) is -1,
- * which results in icons being set to 0. Fix is to compare only positive sizes.
- */
- if (parent.pixbufWidth > Math.max(currentWidth [0], 0) || parent.pixbufHeight > Math.max(currentHeight [0], 0)) {
- GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, parent.pixbufWidth, parent.pixbufHeight);
+ if (DPIUtil.useCairoAutoScale()) {
+ /*
+ * Bug in GTK the default renderer does scale again on pixbuf.
+ * Need to scaledown here and no need to scaledown id device scale is 1
+ */
+ if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
+ Rectangle imgSize = image.getBounds();
+ long /*int*/ scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
+ if (scaledPixbuf !=0) {
+ pixbuf = scaledPixbuf;
}
}
}
- GTK.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, pixbuf, -1);
- /*
- * Bug in GTK. When using fixed-height-mode, GTK does not recalculate the cell renderer width
- * when the image is changed in the model. The fix is to force it to recalculate the width if
- * more space is required.
- */
- if ((parent.style & SWT.VIRTUAL) != 0 && parent.currentItem == null) {
+ long /*int*/parentHandle = parent.handle;
+ long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
+ long /*int*/ pixbufRenderer = parent.getPixbufRenderer (column);
+ int [] currentWidth = new int [1];
+ int [] currentHeight= new int [1];
+ GTK.gtk_cell_renderer_get_fixed_size (pixbufRenderer, currentWidth, currentHeight);
+ if (!parent.pixbufSizeSet) {
if (image != null) {
- long /*int*/parentHandle = parent.handle;
- long /*int*/ column = GTK.gtk_tree_view_get_column (parentHandle, index);
- int [] w = new int [1];
- long /*int*/ pixbufRenderer = parent.getPixbufRenderer(column);
- gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
- int iWidth;
- if (GTK.GTK3 && DPIUtil.useCairoAutoScale()) {
+ int iWidth, iHeight;
+ if (DPIUtil.useCairoAutoScale()) {
iWidth = image.getBounds ().width;
+ iHeight = image.getBounds ().height;
} else {
iWidth = image.getBoundsInPixels ().width;
+ iHeight = image.getBoundsInPixels ().height;
}
- if (w[0] < iWidth) {
+ if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) {
+ GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight);
+ parent.pixbufSizeSet = true;
+ parent.pixbufHeight = iHeight;
+ parent.pixbufWidth = iWidth;
/*
- * There is no direct way to clear the cell renderer width so we
- * are relying on the fact that it is done as part of modifying
- * the style.
+ * Feature in GTK: a Tree with the style SWT.VIRTUAL has
+ * fixed-height-mode enabled. This will limit the size of
+ * any cells, including renderers. In order to prevent
+ * images from disappearing/being cropped, we re-create
+ * the renderers when the first image is set. Fix for
+ * bug 480261.
*/
- if (!GTK.GTK3) {
- long /*int*/ style = GTK.gtk_widget_get_modifier_style (parentHandle);
- parent.modifyStyle (parentHandle, style);
+ if ((parent.style & SWT.VIRTUAL) != 0) {
+ /*
+ * Only re-create SWT.CHECK renderers if this is the first column.
+ * Otherwise check-boxes will be rendered in columns they are not
+ * supposed to be rendered in. See bug 513761.
+ */
+ boolean check = modelIndex == Tree.FIRST_COLUMN && (parent.style & SWT.CHECK) != 0;
+ parent.createRenderers(column, modelIndex, check, parent.style);
}
}
}
+ } else {
+ /*
+ * Bug 483112: We check to see if the cached value is greater than the size of the pixbufRenderer.
+ * If it is, then we change the size of the pixbufRenderer accordingly.
+ * Bug 489025: There is a corner case where the below is triggered when current(Width|Height) is -1,
+ * which results in icons being set to 0. Fix is to compare only positive sizes.
+ */
+ if (parent.pixbufWidth > Math.max(currentWidth [0], 0) || parent.pixbufHeight > Math.max(currentHeight [0], 0)) {
+ GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, parent.pixbufWidth, parent.pixbufHeight);
+ }
}
+ GTK.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, pixbuf, -1);
cached = true;
updated = true;
}

Back to the top