diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-28 15:19:54 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-08-28 15:19:54 -0400 |
commit | c47cc57ebf3b1c46a730df03432af6a0b59c5aca (patch) | |
tree | 6b3a90a5785a1ca2f6fa39617ca703f8bd5af664 | |
parent | 7ac2d15e081f50dc81d21e4d632f358a2190c759 (diff) | |
download | eclipse.platform.swt-gtk3_box_new.tar.gz eclipse.platform.swt-gtk3_box_new.tar.xz eclipse.platform.swt-gtk3_box_new.zip |
Use gtk_box_new() and gtk_box_set_homogeneous() for GTK3gtk3_box_new
This patch implements Gtk 3 methods gtk_box_new() and
gtk_box_set_homogeneous() instead of deprecated gtk_hbox_new() and
gtk_vbox_new()
17 files changed, 133 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java index 3a92ce31f8..b248ea6787 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java @@ -177,7 +177,12 @@ int /*long*/ getHandle () { * causing the child of the GtkFixed handle to be resized to 1. * The workaround is to embed Mozilla into a GtkHBox handle. */ - embedHandle = OS.gtk_hbox_new (false, 0); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)){ + embedHandle = OS.gtk_box_new(OS.GTK_ORIENTATION_HORIZONTAL, 0); + OS.gtk_box_set_homogeneous(embedHandle, false); + } else { + embedHandle = OS.gtk_hbox_new (false, 0); + } OS.gtk_container_add (browser.handle, embedHandle); OS.gtk_widget_show (embedHandle); return embedHandle; 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 16ad4e8134..08704175a5 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 @@ -7427,6 +7427,26 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1border_1free) } #endif +#ifndef NO__1gtk_1box_1new +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1box_1new) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1box_1new_FUNC); +/* + rc = (jintLong)gtk_box_new((GtkOrientation)arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_box_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkOrientation, jint))fp)((GtkOrientation)arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1box_1new_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1box_1set_1child_1packing JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1child_1packing) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jboolean arg2, jboolean arg3, jint arg4, jint arg5) @@ -7437,6 +7457,24 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1child_1packing) } #endif +#ifndef NO__1gtk_1box_1set_1homogeneous +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1homogeneous) + (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1box_1set_1homogeneous_FUNC); +/* + gtk_box_set_homogeneous(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_box_set_homogeneous) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jboolean))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1box_1set_1homogeneous_FUNC); +} +#endif + #ifndef NO__1gtk_1box_1set_1spacing JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1spacing) (JNIEnv *env, jclass that, jintLong arg0, jint arg1) @@ -9413,7 +9451,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1hbox_1new) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1hbox_1new_FUNC); +/* rc = (jintLong)gtk_hbox_new((gboolean)arg0, (gint)arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_hbox_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(gboolean, gint))fp)((gboolean)arg0, (gint)arg1); + } + } OS_NATIVE_EXIT(env, that, _1gtk_1hbox_1new_FUNC); return rc; } @@ -15319,7 +15365,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1vbox_1new) { jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1vbox_1new_FUNC); +/* rc = (jintLong)gtk_vbox_new((gboolean)arg0, (gint)arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_vbox_new) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(gboolean, gint))fp)((gboolean)arg0, (gint)arg1); + } + } OS_NATIVE_EXIT(env, that, _1gtk_1vbox_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 69b44542ef..f8de3bb693 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 @@ -72,6 +72,10 @@ #define XRenderSetPictureTransform_LIB LIB_XRENDER #define g_filename_display_name_LIB LIB_GLIB #define gtk_widget_set_allocation_LIB LIB_GTK +#define gtk_box_new_LIB LIB_GTK +#define gtk_box_set_homogeneous_LIB LIB_GTK +#define gtk_hbox_new_LIB LIB_GTK +#define gtk_vbox_new_LIB LIB_GTK #define gtk_calendar_display_options_LIB LIB_GTK #define gtk_calendar_get_date_LIB LIB_GTK #define gtk_calendar_new_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 657e02529d..cb2dad96c0 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 = 1333; -int OS_nativeFunctionCallCount[1333]; +int OS_nativeFunctionCount = 1335; +int OS_nativeFunctionCallCount[1335]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -594,7 +594,9 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1arrow_1set", "_1gtk_1bin_1get_1child", "_1gtk_1border_1free", + "_1gtk_1box_1new", "_1gtk_1box_1set_1child_1packing", + "_1gtk_1box_1set_1homogeneous", "_1gtk_1box_1set_1spacing", "_1gtk_1button_1clicked", "_1gtk_1button_1get_1relief", 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 e97f22092c..247a80f4b1 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 @@ -602,7 +602,9 @@ typedef enum { _1gtk_1arrow_1set_FUNC, _1gtk_1bin_1get_1child_FUNC, _1gtk_1border_1free_FUNC, + _1gtk_1box_1new_FUNC, _1gtk_1box_1set_1child_1packing_FUNC, + _1gtk_1box_1set_1homogeneous_FUNC, _1gtk_1box_1set_1spacing_FUNC, _1gtk_1button_1clicked_FUNC, _1gtk_1button_1get_1relief_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 c0ae254c02..e570b25d8c 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 @@ -7108,6 +7108,7 @@ public static final int /*long*/ gtk_grab_get_current() { } } /** + * @method flags=dynamic * @param homogeneous cast=(gboolean) * @param spacing cast=(gint) */ @@ -7120,6 +7121,31 @@ public static final int /*long*/ gtk_hbox_new(boolean homogeneous, int spacing) lock.unlock(); } } +/** + * @method flags=dynamic + * @param orientation cast=(GtkOrientation) + */ +public static final native int /*long*/ _gtk_box_new(int orientation, int spacing); +public static final int /*long*/ gtk_box_new(int orientation, int spacing) { + lock.lock(); + try { + return _gtk_box_new(orientation, spacing); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + */ +public static final native void _gtk_box_set_homogeneous(int /*long*/ box, boolean homogeneous); +public static final void gtk_box_set_homogeneous(int /*long*/ box, boolean homogeneous) { + lock.lock(); + try { + _gtk_box_set_homogeneous(box, homogeneous); + } finally { + lock.unlock(); + } +} /** @param adjustment cast=(GtkAdjustment *) */ public static final native int /*long*/ _gtk_hscale_new(int /*long*/ adjustment); public static final int /*long*/ gtk_hscale_new(int /*long*/ adjustment) { @@ -12001,6 +12027,7 @@ public static final void gtk_tree_view_convert_widget_to_bin_window_coords(int / } } /** + * @method flags=dynamic * @param homogeneous cast=(gboolean) * @param spacing cast=(gint) */ 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 7649674a1a..6d1ba92794 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 @@ -308,7 +308,7 @@ void createHandle (int index) { if ((style & SWT.ARROW) != 0) { OS.gtk_container_add (handle, arrowHandle); } else { - boxHandle = OS.gtk_hbox_new (false, 4); + boxHandle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 4); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java index cd4060359a..1a28ecebdb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java @@ -159,7 +159,13 @@ String openChooserDialog () { } if (message.length () > 0) { byte [] buffer = Converter.wcsToMbcs (null, message, true); - int /*long*/ box = OS.gtk_hbox_new (false, 0); + int /*long*/ box = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)){ + box = OS.gtk_box_new(OS.GTK_ORIENTATION_HORIZONTAL, 0); + OS.gtk_box_set_homogeneous(box, false); + } else { + box = OS.gtk_hbox_new (false, 0); + } if (box == 0) error (SWT.ERROR_NO_HANDLES); int /*long*/ label = OS.gtk_label_new (buffer); if (label == 0) error (SWT.ERROR_NO_HANDLES); 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 5b4887b7f9..cf156cb5c9 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 @@ -130,7 +130,12 @@ void createHandle (int index) { 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_vbox_new (false, 0); + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)){ + handle = OS.gtk_box_new(OS.GTK_ORIENTATION_VERTICAL, 0); + OS.gtk_box_set_homogeneous(handle, false); + } else { + handle = OS.gtk_vbox_new (false, 0); + } if (handle == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.V_SCROLL) != 0) { scrolledHandle = OS.gtk_scrolled_window_new (0, 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 d312929e94..311e6b802b 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 @@ -127,7 +127,7 @@ void createHandle (int index) { clientHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES); OS.gtk_container_add (handle, clientHandle); - boxHandle = OS.gtk_hbox_new (false, 4); + boxHandle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 4); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); labelHandle = OS.gtk_label_new (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 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 4885a1b520..d4326cdebb 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 @@ -211,7 +211,7 @@ void createHandle (int index) { } if (handle == 0) error (SWT.ERROR_NO_HANDLES); } else { - handle = OS.gtk_hbox_new (false, 0); + handle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 0); if (handle == 0) error (SWT.ERROR_NO_HANDLES); labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 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 91bc955651..5f1a5416bc 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 @@ -677,7 +677,7 @@ void createHandle (int index) { } else { OS.gtk_window_set_resizable (shellHandle, false); } - vboxHandle = OS.gtk_vbox_new (false, 0); + vboxHandle = gtk_box_new (OS.GTK_ORIENTATION_VERTICAL, false, 0); if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES); createHandle (index, false, true); OS.gtk_container_add (vboxHandle, scrolledHandle); 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 6e3cb9f984..232b05af5a 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 @@ -217,7 +217,7 @@ void createItem (TabItem item, int index) { System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } - int /*long*/ boxHandle = OS.gtk_hbox_new (false, 0); + int /*long*/ boxHandle = gtk_box_new ( OS.GTK_ORIENTATION_HORIZONTAL, false, 0); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 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 68a5709493..49c647848d 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 @@ -652,7 +652,7 @@ void createItem (TableColumn column, int index) { } else { createColumn (column, index); } - int /*long*/ boxHandle = OS.gtk_hbox_new (false, 3); + int /*long*/ boxHandle = gtk_box_new ( OS.GTK_ORIENTATION_HORIZONTAL, false, 3); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 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 b6ae773f1f..6145bc6524 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 @@ -215,7 +215,7 @@ void createHandle (int index) { */ handle = OS.gtk_tool_button_new (0, null); if (handle == 0) error (SWT.ERROR_NO_HANDLES); - arrowBoxHandle = OS.gtk_hbox_new (false, 0); + arrowBoxHandle = gtk_box_new ( OS.GTK_ORIENTATION_HORIZONTAL, false, 0);; if (arrowBoxHandle == 0) error(SWT.ERROR_NO_HANDLES); arrowHandle = OS.gtk_arrow_new (OS.GTK_ARROW_DOWN, OS.GTK_SHADOW_NONE); if (arrowHandle == 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 ac79e8b168..3b16e90abd 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 @@ -762,7 +762,7 @@ void createItem (TreeColumn column, int index) { } else { createColumn (column, index); } - int /*long*/ boxHandle = OS.gtk_hbox_new (false, 3); + int /*long*/ boxHandle = gtk_box_new ( OS.GTK_ORIENTATION_HORIZONTAL, false, 3); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 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 465a0f733e..e9db87b1ae 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 @@ -1834,6 +1834,21 @@ void gdk_window_get_size (int /*long*/ drawable, int[] width, int[] height) { } } +int /*long*/ gtk_box_new (int orientation, boolean homogeneous, int spacing) { + int /*long*/ box = 0; + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + box = OS.gtk_box_new (orientation, spacing); + OS.gtk_box_set_homogeneous (box, homogeneous); + } else { + if (orientation == OS.GTK_ORIENTATION_HORIZONTAL) { + box = OS.gtk_hbox_new (homogeneous, spacing); + } else if (orientation == OS.GTK_ORIENTATION_VERTICAL) { + box = OS.gtk_vbox_new (homogeneous, spacing); + } + } + return box; +} + /** * Returns a string containing a concise, human-readable * description of the receiver. |