From 6e60699d5dc28f66b62a845bf0b1a57aa83c551a Mon Sep 17 00:00:00 2001 From: Anatoly Spektor Date: Wed, 29 Aug 2012 10:28:58 -0400 Subject: Use gtk_scrollbar_new() for GTK+3 This patch uses gtk_scrollbar_new() instead of deprecated gtk_hscrollbar_new() and gtk_vscrollbar_new() for GTK+3 and higher --- .../Eclipse SWT PI/gtk/library/os.c | 36 ++++++++++++++++++++++ .../Eclipse SWT PI/gtk/library/os_custom.h | 3 ++ .../Eclipse SWT PI/gtk/library/os_stats.c | 1 + .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 24 +++++++++++++-- .../gtk/org/eclipse/swt/widgets/Slider.java | 18 +++++++++-- 6 files changed, 79 insertions(+), 4 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 90c1ebac16..bb0c2a9d0b 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 @@ -9481,7 +9481,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1hscrollbar_1new) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1hscrollbar_1new_FUNC); +/* rc = (jintLong)gtk_hscrollbar_new((GtkAdjustment *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_hscrollbar_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkAdjustment *))fp)((GtkAdjustment *)arg0); + } + } OS_NATIVE_EXIT(env, that, _1gtk_1hscrollbar_1new_FUNC); return rc; } @@ -12337,6 +12345,26 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scale_1set_1draw_1value) } #endif +#ifndef NO__1gtk_1scrollbar_1new +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1scrollbar_1new) + (JNIEnv *env, jclass that, jint arg0, jintLong arg1) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1scrollbar_1new_FUNC); +/* + rc = (jintLong)gtk_scrollbar_new((GtkOrientation)arg0, (GtkAdjustment *)arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_scrollbar_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkOrientation, GtkAdjustment *))fp)((GtkOrientation)arg0, (GtkAdjustment *)arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1scrollbar_1new_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1scrolled_1window_1add_1with_1viewport JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1add_1with_1viewport) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) @@ -15407,7 +15435,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1vscrollbar_1new) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1vscrollbar_1new_FUNC); +/* rc = (jintLong)gtk_vscrollbar_new((GtkAdjustment *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_vscrollbar_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkAdjustment *))fp)((GtkAdjustment *)arg0); + } + } OS_NATIVE_EXIT(env, that, _1gtk_1vscrollbar_1new_FUNC); return rc; } 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 09073e9c3e..7e7847971a 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 @@ -136,6 +136,9 @@ #define gtk_menu_tool_button_new_LIB LIB_GTK #define gtk_window_set_keep_below_LIB LIB_GTK #define gtk_set_locale_LIB LIB_GTK +#define gtk_scrollbar_new_LIB LIB_GTK +#define gtk_hscrollbar_new_LIB LIB_GTK +#define gtk_vscrollbar_new_LIB LIB_GTK #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 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 119f1c66aa..84a09fcd6b 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 @@ -940,6 +940,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1rc_1style_1set_1text", "_1gtk_1scale_1set_1digits", "_1gtk_1scale_1set_1draw_1value", + "_1gtk_1scrollbar_1new", "_1gtk_1scrolled_1window_1add_1with_1viewport", "_1gtk_1scrolled_1window_1get_1hadjustment", "_1gtk_1scrolled_1window_1get_1hscrollbar", 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 20250dbe2b..b8f5863797 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 @@ -948,6 +948,7 @@ typedef enum { _1gtk_1rc_1style_1set_1text_FUNC, _1gtk_1scale_1set_1digits_FUNC, _1gtk_1scale_1set_1draw_1value_FUNC, + _1gtk_1scrollbar_1new_FUNC, _1gtk_1scrolled_1window_1add_1with_1viewport_FUNC, _1gtk_1scrolled_1window_1get_1hadjustment_FUNC, _1gtk_1scrolled_1window_1get_1hscrollbar_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 c2310b7878..beeb4bfe2f 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 @@ -7139,7 +7139,10 @@ public static final int /*long*/ gtk_hscale_new(int /*long*/ adjustment) { lock.unlock(); } } -/** @param adjustment cast=(GtkAdjustment *) */ +/** + * @method flags=dynamic + * @param adjustment cast=(GtkAdjustment *) + */ public static final native int /*long*/ _gtk_hscrollbar_new(int /*long*/ adjustment); public static final int /*long*/ gtk_hscrollbar_new(int /*long*/ adjustment) { lock.lock(); @@ -7149,6 +7152,20 @@ public static final int /*long*/ gtk_hscrollbar_new(int /*long*/ adjustment) { lock.unlock(); } } +/** + * @method flags=dynamic + * @param orientation cast=(GtkOrientation) + * @param adjustment cast=(GtkAdjustment *) + * */ +public static final native int /*long*/ _gtk_scrollbar_new(int orientation, int /*long*/ adjustment); +public static final int /*long*/ gtk_scrollbar_new(int orientation, int /*long*/ adjustment) { + lock.lock(); + try { + return _gtk_scrollbar_new(orientation, adjustment); + } finally { + lock.unlock(); + } +} public static final native int /*long*/ _gtk_hseparator_new(); public static final int /*long*/ gtk_hseparator_new() { lock.lock(); @@ -12056,7 +12073,10 @@ public static final int /*long*/ gtk_vscale_new(int /*long*/ adjustment) { lock.unlock(); } } -/** @param adjustment cast=(GtkAdjustment *) */ +/** + * @method flags=dynamic + * @param adjustment cast=(GtkAdjustment *) + */ public static final native int /*long*/ _gtk_vscrollbar_new(int /*long*/ adjustment); public static final int /*long*/ gtk_vscrollbar_new(int /*long*/ adjustment) { lock.lock(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java index fb26b7dc08..e5072197b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java @@ -156,9 +156,9 @@ void createHandle (int index) { int /*long*/ hAdjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.HORIZONTAL) != 0) { - handle = OS.gtk_hscrollbar_new (hAdjustment); + handle = gtk_scrollbar_new (OS.GTK_ORIENTATION_HORIZONTAL, hAdjustment); } else { - handle = OS.gtk_vscrollbar_new (hAdjustment); + handle = gtk_scrollbar_new (OS.GTK_ORIENTATION_VERTICAL, hAdjustment); } if (handle == 0) error (SWT.ERROR_NO_HANDLES); /* @@ -613,4 +613,18 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); } +int /*long*/ gtk_scrollbar_new (int orientation, int /*long*/ adjustment) { + int /*long*/ scrollbar = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + scrollbar = OS.gtk_scrollbar_new (orientation, adjustment); + } else { + if (orientation == OS.GTK_ORIENTATION_HORIZONTAL) { + scrollbar = OS.gtk_hscrollbar_new (adjustment); + } else if (orientation == OS.GTK_ORIENTATION_VERTICAL) { + scrollbar = OS.gtk_vscrollbar_new (adjustment); + } + } + return scrollbar; +} + } -- cgit