diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-03 14:10:12 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-08-03 14:10:12 -0400 |
commit | b1ac97165e1b81fb0e6f8e4405b2f250b451c8da (patch) | |
tree | 955779c0311697e2c55f2140a52ae6b015c0f71b | |
parent | c9f7838af1e54e39107b4e5302048b7cebef9023 (diff) | |
download | eclipse.platform.swt-gtk_tooltips_get_window.tar.gz eclipse.platform.swt-gtk_tooltips_get_window.tar.xz eclipse.platform.swt-gtk_tooltips_get_window.zip |
Omit use of deprecated GTK_TOOLTIPS_TIP_WINDOW and gtk_tooltips_newgtk_tooltips_get_window
7 files changed, 124 insertions, 26 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 155872e3dd..816ffae7bd 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 @@ -13832,7 +13832,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; } @@ -15397,6 +15405,26 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1events) } #endif +#ifndef NO__1gtk_1widget_1get_1has_1tooltip +JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1get_1has_1tooltip) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jboolean rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1has_1tooltip_FUNC); +/* + rc = (jboolean)gtk_widget_get_has_tooltip(arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_get_has_tooltip) + if (fp) { + rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jintLong))fp)(arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1has_1tooltip_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1widget_1get_1modifier_1style JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1modifier_1style) (JNIEnv *env, jclass that, jintLong arg0) @@ -15804,6 +15832,24 @@ fail: } #endif +#ifndef NO__1gtk_1widget_1set_1tooltip_1window +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1tooltip_1window) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1tooltip_1window_FUNC); +/* + gtk_widget_set_tooltip_window(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_set_tooltip_window) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1tooltip_1window_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1show JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1show) (JNIEnv *env, jclass that, jintLong arg0) 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 f21e8ca75a..8e87010fe2 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 @@ -135,6 +135,7 @@ #define gtk_toolbar_set_orientation_LIB LIB_GTK #define gtk_tooltip_trigger_tooltip_query_LIB LIB_GTK #define gtk_tooltips_set_tip_LIB LIB_GTK +#define gtk_tooltips_new_LIB LIB_GTK #define gtk_tooltips_enable_LIB LIB_GTK #define gtk_tooltips_disable_LIB LIB_GTK #define gtk_tooltips_data_get_LIB LIB_GTK @@ -198,6 +199,8 @@ #define gtk_widget_is_composited_LIB LIB_GTK #define gtk_widget_get_tooltip_text_LIB LIB_GTK #define gtk_widget_set_tooltip_text_LIB LIB_GTK +#define gtk_widget_set_tooltip_window_LIB LIB_GTK +#define gtk_widget_get_has_tooltip_LIB LIB_GTK #define gdk_pango_context_set_colormap_LIB LIB_GDK #define gdk_x11_screen_get_window_manager_name_LIB LIB_GDK #define gdk_x11_screen_lookup_visual_LIB LIB_GDK @@ -365,7 +368,11 @@ #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 +#if GTK_CHECK_VERSION(2,12,0) +#define GTK_TOOLTIPS_TIP_WINDOW(arg0) 0 +#else #define GTK_TOOLTIPS_TIP_WINDOW(arg0) (arg0)->tip_window +#endif #define GTK_TOOLTIPS_SET_ACTIVE(arg0, arg1) (arg0)->active_tips_data = arg1 #define GTK_TOOLTIPS_GET_TIP_TEXT(arg0) (arg0)->tip_text #define GTK_WIDGET_Y(arg0) ((GtkWidget *)arg0)->allocation.y diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index b8074eb1de..9640a6c597 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -18,8 +18,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1315; -int OS_nativeFunctionCallCount[1315]; +int OS_nativeFunctionCount = 1317; +int OS_nativeFunctionCallCount[1317]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -1224,6 +1224,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1get_1child_1visible", "_1gtk_1widget_1get_1default_1style", "_1gtk_1widget_1get_1events", + "_1gtk_1widget_1get_1has_1tooltip", "_1gtk_1widget_1get_1modifier_1style", "_1gtk_1widget_1get_1pango_1context", "_1gtk_1widget_1get_1parent", @@ -1258,6 +1259,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1set_1size_1request", "_1gtk_1widget_1set_1state", "_1gtk_1widget_1set_1tooltip_1text", + "_1gtk_1widget_1set_1tooltip_1window", "_1gtk_1widget_1show", "_1gtk_1widget_1size_1allocate", "_1gtk_1widget_1size_1request", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 75194be58b..682d1d5971 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -1232,6 +1232,7 @@ typedef enum { _1gtk_1widget_1get_1child_1visible_FUNC, _1gtk_1widget_1get_1default_1style_FUNC, _1gtk_1widget_1get_1events_FUNC, + _1gtk_1widget_1get_1has_1tooltip_FUNC, _1gtk_1widget_1get_1modifier_1style_FUNC, _1gtk_1widget_1get_1pango_1context_FUNC, _1gtk_1widget_1get_1parent_FUNC, @@ -1266,6 +1267,7 @@ typedef enum { _1gtk_1widget_1set_1size_1request_FUNC, _1gtk_1widget_1set_1state_FUNC, _1gtk_1widget_1set_1tooltip_1text_FUNC, + _1gtk_1widget_1set_1tooltip_1window_FUNC, _1gtk_1widget_1show_FUNC, _1gtk_1widget_1size_1allocate_FUNC, _1gtk_1widget_1size_1request_FUNC, 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 0a5969cade..cfa7d01115 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 @@ -10642,6 +10642,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(); @@ -12160,6 +12161,26 @@ public static final int /*long*/ gtk_widget_get_tooltip_text (int /*long*/ widge lock.unlock(); } } +/** @method flags=dynamic */ +public static final native void _gtk_widget_set_tooltip_window(int /*long*/ widget, int /*long*/ custom_window); +public static final void gtk_widget_set_tooltip_window(int /*long*/ widget, int /*long*/ custom_window) { + lock.lock(); + try { + _gtk_widget_set_tooltip_window(widget,custom_window); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native boolean _gtk_widget_get_has_tooltip(int /*long*/ widget); +public static final boolean gtk_widget_get_has_tooltip(int /*long*/ widget){ + lock.lock(); + try { + return _gtk_widget_get_has_tooltip(widget); + } finally { + lock.unlock(); + } +} /** @param widget cast=(GtkWidget *) */ public static final native void _gtk_widget_grab_focus(int /*long*/ widget); public static final void gtk_widget_grab_focus(int /*long*/ widget) { 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 c7da6c4393..f586f8dd8c 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 @@ -50,6 +50,7 @@ public class ToolTip extends Widget { int /*long*/ layoutText = 0, layoutMessage = 0; int [] borderPolygon; boolean spikeAbove, autohide; + int /*long*/ tipWindow; static final int BORDER = 5; static final int PADDING = 5; @@ -265,20 +266,25 @@ void createHandle (int index) { 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)) { + tipWindow = OS.gtk_window_new(OS.GTK_WINDOW_POPUP); + OS.gtk_widget_set_tooltip_window(tipWindow, 0); + } 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); + } + OS.g_object_ref (handle); + OS.gtk_object_sink (handle); } - OS.g_object_ref (handle); - OS.gtk_object_sink (handle); } } @@ -293,7 +299,7 @@ void createWidget (int index) { void deregister () { super.deregister (); if ((style & SWT.BALLOON) == 0) { - int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle); + tipWindow = gtk_tooltips_tip_window (handle); if (tipWindow != 0) display.removeWidget (tipWindow); } } @@ -460,8 +466,12 @@ 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); + tipWindow = gtk_tooltips_tip_window(handle); + if (tipWindow != 0){ + return OS.GTK_WIDGET_VISIBLE (tipWindow); + } else { + return false; + } } int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { @@ -596,7 +606,7 @@ 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); + tipWindow = 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); @@ -627,7 +637,7 @@ public boolean isVisible () { void register () { super.register (); if ((style & SWT.BALLOON) == 0) { - int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle); + tipWindow = gtk_tooltips_tip_window (handle); if (tipWindow != 0) display.addWidget (tipWindow, this); } } @@ -715,7 +725,7 @@ 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); + tipWindow = gtk_tooltips_tip_window (handle); if (OS.GTK_WIDGET_VISIBLE (tipWindow)) { OS.gtk_window_move (tipWindow, x, y); } @@ -881,10 +891,18 @@ 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); + tipWindow = gtk_tooltips_tip_window (handle); OS.gtk_widget_hide (tipWindow); } return 0; } +int /*long*/ gtk_tooltips_tip_window ( int /*long*/ widget){ + if (OS.GTK_VERSION < OS.VERSION (2, 12, 0)) { + return OS.GTK_TOOLTIPS_TIP_WINDOW (widget); + } else { + return tipWindow; + } +} + } 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 2a82fb8e45..4a20f76599 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 @@ -588,10 +588,12 @@ public void setToolTipText (String string) { 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); - OS.gtk_object_sink (tooltipsHandle); + if (OS.GTK_VERSION <= OS.VERSION (2, 10, 0)) { + tooltipsHandle = OS.gtk_tooltips_new (); + if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES); + OS.g_object_ref (tooltipsHandle); + OS.gtk_object_sink (tooltipsHandle); + } } if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) { OS.gtk_status_icon_set_tooltip (handle, buffer); |