summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnatoly Spektor <aspektor@redhat.com>2012-08-28 11:07:03 -0400
committerAnatoly Spektor <aspektor@redhat.com>2012-08-28 11:07:03 -0400
commit97be2e59da48ecf0ac05d0b55b7e587b8dd04bb7 (patch)
tree81ac24305d7e14df4d815b74a52624cf1934bfff
parent4764388a0a9afb9e042874f30979a69aae6fd14c (diff)
parentf9c7f286716e1457f10365cf85e9924d4a2e869b (diff)
downloadeclipse.platform.swt-97be2e59da48ecf0ac05d0b55b7e587b8dd04bb7.tar.gz
eclipse.platform.swt-97be2e59da48ecf0ac05d0b55b7e587b8dd04bb7.tar.xz
eclipse.platform.swt-97be2e59da48ecf0ac05d0b55b7e587b8dd04bb7.zip
Merge branch 'master' of http://git.eclipse.org/gitroot/platform/eclipse.platform.swt.git
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java179
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java101
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java119
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java96
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java11
26 files changed, 287 insertions, 733 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 2319721824..c5f471ed11 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -1486,7 +1486,7 @@ boolean gestureEvent(int /*long*/ id, int /*long*/ eventPtr, int detail) {
break;
}
case SWT.GESTURE_MAGNIFY:
- display.magnification += nsEvent.magnification();
+ display.magnification *= (1.0 + nsEvent.magnification());
event.magnification = display.magnification;
break;
case SWT.GESTURE_PAN:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index b4a341f417..7649674a1a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -752,17 +752,10 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* resized so that it will draw wrapped.
*/
if (wrap) {
- int boxWidth = 0;
- int boxHeight = 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(boxHandle, allocation);
- boxWidth = allocation.width;
- boxHeight = allocation.height;
- } else {
- boxWidth = OS.GTK_WIDGET_WIDTH (boxHandle);
- boxHeight = OS.GTK_WIDGET_HEIGHT (boxHandle);
- }
+ gtk_widget_get_allocation (boxHandle, allocation);
+ int boxWidth = allocation.width;
+ int boxHeight = allocation.height;
int /*long*/ labelLayout = OS.gtk_label_get_layout (labelHandle);
int pangoWidth = OS.pango_layout_get_width (labelLayout);
OS.pango_layout_set_width (labelLayout, -1);
@@ -785,12 +778,6 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (boxHandle, requisition);
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(boxHandle, allocation);
- } else {
- allocation.x = OS.GTK_WIDGET_X (boxHandle);
- allocation.y = OS.GTK_WIDGET_Y (boxHandle);
- }
allocation.width = boxWidth;
allocation.height = boxHeight;
OS.gtk_widget_size_allocate (boxHandle, allocation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 09e5150b5b..9f6c6ba29f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -605,16 +605,12 @@ public Rectangle getClientArea () {
}
forceResize ();
int /*long*/ clientHandle = clientHandle ();
- int width = 0;
- int height = 0;
- GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+ int width = 0, height = 0;
+ if ((state & ZERO_WIDTH) == 0) {
+ GtkAllocation allocation = new GtkAllocation();
+ gtk_widget_get_allocation (clientHandle, allocation);
+ width = allocation.width;
+ height = allocation.height;
}
return new Rectangle (0, 0, width, height);
}
@@ -622,14 +618,10 @@ public Rectangle getClientArea () {
}
int getClientWidth() {
+ if ((state & ZERO_WIDTH) != 0) return 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle (), allocation);
- return (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- } else {
- return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle ());
- }
-
+ gtk_widget_get_allocation(clientHandle (), allocation);
+ return allocation.width;
}
/**
@@ -1217,20 +1209,11 @@ void moveChildren(int oldWidth) {
for (int i = 0; i < children.length; i++) {
Control child = children[i];
int /*long*/ topHandle = child.topHandle ();
- int x = 0;
- int y = 0;
- int controlWidth = 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- } else {
- x = OS.GTK_WIDGET_X (topHandle);
- y = OS.GTK_WIDGET_Y (topHandle);
- controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
if (oldWidth > 0) x = oldWidth - controlWidth - x;
int clientWidth = getClientWidth ();
x = clientWidth - controlWidth - x;
@@ -1247,12 +1230,6 @@ void moveChildren(int oldWidth) {
gtk_widget_size_request (topHandle, requisition);
allocation.x = x;
allocation.y = y;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- } else {
- allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
- allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
- }
OS.gtk_widget_size_allocate (topHandle, allocation);
Control control = child.findBackgroundControl ();
if (control != null && control.backgroundImage != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index fb6ac2cc49..7993e54757 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -682,14 +682,7 @@ void forceResize () {
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (topHandle, requisition);
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- } else {
- allocation.x = OS.GTK_WIDGET_X (topHandle);
- allocation.y = OS.GTK_WIDGET_Y (topHandle);
- allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
- allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation(topHandle, allocation);
OS.gtk_widget_size_allocate (topHandle, allocation);
}
@@ -741,23 +734,12 @@ Accessible _getAccessible () {
public Rectangle getBounds () {
checkWidget();
int /*long*/ topHandle = topHandle ();
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 :allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (topHandle);
- y = OS.GTK_WIDGET_Y (topHandle);
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 :allocation.height;
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
return new Rectangle (x, y, width, height);
}
@@ -856,33 +838,25 @@ void resizeHandle (int width, int height) {
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int /*long*/ topHandle = topHandle ();
boolean sendMove = move;
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (topHandle, allocation);
if ((parent.style & SWT.MIRRORED) != 0) {
int clientWidth = parent.getClientWidth ();
- int oldWidth = 0;
- int oldX = 0;
- GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- oldX = clientWidth - oldWidth - allocation.x;
- } else {
- oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- oldX = clientWidth - oldWidth - OS.GTK_WIDGET_X (topHandle);
- }
-
+ int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int oldX = clientWidth - oldWidth - allocation.x;
if (move) {
sendMove &= x != oldX;
x = clientWidth - (resize ? width : oldWidth) - x;
} else {
move = true;
x = clientWidth - (resize ? width : oldWidth) - oldX;
- y = OS.GTK_WIDGET_Y (topHandle);
+ y = allocation.y;
}
}
boolean sameOrigin = true, sameExtent = true;
if (move) {
- int oldX = OS.GTK_WIDGET_X (topHandle);
- int oldY = OS.GTK_WIDGET_Y (topHandle);
+ int oldX = allocation.x;
+ int oldY = allocation.y;
sameOrigin = x == oldX && y == oldY;
if (!sameOrigin) {
if (enableWindow != 0) {
@@ -893,17 +867,8 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
}
int clientWidth = 0;
if (resize) {
- int oldWidth = 0;
- int oldHeight = 0;
- GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
sameExtent = width == oldWidth && height == oldHeight;
if (!sameExtent && (style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
if (!sameExtent && !(width == 0 && height == 0)) {
@@ -926,29 +891,13 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (topHandle, requisition);
- GtkAllocation allocation = new GtkAllocation ();
if (move) {
allocation.x = x;
allocation.y = y;
- } else {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- } else {
- allocation.x = OS.GTK_WIDGET_X (topHandle);
- allocation.y = OS.GTK_WIDGET_Y (topHandle);
- }
-
}
if (resize) {
allocation.width = width;
allocation.height = height;
- } else {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- } else {
- allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
- allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
- }
}
OS.gtk_widget_size_allocate (topHandle, allocation);
}
@@ -1007,24 +956,12 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
public Point getLocation () {
checkWidget();
int /*long*/ topHandle = topHandle ();
- int x = 0;
- int y = 0;
- int width = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- } else {
- x = OS.GTK_WIDGET_X (topHandle);
- y = OS.GTK_WIDGET_Y (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
if ((parent.style & SWT.MIRRORED) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- } else {
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- }
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
x = parent.getClientWidth () - width - x;
}
return new Point (x, y);
@@ -1085,17 +1022,13 @@ public void setLocation(int x, int y) {
*/
public Point getSize () {
checkWidget();
- int /*long*/ topHandle = topHandle ();
- int width = 0;
- int height = 0;
- GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ int width = 0, height = 0;
+ if ((state & ZERO_WIDTH) == 0) {
+ int /*long*/ topHandle = topHandle ();
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (topHandle, allocation);
+ width = allocation.width;
+ height = allocation.height;
}
return new Point (width, height);
}
@@ -3100,18 +3033,19 @@ int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
}
int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
- if (!hasFocus ()) return 0;
GdkEventKey gdkEvent = new GdkEventKey ();
OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+
+ if (filterKey (gdkEvent.keyval, event)) return 1;
+ // widget could be disposed at this point
+ if (isDisposed ()) return 0;
+
+ if (!hasFocus ()) return 0;
if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1;
// widget could be disposed at this point
if (isDisposed ()) return 0;
- if (filterKey (gdkEvent.keyval, event)) return 1;
- // widget could be disposed at this point
- if (isDisposed ()) return 0;
-
if (translateTraversal (gdkEvent)) return 1;
// widget could be disposed at this point
if (isDisposed ()) return 0;
@@ -4045,19 +3979,11 @@ public void setEnabled (boolean enabled) {
int /*long*/ topHandle = topHandle ();
GdkWindowAttr attributes = new GdkWindowAttr ();
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
-
- } else {
- attributes.x = OS.GTK_WIDGET_X (topHandle);
- attributes.y = OS.GTK_WIDGET_Y (topHandle);
- attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask);
attributes.wclass = OS.GDK_INPUT_ONLY;
attributes.window_type = OS.GDK_WINDOW_CHILD;
@@ -4312,27 +4238,18 @@ public boolean setParent (Composite parent) {
if (!isReparentable ()) return false;
OS.gtk_widget_realize (parent.handle);
int /*long*/ topHandle = topHandle ();
- int x = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- x = allocation.x;
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (topHandle);
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
if ((this.parent.style & SWT.MIRRORED) != 0) {
x = this.parent.getClientWidth () - width - x;
}
if ((parent.style & SWT.MIRRORED) != 0) {
x = parent.getClientWidth () - width - x;
}
- int y = OS.GTK_WIDGET_Y (topHandle);
releaseParent ();
Shell newShell = parent.getShell (), oldShell = getShell ();
Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
@@ -4349,12 +4266,14 @@ public boolean setParent (Composite parent) {
* on a toolbar or on a widget hierarchy containing a toolbar. The fix is
* to reparent by removing the widget from its current parent and adding it
* to the new parent.
+ *
+ * Temporarily put back for bug#387496.
*/
-// OS.gtk_widget_reparent(topHandle, newParent);
- OS.g_object_ref (topHandle);
- OS.gtk_container_remove (OS.gtk_widget_get_parent (topHandle), topHandle);
- OS.gtk_container_add (newParent, topHandle);
- OS.g_object_unref (topHandle);
+ OS.gtk_widget_reparent(topHandle, newParent);
+// OS.g_object_ref (topHandle);
+// OS.gtk_container_remove (OS.gtk_widget_get_parent (topHandle), topHandle);
+// OS.gtk_container_add (newParent, topHandle);
+// OS.g_object_unref (topHandle);
OS.gtk_fixed_move (newParent, topHandle, x, y);
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index 1bdae2b97b..5b4887b7f9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -453,14 +453,9 @@ void setScrollbar () {
OS.gtk_adjustment_changed (adjustmentHandle);
int policy = maxHeight > height ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, policy);
- int width = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(fixedHandle, allocation);
- width = allocation.width - spacing * 2;
- } else {
- width = OS.GTK_WIDGET_WIDTH (fixedHandle) - spacing * 2;
- }
+ gtk_widget_get_allocation (fixedHandle, allocation);
+ int width = allocation.width - spacing * 2;
if (policy == OS.GTK_POLICY_ALWAYS) {
int /*long*/ vHandle = 0;
if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index 7da2a5e5bf..d312929e94 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
@@ -266,12 +266,8 @@ public boolean getExpanded () {
public int getHeaderHeight () {
checkWidget ();
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- return allocation.height - (expanded ? height : 0);
- } else {
- return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ return allocation.height - (expanded ? height : 0);
}
/**
@@ -384,31 +380,16 @@ void releaseWidget () {
}
void resizeControl (int yScroll) {
- GtkAllocation allocation = new GtkAllocation ();
if (control != null && !control.isDisposed ()) {
boolean visible = OS.gtk_expander_get_expanded (handle);
if (visible) {
- int x = 0;
- int y = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- } else {
- x = OS.GTK_WIDGET_X (clientHandle);
- y = OS.GTK_WIDGET_Y (clientHandle);
- }
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (clientHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
if (x != -1 && y != -1) {
- int width = 0;
- int height = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (clientHandle);
- height = OS.GTK_WIDGET_HEIGHT (clientHandle);
- }
+ int width = allocation.width;
+ int height = allocation.height;
int [] property = new int [1];
OS.gtk_widget_style_get (handle, OS.focus_line_width, property, 0);
y += property [0] * 2;
@@ -425,12 +406,8 @@ void resizeControl (int yScroll) {
ScrollBar vBar = parent.verticalBar;
if (vBar != null) {
if (gtk_widget_get_visible (vBar.handle)) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(parent.scrolledHandle, allocation);
- width = allocation.width - parent.vScrollBarWidth () - 2 * parent.spacing;
- } else {
- width = OS.GTK_WIDGET_WIDTH (parent.scrolledHandle) - parent.vScrollBarWidth () - 2 * parent.spacing;
- }
+ gtk_widget_get_allocation (parent.scrolledHandle, allocation);
+ width = allocation.width - parent.vScrollBarWidth () - 2 * parent.spacing;
}
}
control.setBounds (x, y - yScroll, width, Math.max (0, height), true, true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 4351547a44..0045057364 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -109,17 +109,10 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
forceResize ();
- int clientX = 0;
- int clientY = 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- clientX = allocation.x;
- clientY = allocation.y;
- } else {
- clientX = OS.GTK_WIDGET_X (clientHandle);
- clientY = OS.GTK_WIDGET_Y (clientHandle);
- }
+ gtk_widget_get_allocation (clientHandle, allocation);
+ int clientX = allocation.x;
+ int clientY = allocation.y;
x -= clientX;
y -= clientY;
width += clientX + clientX;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 66ffce244d..4885a1b520 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -465,17 +465,10 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* resized so that it will draw wrapped.
*/
if (fixWrap) {
- int labelWidth = 0;
- int labelHeight = 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- labelWidth = allocation.width;
- labelHeight = allocation.height;
- } else {
- labelWidth = OS.GTK_WIDGET_WIDTH (handle);
- labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int labelWidth = allocation.width;
+ int labelHeight = allocation.height;
OS.gtk_widget_set_size_request (labelHandle, labelWidth, labelHeight);
/*
* Bug in GTK. Setting the size request should invalidate the label's
@@ -483,12 +476,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (labelHandle, requisition);
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(labelHandle, allocation);
- } else {
- allocation.x = OS.GTK_WIDGET_X (labelHandle);
- allocation.y = OS.GTK_WIDGET_Y (labelHandle);
- }
+ gtk_widget_get_allocation(labelHandle, allocation);
allocation.width = labelWidth;
allocation.height = labelHeight;
OS.gtk_widget_size_allocate (labelHandle, allocation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 9afefbb3ef..2bceea8310 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -262,13 +262,10 @@ Rectangle [] getRectangles (int linkIndex) {
}
int getClientWidth () {
+ if ((state & ZERO_WIDTH) != 0) return 0;
GtkAllocation allocation = new GtkAllocation();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- return (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- } else {
- return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ return allocation.width;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 7a45c3af0d..5bb5e3e674 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -378,24 +378,12 @@ void fixMenus (Decorations newParent) {
int /*long*/ window = gtk_widget_get_window (handle);
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = origin_x [0] + allocation.x;
- y = origin_x [0] + allocation.y;
- width = allocation.width;
- height = allocation.height;
- } else {
- x = origin_x [0] + OS.GTK_WIDGET_X (handle);
- y = origin_y [0] + OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
-
+ gtk_widget_get_allocation (handle, allocation);
+ int x = origin_x [0] + allocation.x;
+ int y = origin_x [0] + allocation.y;
+ int width = allocation.width;
+ int height = allocation.height;
return new Rectangle (x, y, width, height);
}
@@ -960,11 +948,7 @@ public void setDefaultItem (MenuItem item) {
*/
public void setEnabled (boolean enabled) {
checkWidget();
- if (enabled) {
- OS.gtk_widget_set_sensitive (handle, true);
- } else {
- OS.gtk_widget_set_sensitive (handle, false);
- }
+ OS.gtk_widget_set_sensitive (handle, enabled);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index ccaa1c62ec..40c3504191 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -322,23 +322,12 @@ int /*long*/ getAccelGroup () {
if (!gtk_widget_get_mapped (handle)) {
return new Rectangle (0, 0, 0, 0);
}
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = allocation.width;
- height = allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (handle);
- y = OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = allocation.width;
+ int height = allocation.height;
return new Rectangle (x, y, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index c5f7d7e901..3dfad2887d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -177,23 +177,12 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr)
OS.gdk_window_get_origin (window, origin_x, origin_y);
startX = (int) (gdkEvent.x_root - origin_x [0]);
startY = (int) (gdkEvent.y_root - origin_y [0]);
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = allocation.width;
- height = allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (handle);
- y = OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation(handle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = allocation.width;
+ int height = allocation.height;
lastX = x;
lastY = y;
Event event = new Event ();
@@ -232,17 +221,10 @@ int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ eventPt
if (button != 1) return 0;
if (!dragging) return 0;
dragging = false;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
Event event = new Event ();
event.time = gdkEvent.time;
event.x = lastX;
@@ -268,14 +250,9 @@ int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
// widget could be disposed at this point
if (handle != 0) {
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- lastX = allocation.x;
- lastY = allocation.y;
- } else {
- lastX = OS.GTK_WIDGET_X (handle);
- lastY = OS.GTK_WIDGET_Y (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ lastX = allocation.x;
+ lastY = allocation.y;
}
return 0;
}
@@ -301,25 +278,14 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
if (keyval == OS.GDK_Left ||keyval == OS.GDK_Right) break;
yChange = keyval == OS.GDK_Up ? -stepSize : stepSize;
}
- int width = 0;
- int height = 0;
int parentBorder = 0;
- int parentWidth = 0;
- int parentHeight = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- width = allocation.width;
- height = allocation.height;
- OS.gtk_widget_get_allocation(parent.handle, allocation);
- parentWidth = allocation.width;
- parentHeight = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
- parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
+ gtk_widget_get_allocation (parent.handle, allocation);
+ int parentWidth = allocation.width;
+ int parentHeight = allocation.height;
int newX = lastX, newY = lastY;
if ((style & SWT.VERTICAL) != 0) {
newX = Math.min (Math.max (0, lastX + xChange - parentBorder - startX), parentWidth - width);
@@ -389,31 +355,16 @@ int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ eventPtr
eventState = gdkEvent.state;
}
if ((eventState & OS.GDK_BUTTON1_MASK) == 0) return 0;
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
- int parentBorder = 0;
- int parentWidth = 0;
- int parentHeight = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = allocation.width;
- height = allocation.height;
- OS.gtk_widget_get_allocation(parent.handle, allocation);
- parentWidth = allocation.width;
- parentHeight = allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (handle);
- y = OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
- parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = allocation.width;
+ int height = allocation.height;
+ int parentBorder = 0;
+ gtk_widget_get_allocation (parent.handle, allocation);
+ int parentWidth = allocation.width;
+ int parentHeight = allocation.height;
int newX = lastX, newY = lastY;
if ((style & SWT.VERTICAL) != 0) {
newX = Math.min (Math.max (0, eventX + x - startX - parentBorder), parentWidth - width);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index f738c23278..e09afe3c7b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -343,28 +343,17 @@ public Rectangle getThumbBounds () {
gtk_range_get_slider_range (handle, slider_start, slider_end);
int x, y, width, height;
GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (handle, allocation);
if ((style & SWT.VERTICAL) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = allocation.x;
- width = allocation.width;
- } else {
- x = OS.GTK_WIDGET_X (handle);
- width = OS.GTK_WIDGET_WIDTH (handle);
- }
+ x = allocation.x;
y = slider_start [0];
+ width = allocation.width;
height = slider_end [0] - slider_start [0];
} else {
x = slider_start [0];
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- y = allocation.y;
- height = allocation.height;
- } else {
- y = OS.GTK_WIDGET_Y (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ y = allocation.y;
width = slider_end [0] - slider_start [0];
+ height = allocation.height;
}
Rectangle rect = new Rectangle(x, y, width, height);
int [] origin_x = new int [1], origin_y = new int [1];
@@ -406,25 +395,14 @@ public Rectangle getThumbTrackBounds () {
OS.gtk_widget_style_get (handle, OS.has_secondary_forward_stepper, has_stepper, 0);
boolean hasD = has_stepper[0] != 0;
GtkAllocation allocation = new GtkAllocation ();
- int stepperSize = 0;
+ gtk_widget_get_allocation (handle, allocation);
if ((style & SWT.VERTICAL) != 0) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- stepperSize = allocation.width;
- x = allocation.x;
- } else {
- stepperSize = OS.GTK_WIDGET_WIDTH (handle);
- x = OS.GTK_WIDGET_X (handle);
- }
+ int stepperSize = allocation.width;
+ x = allocation.x;
if (hasA) y += stepperSize;
if (hasB) y += stepperSize;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- width = allocation.width;
- height = allocation.height - y;
- } else {
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle) - y;
- }
+ width = allocation.width;
+ height = allocation.height - y;
if (hasC) height -= stepperSize;
if (hasD) height -= stepperSize;
if (height < 0) {
@@ -434,28 +412,14 @@ public Rectangle getThumbTrackBounds () {
height = 0;
}
} else {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- stepperSize = allocation.height;
- } else {
- stepperSize = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ int stepperSize = allocation.height;
if (hasA) x += stepperSize;
if (hasB) x += stepperSize;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- y = allocation.y;
- width = allocation.width -x;
- } else {
- y = OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle) - x;
- }
+ y = allocation.y;
+ width = allocation.width -x;
if (hasC) width -= stepperSize;
if (hasD) width -= stepperSize;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- height = allocation.height;
- } else {
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ height = allocation.height;
if (width < 0) {
int [] slider_start = new int [1], slider_end = new int [1];
gtk_range_get_slider_range (handle, slider_start, slider_end);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index c08b0f3994..89f5371ec5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -204,23 +204,12 @@ public Rectangle getClientArea () {
checkWidget ();
forceResize ();
int /*long*/ clientHandle = clientHandle ();
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (clientHandle);
- y = OS.GTK_WIDGET_Y (clientHandle);
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
- }
+ gtk_widget_get_allocation (clientHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
return new Rectangle (x, y, width, height);
}
/**
@@ -378,14 +367,9 @@ void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boole
GdkRectangle rect = new GdkRectangle ();
if (redrawAll) {
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- rect.width = allocation.width;
- rect.height = allocation.height;
- } else {
- rect.width = OS.GTK_WIDGET_WIDTH (topHandle);
- rect.height = OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ rect.width = allocation.width;
+ rect.height = allocation.height;
} else {
int [] destX = new int [1], destY = new int [1];
OS.gtk_widget_translate_coordinates (paintHandle, topHandle, x, y, destX, destY);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index b48eeea42e..91bc955651 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -451,17 +451,10 @@ void addToolTip (ToolTip toolTip) {
void adjustTrim () {
if (display.ignoreTrim) return;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(shellHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (shellHandle);
- height = OS.GTK_WIDGET_HEIGHT (shellHandle);
- }
+ gtk_widget_get_allocation (shellHandle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
int /*long*/ window = gtk_widget_get_window (shellHandle);
GdkRectangle rect = new GdkRectangle ();
OS.gdk_window_get_frame_extents (window, rect);
@@ -644,14 +637,9 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
trim.height += trimHeight + border * 2;
if (menuBar != null) {
forceResize ();
- int menuBarHeight = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(menuBar.handle, allocation);
- menuBarHeight = allocation.height;
- } else {
- menuBarHeight = OS.GTK_WIDGET_HEIGHT (menuBar.handle);
- }
+ gtk_widget_get_allocation (menuBar.handle, allocation);
+ int menuBarHeight = allocation.height;
trim.y -= menuBarHeight;
trim.height += menuBarHeight;
}
@@ -909,12 +897,8 @@ void fixStyle (int /*long*/ handle) {
void forceResize () {
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(vboxHandle, allocation);
- forceResize (allocation.width, allocation.height);
- } else {
- forceResize (OS.GTK_WIDGET_WIDTH (vboxHandle), OS.GTK_WIDGET_HEIGHT (vboxHandle));
- }
+ gtk_widget_get_allocation (vboxHandle, allocation);
+ forceResize (allocation.width, allocation.height);
}
void forceResize (int width, int height) {
@@ -953,17 +937,10 @@ public int getAlpha () {
}
int getResizeMode (double x, double y) {
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(shellHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (shellHandle);
- height = OS.GTK_WIDGET_HEIGHT (shellHandle);
- }
+ gtk_widget_get_allocation (shellHandle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
int border = OS.gtk_container_get_border_width (shellHandle);
int mode = 0;
if (y >= height - border) {
@@ -1086,17 +1063,10 @@ public boolean getModified () {
public Point getSize () {
checkWidget ();
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(vboxHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (vboxHandle);
- height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
- }
+ gtk_widget_get_allocation (vboxHandle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
border = OS.gtk_container_get_border_width (shellHandle);
@@ -1206,14 +1176,9 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
display.resizeBoundsX = x [0];
display.resizeBoundsY = y [0];
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(shellHandle, allocation);
- display.resizeBoundsWidth = allocation.width;
- display.resizeBoundsHeight = allocation.height;
- } else {
- display.resizeBoundsWidth = OS.GTK_WIDGET_WIDTH (shellHandle);
- display.resizeBoundsHeight = OS.GTK_WIDGET_HEIGHT (shellHandle);
- }
+ gtk_widget_get_allocation (shellHandle, allocation);
+ display.resizeBoundsWidth = allocation.width;
+ display.resizeBoundsHeight = allocation.height;
}
}
return 0;
@@ -1424,17 +1389,10 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
}
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
- int width = 0;
- int height = 0;
GtkAllocation widgetAllocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(shellHandle, widgetAllocation);
- width = widgetAllocation.width;
- height = widgetAllocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (shellHandle);
- height = OS.GTK_WIDGET_HEIGHT (shellHandle);
- }
+ gtk_widget_get_allocation (shellHandle, widgetAllocation);
+ int width = widgetAllocation.width;
+ int height = widgetAllocation.height;
if (!resized || oldWidth != width || oldHeight != height) {
oldWidth = width;
oldHeight = height;
@@ -1915,17 +1873,10 @@ public void setMenuBar (Menu menu) {
createAccelGroup ();
menuBar.addAccelerators (accelGroup);
}
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(vboxHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (vboxHandle);
- height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
- }
+ gtk_widget_get_allocation (vboxHandle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
resizeBounds (width, height, !both);
}
@@ -2209,17 +2160,10 @@ int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*lon
int monitorNumber = OS.gdk_screen_get_monitor_at_point (screen, x[0], y[0]);
GdkRectangle dest = new GdkRectangle ();
OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
if (x[0] + width > dest.x + dest.width) {
x [0] = (dest.x + dest.width) - width;
}
@@ -2411,17 +2355,10 @@ public Rectangle getBounds () {
checkWidget ();
int [] x = new int [1], y = new int [1];
OS.gtk_window_get_position (shellHandle, x, y);
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(vboxHandle, allocation);
- width = allocation.width;
- height = allocation.height;
- } else {
- width = OS.GTK_WIDGET_WIDTH (vboxHandle);
- height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
- }
+ gtk_widget_get_allocation (vboxHandle, allocation);
+ int width = allocation.width;
+ int height = allocation.height;
int border = 0;
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
border = OS.gtk_container_get_border_width (shellHandle);
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 b1e3bbd1f9..6e3cb9f984 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
@@ -166,32 +166,17 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
forceResize ();
int /*long*/ clientHandle = clientHandle ();
- int clientX = 0;
- int clientY = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- clientX = allocation.x;
- clientY = allocation.y;
- } else {
- clientX = OS.GTK_WIDGET_X (clientHandle);
- clientY = OS.GTK_WIDGET_Y (clientHandle);
- }
+ gtk_widget_get_allocation (clientHandle, allocation);
+ int clientX = allocation.x;
+ int clientY = allocation.y;
x -= clientX;
y -= clientY;
width += clientX + clientX;
if ((style & SWT.BOTTOM) != 0) {
- int parentHeight = 0;
- int clientHeight = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- clientHeight = allocation.height;
- OS.gtk_widget_get_allocation(handle, allocation);
- parentHeight = allocation.height;
- } else {
- parentHeight = OS.GTK_WIDGET_HEIGHT (handle);
- clientHeight = OS.GTK_WIDGET_HEIGHT (clientHandle);
- }
+ int clientHeight = allocation.height;
+ gtk_widget_get_allocation (handle, allocation);
+ int parentHeight = allocation.height;
height += parentHeight - clientHeight;
} else {
height += clientX + clientY;
@@ -202,6 +187,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
void createHandle (int index) {
state |= HANDLE;
fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
gtk_widget_set_has_window (fixedHandle, true);
handle = OS.gtk_notebook_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
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 ed57668988..8a5b3fcde0 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
@@ -150,23 +150,12 @@ void destroyWidget () {
*/
public Rectangle getBounds () {
checkWidget();
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (handle);
- y = OS.GTK_WIDGET_Y (handle);
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
return new Rectangle (x, y, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 1b38aa9357..68a5709493 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -541,8 +541,7 @@ void createColumn (TableColumn column, int index) {
}
}
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
}
}
int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
@@ -990,8 +989,7 @@ void destroyItem (TableColumn column) {
}
}
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
createColumn (null, 0);
} else {
for (int i=0; i<itemCount; i++) {
@@ -1126,16 +1124,12 @@ public Rectangle getClientArea () {
int [] fixedX = new int [1], fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
int /*long*/ clientHandle = clientHandle ();
- int width = 0;
- int height = 0;
- GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+ int width = 0, height = 0;
+ if ((state & ZERO_WIDTH) == 0) {
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (clientHandle, allocation);
+ width = allocation.width;
+ height = allocation.height;
}
return new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
}
@@ -3092,6 +3086,17 @@ public void setLinesVisible (boolean show) {
}
}
+void setModel (int /*long*/ newModel) {
+ display.removeWidget (modelHandle);
+ OS.g_object_unref (modelHandle);
+ modelHandle = newModel;
+ display.addWidget (modelHandle, this);
+ if (fixAccessibility ()) {
+ OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.closures [ROW_INSERTED], true);
+ OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.closures [ROW_DELETED], true);
+ }
+}
+
void setOrientation (boolean create) {
super.setOrientation (create);
for (int i=0; i<itemCount; i++) {
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 740f2dc6b4..8f2bca2160 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
@@ -388,17 +388,10 @@ int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
useFixedWidth = false;
- int x = 0;
- int width = 0;
GtkAllocation widgetAllocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation (widget, widgetAllocation);
- x = widgetAllocation.x;
- width = widgetAllocation.width;
- } else {
- x = OS.GTK_WIDGET_X (widget);
- width = OS.GTK_WIDGET_WIDTH (widget);
- }
+ gtk_widget_get_allocation (widget, widgetAllocation);
+ int x = widgetAllocation.x;
+ int width = widgetAllocation.width;
if (x != lastX) {
lastX = x;
sendEvent (SWT.Move);
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 c040f92753..821beed3b0 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
@@ -389,15 +389,10 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
event.detail = SWT.ARROW;
int /*long*/ topHandle = currentFocusItem.topHandle ();
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- event.x = allocation.x;
- event.y = allocation.y + allocation.height;
- } else {
- event.x = OS.GTK_WIDGET_X (topHandle);
- event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
- }
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - OS.GTK_WIDGET_WIDTH(topHandle) - event.x;
+ gtk_widget_get_allocation (topHandle, allocation);
+ event.x = allocation.x;
+ event.y = allocation.y + allocation.height;
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - allocation.width - event.x;
currentFocusItem.sendSelectionEvent (SWT.Selection, event, false);
/*
* Stop GTK from processing the event further as key_down binding
@@ -469,16 +464,10 @@ int /*long*/ menuItemSelected (int /*long*/ widget, ToolItem item) {
*/
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(widget, allocation);
- event.x = allocation.x;
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
- } else {
- event.x = OS.GTK_WIDGET_X (widget);
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - OS.GTK_WIDGET_WIDTH (widget) - event.x;
- event.y = OS.GTK_WIDGET_Y (widget) + OS.GTK_WIDGET_HEIGHT (widget);
- }
+ gtk_widget_get_allocation (widget, allocation);
+ event.x = allocation.x;
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - allocation.width - event.x;
+ event.y = allocation.y + allocation.height;
break;
case SWT.RADIO :
if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio ();
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 40eb65b2a9..b6ae773f1f 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
@@ -316,20 +316,12 @@ public Rectangle getBounds () {
checkWidget();
parent.forceResize ();
int /*long*/ topHandle = topHandle ();
- int x, y, width, height;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- x = allocation.x;
- y = allocation.y;
- width = allocation.width;
- height = allocation.height;
- } else {
- x = OS.GTK_WIDGET_X (topHandle);
- y = OS.GTK_WIDGET_Y (topHandle);
- width = OS.GTK_WIDGET_WIDTH (topHandle);
- height = OS.GTK_WIDGET_HEIGHT (topHandle);
- }
+ gtk_widget_get_allocation (topHandle, allocation);
+ int x = allocation.x;
+ int y = allocation.y;
+ int width = allocation.width;
+ int height = allocation.height;
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
if ((style & SWT.SEPARATOR) != 0 && control != null) height = Math.max (height, 23);
return new Rectangle (x, y, width, height);
@@ -478,32 +470,18 @@ public int getWidth () {
checkWidget();
parent.forceResize ();
int /*long*/ topHandle = topHandle ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- GtkAllocation allocation = new GtkAllocation();
- OS.gtk_widget_get_allocation (topHandle, allocation);
- return allocation.width;
- } else {
- return OS.GTK_WIDGET_WIDTH (topHandle);
- }
+ GtkAllocation allocation = new GtkAllocation();
+ gtk_widget_get_allocation (topHandle, allocation);
+ return allocation.width;
}
int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
- double x = gdkEvent.x;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- gdkEvent.x += allocation.x;
- } else {
- gdkEvent.x += OS.GTK_WIDGET_X (handle);
- }
- double y = gdkEvent.y;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- gdkEvent.y += allocation.y;
- } else {
- gdkEvent.y += OS.GTK_WIDGET_Y (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ double x = gdkEvent.x + allocation.x;
+ double y = gdkEvent.y + allocation.y;
OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
int /*long*/ result = parent.gtk_button_press_event (widget, event);
gdkEvent.x = x;
@@ -515,20 +493,10 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
- double x = gdkEvent.x;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(handle, allocation);
- gdkEvent.x += allocation.x;
- } else {
- gdkEvent.x += OS.GTK_WIDGET_X (handle);
- }
- double y = gdkEvent.y;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- gdkEvent.y += allocation.y;
- } else {
- gdkEvent.y += OS.GTK_WIDGET_Y (handle);
- }
+ gtk_widget_get_allocation (handle, allocation);
+ double x = gdkEvent.x + allocation.x;
+ double y = gdkEvent.y + allocation.y;
OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
int /*long*/ result = parent.gtk_button_release_event (widget, event);
gdkEvent.x = x;
@@ -557,18 +525,12 @@ int /*long*/ gtk_clicked (int /*long*/ widget) {
OS.gdk_event_get_coords (eventPtr, x_win, y_win);
int x = 0;
int width = 0;
- GtkAllocation handleAllocation = new GtkAllocation ();
- GtkAllocation arrowHandleAllocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(arrowHandle, arrowHandleAllocation);
- OS.gtk_widget_get_allocation(handle, handleAllocation);
- x = arrowHandleAllocation.x - handleAllocation.x;
- width = arrowHandleAllocation.width;
- } else {
- x = OS.GTK_WIDGET_X (arrowHandle) - OS.GTK_WIDGET_X (handle);
- width = OS.GTK_WIDGET_WIDTH (arrowHandle);
- }
-
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (arrowHandle, allocation);
+ x = allocation.x;
+ width = allocation.width;
+ gtk_widget_get_allocation (handle, allocation);
+ x -= allocation.x;
if ((((parent.style & SWT.RIGHT_TO_LEFT) == 0) && x <= (int)x_win [0])
|| (((parent.style & SWT.RIGHT_TO_LEFT) != 0) && (int)x_win [0] <= x + width)) {
isArrow = true;
@@ -587,17 +549,10 @@ int /*long*/ gtk_clicked (int /*long*/ widget) {
if (isArrow) {
event.detail = SWT.ARROW;
GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(topHandle, allocation);
- event.x = allocation.x;
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - allocation.width - event.x;
- event.y = allocation.y + allocation.height;
- } else {
- event.x = OS.GTK_WIDGET_X (topHandle);
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - OS.GTK_WIDGET_WIDTH (topHandle) - event.x;
- event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
- }
-
+ gtk_widget_get_allocation (topHandle, allocation);
+ event.x = allocation.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - allocation.width - event.x;
+ event.y = allocation.y + allocation.height;
}
break;
}
@@ -906,8 +861,7 @@ void resizeHandle(int width, int height) {
GtkRequisition requisition = new GtkRequisition ();
parent.gtk_widget_size_request (handle, requisition);
GtkAllocation allocation = new GtkAllocation ();
- allocation.x = OS.GTK_WIDGET_X(handle);
- allocation.y = OS.GTK_WIDGET_Y(handle);
+ gtk_widget_get_allocation (handle, allocation);
allocation.width = width;
allocation.height = height;
OS.gtk_widget_size_allocate (handle, allocation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 13425ad071..1ee867b046 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -338,7 +338,7 @@ Point getLocation () {
int y = this.y;
if (item != null) {
int /*long*/ itemHandle = item.handle;
- if(OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
+ if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
GdkRectangle area = new GdkRectangle ();
OS.gtk_status_icon_get_geometry (itemHandle, 0, area, 0);
x = area.x + area.width / 2;
@@ -348,8 +348,10 @@ Point getLocation () {
int /*long*/ window = gtk_widget_get_window (itemHandle);
int [] px = new int [1], py = new int [1];
OS.gdk_window_get_origin (window, px, py);
- x = px [0] + OS.GTK_WIDGET_WIDTH (itemHandle) / 2;
- y = py [0] + OS.GTK_WIDGET_HEIGHT (itemHandle) / 2;
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (itemHandle, allocation);
+ x = px [0] + allocation.width / 2;
+ y = py [0] + allocation.height / 2;
}
}
if (x == -1 || y == -1) {
@@ -590,17 +592,10 @@ int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
GdkRectangle dest = new GdkRectangle ();
OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
- int w = 0;
- int h = 0;
GtkAllocation widgetAllocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation (widget, widgetAllocation);
- w = widgetAllocation.width;
- h = widgetAllocation.height;
- } else {
- w = OS.GTK_WIDGET_WIDTH (widget);
- h = OS.GTK_WIDGET_HEIGHT (widget);
- }
+ gtk_widget_get_allocation (widget, widgetAllocation);
+ int w = widgetAllocation.width;
+ int h = widgetAllocation.height;
if (dest.height < y + h) y -= h;
if (dest.width < x + w) x -= w;
OS.gtk_window_move (widget, x, y);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index 108a0830a0..917575298b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -316,18 +316,11 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr)
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
if (image != null && image.mask != 0) {
- int xoffset = 0;
- int yoffset = 0;
- GtkAllocation widgetAllocation = new GtkAllocation();
if (OS.gdk_drawable_get_depth (image.mask) == 1) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(widget, widgetAllocation);
- xoffset = (int) Math.floor (widgetAllocation.x + ((widgetAllocation.width -OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
- yoffset = (int) Math.floor (widgetAllocation.y + ((widgetAllocation.height - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
- } else {
- xoffset = (int) Math.floor (OS.GTK_WIDGET_X (widget) + ((OS.GTK_WIDGET_WIDTH (widget) - OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
- yoffset = (int) Math.floor (OS.GTK_WIDGET_Y (widget) + ((OS.GTK_WIDGET_HEIGHT (widget) - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
- }
+ GtkAllocation widgetAllocation = new GtkAllocation ();
+ gtk_widget_get_allocation (widget, widgetAllocation);
+ int xoffset = (int) Math.floor (widgetAllocation.x + ((widgetAllocation.width -OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
+ int yoffset = (int) Math.floor (widgetAllocation.y + ((widgetAllocation.height - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
Rectangle b = image.getBounds();
int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, b.width, b.height);
if (gdkImagePtr == 0) error(SWT.ERROR_NO_HANDLES);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 5f2cb67736..ac79e8b168 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -646,8 +646,7 @@ void createColumn (TreeColumn column, int index) {
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
copyModel (oldModel, FIRST_COLUMN, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, modelLength);
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
}
}
int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
@@ -994,10 +993,8 @@ void destroyItem (TreeColumn column) {
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
copyModel(oldModel, column.modelIndex, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, FIRST_COLUMN + CELL_TYPES);
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
createColumn (null, 0);
-
} else {
for (int i=0; i<items.length; i++) {
TreeItem item = items [i];
@@ -1127,16 +1124,12 @@ public Rectangle getClientArea () {
int [] fixedX = new int [1], fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
int /*long*/ clientHandle = clientHandle ();
- int height = 0;
- int width = 0;
- GtkAllocation allocation = new GtkAllocation ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(clientHandle, allocation);
- width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
- height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- } else {
- width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
- height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+ int height = 0, width = 0;
+ if ((state & ZERO_WIDTH) == 0) {
+ GtkAllocation allocation = new GtkAllocation ();
+ gtk_widget_get_allocation (clientHandle, allocation);
+ width = allocation.width;
+ height = allocation.height;
}
return new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
}
@@ -3027,6 +3020,17 @@ public void setLinesVisible (boolean show) {
}
}
+void setModel (int /*long*/ newModel) {
+ display.removeWidget (modelHandle);
+ OS.g_object_unref (modelHandle);
+ modelHandle = newModel;
+ display.addWidget (modelHandle, this);
+ if (fixAccessibility ()) {
+ OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.closures [ROW_INSERTED], true);
+ OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.closures [ROW_DELETED], true);
+ }
+}
+
void setOrientation (boolean create) {
super.setOrientation (create);
if (items != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index a362f0bbbc..29ba6ea279 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -391,16 +391,9 @@ int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
useFixedWidth = false;
GtkAllocation widgetAllocation = new GtkAllocation();
- int x = 0;
- int width = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_widget_get_allocation(widget, widgetAllocation);
- x = widgetAllocation.x;
- width = widgetAllocation.width;
- } else {
- x = OS.GTK_WIDGET_X (widget);
- width = OS.GTK_WIDGET_WIDTH (widget);
- }
+ gtk_widget_get_allocation (widget, widgetAllocation);
+ int x = widgetAllocation.x;
+ int width = widgetAllocation.width;
if (x != lastX) {
lastX = x;
sendEvent (SWT.Move);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 57ab0fc48e..465a0f733e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -898,6 +898,17 @@ int /*long*/ gtk_visibility_notify_event (int /*long*/ widget, int /*long*/ even
return 0;
}
+void gtk_widget_get_allocation (int /*long*/ widget, GtkAllocation allocation) {
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation (widget, allocation);
+ } else {
+ allocation.x = OS.GTK_WIDGET_X (widget);
+ allocation.y = OS.GTK_WIDGET_Y (widget);
+ allocation.width = OS.GTK_WIDGET_WIDTH (widget);
+ allocation.height = OS.GTK_WIDGET_HEIGHT (widget);
+ }
+}
+
boolean gtk_widget_get_mapped (int /*long*/ widget) {
if (OS.GTK_VERSION >= OS.VERSION (2, 20, 0)) {
return OS.gtk_widget_get_mapped (widget);