summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-08-03 19:20:00 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-08-03 19:20:00 -0400
commit88dc3a4dc3c68bb6669db018f4d6d63689ecddba (patch)
tree119485c479d9c77f1a0ae56857dc5a405c3cd896
parent9ef4324d53b9a731c1016f0319ea780ff7e16145 (diff)
downloadeclipse.platform.swt-88dc3a4dc3c68bb6669db018f4d6d63689ecddba.tar.gz
eclipse.platform.swt-88dc3a4dc3c68bb6669db018f4d6d63689ecddba.tar.xz
eclipse.platform.swt-88dc3a4dc3c68bb6669db018f4d6d63689ecddba.zip
Bug 385939 - Omit use of deprecated GTK_TOOLTIPS_TIP_WINDOW and gtk_tooltips_new
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java76
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java15
5 files changed, 89 insertions, 64 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 8098b20651..1bf69d95c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -13973,7 +13973,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1tooltips_1new)
{
jintLong rc = 0;
OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1new_FUNC);
+/*
rc = (jintLong)gtk_tooltips_new();
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_tooltips_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)();
+ }
+ }
OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1new_FUNC);
return rc;
}
@@ -15502,6 +15510,28 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1accessible)
}
#endif
+#ifndef NO__1gtk_1widget_1get_1allocation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1get_1allocation)
+ (JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
+{
+ GtkAllocation _arg1, *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1allocation_FUNC);
+ if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+/*
+ gtk_widget_get_allocation((GtkWidget *)arg0, (GtkAllocation *)lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_widget_get_allocation)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkWidget *, GtkAllocation *))fp)((GtkWidget *)arg0, (GtkAllocation *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) setGtkAllocationFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1allocation_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1widget_1get_1can_1default
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1get_1can_1default)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -18308,28 +18338,6 @@ JNIEXPORT void JNICALL OS_NATIVE(gdk_1threads_1set_1lock_1functions)
}
#endif
-#ifndef NO_gtk_1widget_1get_1allocation
-JNIEXPORT void JNICALL OS_NATIVE(gtk_1widget_1get_1allocation)
- (JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
-{
- GtkAllocation _arg1, *lparg1=NULL;
- OS_NATIVE_ENTER(env, that, gtk_1widget_1get_1allocation_FUNC);
- if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
-/*
- gtk_widget_get_allocation(arg0, (GtkAllocation *)lparg1);
-*/
- {
- OS_LOAD_FUNCTION(fp, gtk_widget_get_allocation)
- if (fp) {
- ((void (CALLING_CONVENTION*)(jintLong, GtkAllocation *))fp)(arg0, (GtkAllocation *)lparg1);
- }
- }
-fail:
- if (arg1 && lparg1) setGtkAllocationFields(env, arg1, lparg1);
- OS_NATIVE_EXIT(env, that, gtk_1widget_1get_1allocation_FUNC);
-}
-#endif
-
#ifndef NO_localeconv_1decimal_1point
JNIEXPORT jintLong JNICALL OS_NATIVE(localeconv_1decimal_1point)
(JNIEnv *env, jclass that)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 12e59d11e7..271d03c36e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -152,6 +152,7 @@
#define gtk_entry_set_alignment_LIB LIB_GTK
#define gtk_entry_set_icon_from_stock_LIB LIB_GTK
#define gtk_entry_set_icon_sensitive_LIB LIB_GTK
+#define gtk_tooltips_new_LIB LIB_GTK
#define gdk_cursor_new_from_pixbuf_LIB LIB_GDK
#define gdk_display_get_default_LIB LIB_GDK
#define gdk_display_supports_cursor_color_LIB LIB_GDK
@@ -407,15 +408,13 @@
#define GTK_WIDGET_SET_X(arg0, arg1) (arg0)->allocation.x = arg1
#define GTK_ENTRY_IM_CONTEXT(arg0) (arg0)->im_context
#define GTK_TEXTVIEW_IM_CONTEXT(arg0) (arg0)->im_context
-#define GTK_TOOLTIPS_TIP_WINDOW(arg0) (arg0)->tip_window
#if GTK_CHECK_VERSION(2,12,0)
+#define GTK_TOOLTIPS_TIP_WINDOW(arg0) 0
#define GTK_TOOLTIPS_SET_ACTIVE(arg0, arg1)
-#else
-#define GTK_TOOLTIPS_SET_ACTIVE(arg0, arg1) (arg0)->active_tips_data = arg1
-#endif
-#if GTK_CHECK_VERSION(2,12,0)
#define GTK_TOOLTIPS_GET_TIP_TEXT(arg0) 0
#else
+#define GTK_TOOLTIPS_TIP_WINDOW(arg0) (arg0)->tip_window
+#define GTK_TOOLTIPS_SET_ACTIVE(arg0, arg1) (arg0)->active_tips_data = arg1
#define GTK_TOOLTIPS_GET_TIP_TEXT(arg0) (arg0)->tip_text
#endif
#if GTK_CHECK_VERSION(2,18,0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index d3061785fe..7d4ad57f19 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -10745,6 +10745,7 @@ public static final void gtk_tooltips_enable(int /*long*/ tooltips) {
lock.unlock();
}
}
+/** @method flags=dynamic */
public static final native int /*long*/ _gtk_tooltips_new();
public static final int /*long*/ gtk_tooltips_new() {
lock.lock();
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 d4f5929351..dc4ff1f1df 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
@@ -257,28 +257,31 @@ void configure () {
}
void createHandle (int index) {
- state |= HANDLE;
if ((style & SWT.BALLOON) != 0) {
+ state |= HANDLE;
handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND);
OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle);
OS.gtk_widget_set_app_paintable (handle, true);
OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP);
} else {
- handle = OS.gtk_tooltips_new ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- /*
- * Bug in Solaris-GTK. Invoking gtk_tooltips_force_window()
- * can cause a crash in older versions of GTK. The fix is
- * to avoid this call if the GTK version is older than 2.2.x.
- * The call is to be avoided on GTK versions newer than 2.12.0
- * where it's deprecated.
- */
- if (OS.GTK_VERSION >= OS.VERSION (2, 2, 1)) {
- OS.gtk_tooltips_force_window (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+ state |= HANDLE;
+ handle = OS.gtk_tooltips_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ /*
+ * Bug in Solaris-GTK. Invoking gtk_tooltips_force_window()
+ * can cause a crash in older versions of GTK. The fix is
+ * to avoid this call if the GTK version is older than 2.2.x.
+ * The call is to be avoided on GTK versions newer than 2.12.0
+ * where it's deprecated.
+ */
+ if (OS.GTK_VERSION >= OS.VERSION (2, 2, 1)) {
+ OS.gtk_tooltips_force_window (handle);
+ }
+ OS.g_object_ref (handle);
+ g_object_ref_sink (handle);
}
- OS.g_object_ref (handle);
- g_object_ref_sink (handle);
}
}
@@ -293,8 +296,10 @@ void createWidget (int index) {
void deregister () {
super.deregister ();
if ((style & SWT.BALLOON) == 0) {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- if (tipWindow != 0) display.removeWidget (tipWindow);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ if (tipWindow != 0) display.removeWidget (tipWindow);
+ }
}
}
@@ -460,8 +465,11 @@ public String getText () {
public boolean getVisible () {
checkWidget ();
if ((style & SWT.BALLOON) != 0) return OS.GTK_WIDGET_VISIBLE (handle);
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- return OS.GTK_WIDGET_VISIBLE (tipWindow);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ return OS.GTK_WIDGET_VISIBLE (tipWindow);
+ }
+ return false;
}
int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
@@ -605,11 +613,13 @@ void hookEvents () {
OS.gtk_widget_add_events (handle, OS.GDK_BUTTON_PRESS_MASK);
OS.g_signal_connect_closure (handle, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
} else {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- if (tipWindow != 0) {
- OS.g_signal_connect_closure (tipWindow, OS.size_allocate, display.closures [SIZE_ALLOCATE], false);
- OS.gtk_widget_add_events (tipWindow, OS.GDK_BUTTON_PRESS_MASK);
- OS.g_signal_connect_closure (tipWindow, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ if (tipWindow != 0) {
+ OS.g_signal_connect_closure (tipWindow, OS.size_allocate, display.closures [SIZE_ALLOCATE], false);
+ OS.gtk_widget_add_events (tipWindow, OS.GDK_BUTTON_PRESS_MASK);
+ OS.g_signal_connect_closure (tipWindow, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
+ }
}
}
}
@@ -636,8 +646,10 @@ public boolean isVisible () {
void register () {
super.register ();
if ((style & SWT.BALLOON) == 0) {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- if (tipWindow != 0) display.addWidget (tipWindow, this);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ if (tipWindow != 0) display.addWidget (tipWindow, this);
+ }
}
}
@@ -724,9 +736,11 @@ public void setLocation (int x, int y) {
if ((style & SWT.BALLOON) != 0) {
if (OS.GTK_WIDGET_VISIBLE (handle)) configure ();
} else {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- if (OS.GTK_WIDGET_VISIBLE (tipWindow)) {
- OS.gtk_window_move (tipWindow, x, y);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ if (OS.GTK_WIDGET_VISIBLE (tipWindow)) {
+ OS.gtk_window_move (tipWindow, x, y);
+ }
}
}
}
@@ -890,8 +904,10 @@ int /*long*/ timerProc (int /*long*/ widget) {
if ((style & SWT.BALLOON) != 0) {
OS.gtk_widget_hide (handle);
} else {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- OS.gtk_widget_hide (tipWindow);
+ if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) {
+ int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+ OS.gtk_widget_hide (tipWindow);
+ }
}
return 0;
}
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 901de7791f..a13c3141b3 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
@@ -596,16 +596,17 @@ public void setToolTipText (String string) {
if (string != null && string.length () > 0) {
buffer = Converter.wcsToMbcs (null, string, true);
}
- if (tooltipsHandle == 0) {
- tooltipsHandle = OS.gtk_tooltips_new ();
- if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.g_object_ref (tooltipsHandle);
- g_object_ref_sink (tooltipsHandle);
- }
if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
OS.gtk_status_icon_set_tooltip (handle, buffer);
- } else
+ } else {
+ if (tooltipsHandle == 0) {
+ tooltipsHandle = OS.gtk_tooltips_new ();
+ if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.g_object_ref (tooltipsHandle);
+ g_object_ref_sink (tooltipsHandle);
+ }
OS.gtk_tooltips_set_tip (tooltipsHandle, handle, buffer, null);
+ }
}
/**