diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c index 7320aafd63c..bf5b9cb7af1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -780,16 +780,6 @@ JNIEXPORT jboolean JNICALL GTK3_NATIVE(gtk_1events_1pending) } #endif -#ifndef NO_gtk_1file_1chooser_1add_1filter -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1add_1filter) - (JNIEnv *env, jclass that, jlong arg0, jlong arg1) -{ - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1add_1filter_FUNC); - gtk_file_chooser_add_filter((GtkFileChooser *)arg0, (GtkFileFilter *)arg1); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1add_1filter_FUNC); -} -#endif - #ifndef NO_gtk_1file_1chooser_1get_1filename JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1get_1filename) (JNIEnv *env, jclass that, jlong arg0) @@ -814,18 +804,6 @@ JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1get_1filenames) } #endif -#ifndef NO_gtk_1file_1chooser_1get_1filter -JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1get_1filter) - (JNIEnv *env, jclass that, jlong arg0) -{ - jlong rc = 0; - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1get_1filter_FUNC); - rc = (jlong)gtk_file_chooser_get_filter((GtkFileChooser *)arg0); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1get_1filter_FUNC); - return rc; -} -#endif - #ifndef NO_gtk_1file_1chooser_1get_1uri JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1get_1uri) (JNIEnv *env, jclass that, jlong arg0) @@ -850,36 +828,6 @@ JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1get_1uris) } #endif -#ifndef NO_gtk_1file_1chooser_1native_1new -JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1file_1chooser_1native_1new) - (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1, jint arg2, jbyteArray arg3, jbyteArray arg4) -{ - jbyte *lparg0=NULL; - jbyte *lparg3=NULL; - jbyte *lparg4=NULL; - jlong rc = 0; - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1native_1new_FUNC); - if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; - if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail; - if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail; -/* - rc = (jlong)gtk_file_chooser_native_new((const gchar *)lparg0, (GtkWindow *)arg1, arg2, (const gchar *)lparg3, (const gchar *)lparg4); -*/ - { - GTK3_LOAD_FUNCTION(fp, gtk_file_chooser_native_new) - if (fp) { - rc = (jlong)((jlong (CALLING_CONVENTION*)(const gchar *, GtkWindow *, jint, const gchar *, const gchar *))fp)((const gchar *)lparg0, (GtkWindow *)arg1, arg2, (const gchar *)lparg3, (const gchar *)lparg4); - } - } -fail: - if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, JNI_ABORT); - if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); - if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1native_1new_FUNC); - return rc; -} -#endif - #ifndef NO_gtk_1file_1chooser_1set_1current_1folder JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1current_1folder) (JNIEnv *env, jclass that, jlong arg0, jlong arg1) @@ -904,20 +852,6 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1current_1folder_1uri } #endif -#ifndef NO_gtk_1file_1chooser_1set_1current_1name -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1current_1name) - (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) -{ - jbyte *lparg1=NULL; - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1current_1name_FUNC); - if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; - gtk_file_chooser_set_current_name((GtkFileChooser *)arg0, (const gchar *)lparg1); -fail: - if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1current_1name_FUNC); -} -#endif - #ifndef NO_gtk_1file_1chooser_1set_1do_1overwrite_1confirmation JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1do_1overwrite_1confirmation) (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) @@ -948,16 +882,6 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1filename) } #endif -#ifndef NO_gtk_1file_1chooser_1set_1filter -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1filter) - (JNIEnv *env, jclass that, jlong arg0, jlong arg1) -{ - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1filter_FUNC); - gtk_file_chooser_set_filter((GtkFileChooser *)arg0, (GtkFileFilter *)arg1); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1filter_FUNC); -} -#endif - #ifndef NO_gtk_1file_1chooser_1set_1local_1only JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1local_1only) (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) @@ -968,16 +892,6 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1local_1only) } #endif -#ifndef NO_gtk_1file_1chooser_1set_1select_1multiple -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1select_1multiple) - (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) -{ - GTK3_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1select_1multiple_FUNC); - gtk_file_chooser_set_select_multiple((GtkFileChooser *)arg0, (gboolean)arg1); - GTK3_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1select_1multiple_FUNC); -} -#endif - #ifndef NO_gtk_1file_1chooser_1set_1uri JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1uri) (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) @@ -992,48 +906,6 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1uri) } #endif -#ifndef NO_gtk_1font_1chooser_1dialog_1new -JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1font_1chooser_1dialog_1new) - (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1) -{ - jbyte *lparg0=NULL; - jlong rc = 0; - GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); - if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; - rc = (jlong)gtk_font_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1); -fail: - if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); - GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); - return rc; -} -#endif - -#ifndef NO_gtk_1font_1chooser_1get_1font -JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1font_1chooser_1get_1font) - (JNIEnv *env, jclass that, jlong arg0) -{ - jlong rc = 0; - GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1get_1font_FUNC); - rc = (jlong)gtk_font_chooser_get_font((GtkFontChooser *)arg0); - GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1get_1font_FUNC); - return rc; -} -#endif - -#ifndef NO_gtk_1font_1chooser_1set_1font -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1font_1chooser_1set_1font) - (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) -{ - jbyte *lparg1=NULL; - GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1set_1font_FUNC); - if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; - gtk_font_chooser_set_font((GtkFontChooser *)arg0, (const gchar *)lparg1); -fail: - if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); - GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1set_1font_FUNC); -} -#endif - #ifndef NO_gtk_1frame_1set_1shadow_1type JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1frame_1set_1shadow_1type) (JNIEnv *env, jclass that, jlong arg0, jint arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h index 285dc0afb90..9eed9c0cd17 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -88,26 +88,17 @@ typedef enum { gtk_1event_1box_1new_FUNC, gtk_1event_1controller_1handle_1event_FUNC, gtk_1events_1pending_FUNC, - gtk_1file_1chooser_1add_1filter_FUNC, gtk_1file_1chooser_1get_1filename_FUNC, gtk_1file_1chooser_1get_1filenames_FUNC, - gtk_1file_1chooser_1get_1filter_FUNC, gtk_1file_1chooser_1get_1uri_FUNC, gtk_1file_1chooser_1get_1uris_FUNC, - gtk_1file_1chooser_1native_1new_FUNC, gtk_1file_1chooser_1set_1current_1folder_FUNC, gtk_1file_1chooser_1set_1current_1folder_1uri_FUNC, - gtk_1file_1chooser_1set_1current_1name_FUNC, gtk_1file_1chooser_1set_1do_1overwrite_1confirmation_FUNC, gtk_1file_1chooser_1set_1extra_1widget_FUNC, gtk_1file_1chooser_1set_1filename_FUNC, - gtk_1file_1chooser_1set_1filter_FUNC, gtk_1file_1chooser_1set_1local_1only_FUNC, - gtk_1file_1chooser_1set_1select_1multiple_FUNC, gtk_1file_1chooser_1set_1uri_FUNC, - gtk_1font_1chooser_1dialog_1new_FUNC, - gtk_1font_1chooser_1get_1font_FUNC, - gtk_1font_1chooser_1set_1font_FUNC, gtk_1frame_1set_1shadow_1type_FUNC, gtk_1gesture_1drag_1new_FUNC, gtk_1gesture_1rotate_1new_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c index a06ab26f27f..4ee62a17eff 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c @@ -822,6 +822,54 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1expander_1set_1child) } #endif +#ifndef NO_gtk_1file_1chooser_1get_1file +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1chooser_1get_1file) + (JNIEnv *env, jclass that, jlong arg0) +{ + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1file_1chooser_1get_1file_FUNC); + rc = (jlong)gtk_file_chooser_get_file((GtkFileChooser *)arg0); + GTK4_NATIVE_EXIT(env, that, gtk_1file_1chooser_1get_1file_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1file_1chooser_1get_1files +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1chooser_1get_1files) + (JNIEnv *env, jclass that, jlong arg0) +{ + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1file_1chooser_1get_1files_FUNC); + rc = (jlong)gtk_file_chooser_get_files((GtkFileChooser *)arg0); + GTK4_NATIVE_EXIT(env, that, gtk_1file_1chooser_1get_1files_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1file_1chooser_1set_1current_1folder +JNIEXPORT jboolean JNICALL GTK4_NATIVE(gtk_1file_1chooser_1set_1current_1folder) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2) +{ + jboolean rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1current_1folder_FUNC); + rc = (jboolean)gtk_file_chooser_set_current_folder((GtkFileChooser *)arg0, (GFile *)arg1, (GError **)arg2); + GTK4_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1current_1folder_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1file_1chooser_1set_1file +JNIEXPORT jboolean JNICALL GTK4_NATIVE(gtk_1file_1chooser_1set_1file) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2) +{ + jboolean rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1file_FUNC); + rc = (jboolean)gtk_file_chooser_set_file((GtkFileChooser *)arg0, (GFile *)arg1, (GError **)arg2); + GTK4_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1file_FUNC); + return rc; +} +#endif + #ifndef NO_gtk_1file_1dialog_1get_1default_1filter JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1get_1default_1filter) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h index 9273b0a03c9..328ec74e362 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h @@ -85,6 +85,10 @@ typedef enum { gtk_1event_1controller_1motion_1new_FUNC, gtk_1event_1controller_1scroll_1new_FUNC, gtk_1expander_1set_1child_FUNC, + gtk_1file_1chooser_1get_1file_FUNC, + gtk_1file_1chooser_1get_1files_FUNC, + gtk_1file_1chooser_1set_1current_1folder_FUNC, + gtk_1file_1chooser_1set_1file_FUNC, gtk_1file_1dialog_1get_1default_1filter_FUNC, gtk_1file_1dialog_1new_FUNC, gtk_1file_1dialog_1open_FUNC, 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 999a971259e..da250adcd4a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2025 IBM Corporation and others. All rights reserved. * The contents of this file are made available under the terms * of the GNU Lesser General Public License (LGPL) Version 2.1 that * accompanies this distribution (lgpl-v21.txt). The LGPL is also @@ -4729,6 +4729,92 @@ JNIEXPORT void JNICALL GTK_NATIVE(gtk_1expander_1set_1label_1widget) } #endif +#ifndef NO_gtk_1file_1chooser_1add_1filter +JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1chooser_1add_1filter) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1) +{ + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1add_1filter_FUNC); + gtk_file_chooser_add_filter((GtkFileChooser *)arg0, (GtkFileFilter *)arg1); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1add_1filter_FUNC); +} +#endif + +#ifndef NO_gtk_1file_1chooser_1get_1filter +JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1file_1chooser_1get_1filter) + (JNIEnv *env, jclass that, jlong arg0) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1get_1filter_FUNC); + rc = (jlong)gtk_file_chooser_get_filter((GtkFileChooser *)arg0); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1get_1filter_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1file_1chooser_1native_1new +JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1file_1chooser_1native_1new) + (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1, jint arg2, jbyteArray arg3, jbyteArray arg4) +{ + jbyte *lparg0=NULL; + jbyte *lparg3=NULL; + jbyte *lparg4=NULL; + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1native_1new_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail; + if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail; +/* + rc = (jlong)gtk_file_chooser_native_new((const gchar *)lparg0, (GtkWindow *)arg1, arg2, (const gchar *)lparg3, (const gchar *)lparg4); +*/ + { + GTK_LOAD_FUNCTION(fp, gtk_file_chooser_native_new) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)(const gchar *, GtkWindow *, jint, const gchar *, const gchar *))fp)((const gchar *)lparg0, (GtkWindow *)arg1, arg2, (const gchar *)lparg3, (const gchar *)lparg4); + } + } +fail: + if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, JNI_ABORT); + if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1native_1new_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1file_1chooser_1set_1current_1name +JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1chooser_1set_1current_1name) + (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1current_1name_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + gtk_file_chooser_set_current_name((GtkFileChooser *)arg0, (const gchar *)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1current_1name_FUNC); +} +#endif + +#ifndef NO_gtk_1file_1chooser_1set_1filter +JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1chooser_1set_1filter) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1) +{ + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1filter_FUNC); + gtk_file_chooser_set_filter((GtkFileChooser *)arg0, (GtkFileFilter *)arg1); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1filter_FUNC); +} +#endif + +#ifndef NO_gtk_1file_1chooser_1set_1select_1multiple +JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1chooser_1set_1select_1multiple) + (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) +{ + GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1set_1select_1multiple_FUNC); + gtk_file_chooser_set_select_multiple((GtkFileChooser *)arg0, (gboolean)arg1); + GTK_NATIVE_EXIT(env, that, gtk_1file_1chooser_1set_1select_1multiple_FUNC); +} +#endif + #ifndef NO_gtk_1file_1filter_1add_1pattern JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1filter_1add_1pattern) (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) @@ -4781,6 +4867,48 @@ JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1filter_1set_1name) } #endif +#ifndef NO_gtk_1font_1chooser_1dialog_1new +JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1font_1chooser_1dialog_1new) + (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1) +{ + jbyte *lparg0=NULL; + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + rc = (jlong)gtk_font_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1); +fail: + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1chooser_1get_1font +JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1font_1chooser_1get_1font) + (JNIEnv *env, jclass that, jlong arg0) +{ + jlong rc = 0; + GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1get_1font_FUNC); + rc = (jlong)gtk_font_chooser_get_font((GtkFontChooser *)arg0); + GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1get_1font_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1chooser_1set_1font +JNIEXPORT void JNICALL GTK_NATIVE(gtk_1font_1chooser_1set_1font) + (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1set_1font_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + gtk_font_chooser_set_font((GtkFontChooser *)arg0, (const gchar *)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1set_1font_FUNC); +} +#endif + #ifndef NO_gtk_1frame_1get_1label_1widget JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1frame_1get_1label_1widget) (JNIEnv *env, jclass that, jlong arg0) 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 485ac5a9d2c..c132838f89d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2025 IBM Corporation and others. All rights reserved. * The contents of this file are made available under the terms * of the GNU Lesser General Public License (LGPL) Version 2.1 that * accompanies this distribution (lgpl-v21.txt). The LGPL is also @@ -376,10 +376,19 @@ typedef enum { gtk_1expander_1new_FUNC, gtk_1expander_1set_1expanded_FUNC, gtk_1expander_1set_1label_1widget_FUNC, + gtk_1file_1chooser_1add_1filter_FUNC, + gtk_1file_1chooser_1get_1filter_FUNC, + gtk_1file_1chooser_1native_1new_FUNC, + gtk_1file_1chooser_1set_1current_1name_FUNC, + gtk_1file_1chooser_1set_1filter_FUNC, + gtk_1file_1chooser_1set_1select_1multiple_FUNC, gtk_1file_1filter_1add_1pattern_FUNC, gtk_1file_1filter_1get_1name_FUNC, gtk_1file_1filter_1new_FUNC, gtk_1file_1filter_1set_1name_FUNC, + gtk_1font_1chooser_1dialog_1new_FUNC, + gtk_1font_1chooser_1get_1font_FUNC, + gtk_1font_1chooser_1set_1font_FUNC, gtk_1frame_1get_1label_1widget_FUNC, gtk_1frame_1new_FUNC, gtk_1frame_1set_1label_1widget_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java index c5a9ff0769e..29f15836b1d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java @@ -701,6 +701,30 @@ public class GTK extends OS { /** @param expander cast=(GtkExpander *) */ public static final native long gtk_expander_get_label_widget(long expander); + /* GtkFileChooser */ + /** + * @param chooser cast=(GtkFileChooser *) + * @param filter cast=(GtkFileFilter *) + */ + public static final native void gtk_file_chooser_add_filter(long chooser, long filter); + /** @param chooser cast=(GtkFileChooser *) */ + public static final native long gtk_file_chooser_get_filter(long chooser); + /** + * @param chooser cast=(GtkFileChooser *) + * @param name cast=(const gchar *) + */ + public static final native void gtk_file_chooser_set_current_name(long chooser, byte[] name); + /** + * @param chooser cast=(GtkFileChooser *) + * @param filter cast=(GtkFileFilter *) + */ + public static final native void gtk_file_chooser_set_filter(long chooser, long filter); + /** + * @param chooser cast=(GtkFileChooser *) + * @param select_multiple cast=(gboolean) + */ + public static final native void gtk_file_chooser_set_select_multiple(long chooser, boolean select_multiple); + /* GtkEventController */ /** * @param controller cast=(GtkEventController *) @@ -719,6 +743,16 @@ public class GTK extends OS { /** @param gesture cast=(GtkGestureSingle *) */ public static final native int gtk_gesture_single_get_current_button(long gesture); + /* GtkFileChooserNative */ + /** + * @method flags=dynamic + * @param title cast=(const gchar *),flags=no_out + * @param parent cast=(GtkWindow *) + * @param accept_label cast=(const gchar *),flags=no_out + * @param cancel_label cast=(const gchar *),flags=no_out + */ + public static final native long gtk_file_chooser_native_new(byte[] title, long parent, int action, byte[] accept_label, byte[] cancel_label); + /* GtkFileFilter */ public static final native long gtk_file_filter_new(); /** @@ -776,6 +810,22 @@ public class GTK extends OS { */ public static final native double gtk_gesture_zoom_get_scale_delta(long gesture); + /* GtkFontChooserDialog */ + /** + * @param title cast=(const gchar *) + * @param parent cast=(GtkWindow *) + */ + public static final native long gtk_font_chooser_dialog_new(byte[] title, long parent); + + /* GtkFontChooser Interface */ + /** @param fontchooser cast=(GtkFontChooser *) */ + public static final native long gtk_font_chooser_get_font(long fontchooser); + /** + * @param fsd cast=(GtkFontChooser *) + * @param fontname cast=(const gchar *) + */ + public static final native void gtk_font_chooser_set_font(long fsd, byte[] fontname); + /* GtkFrame */ /** @param label cast=(const gchar *) */ public static final native long gtk_frame_new(byte[] label); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java index 04e4092f0f9..5e5c9e278aa 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java @@ -516,38 +516,6 @@ public class GTK3 { * @param extra_widget cast=(GtkWidget *) */ public static final native void gtk_file_chooser_set_extra_widget(long chooser, long extra_widget); - /** - * @param chooser cast=(GtkFileChooser *) - * @param filter cast=(GtkFileFilter *) - */ - public static final native void gtk_file_chooser_add_filter(long chooser, long filter); - /** @param chooser cast=(GtkFileChooser *) */ - public static final native long gtk_file_chooser_get_filter(long chooser); - /** - * @param chooser cast=(GtkFileChooser *) - * @param name cast=(const gchar *) - */ - public static final native void gtk_file_chooser_set_current_name(long chooser, byte[] name); - /** - * @param chooser cast=(GtkFileChooser *) - * @param filter cast=(GtkFileFilter *) - */ - public static final native void gtk_file_chooser_set_filter(long chooser, long filter); - /** - * @param chooser cast=(GtkFileChooser *) - * @param select_multiple cast=(gboolean) - */ - public static final native void gtk_file_chooser_set_select_multiple(long chooser, boolean select_multiple); - - /* GtkFileChooserNative */ - /** - * @method flags=dynamic - * @param title cast=(const gchar *),flags=no_out - * @param parent cast=(GtkWindow *) - * @param accept_label cast=(const gchar *),flags=no_out - * @param cancel_label cast=(const gchar *),flags=no_out - */ - public static final native long gtk_file_chooser_native_new(byte[] title, long parent, int action, byte[] accept_label, byte[] cancel_label); /* GtkRadioButton */ /** @param radio_button cast=(GtkRadioButton *) */ @@ -1110,22 +1078,6 @@ public class GTK3 { */ public static final native long gtk_gesture_drag_new(long widget); - /* GtkFontChooserDialog */ - /** - * @param title cast=(const gchar *) - * @param parent cast=(GtkWindow *) - */ - public static final native long gtk_font_chooser_dialog_new(byte[] title, long parent); - - /* GtkFontChooser Interface */ - /** @param fontchooser cast=(GtkFontChooser *) */ - public static final native long gtk_font_chooser_get_font(long fontchooser); - /** - * @param fsd cast=(GtkFontChooser *) - * @param fontname cast=(const gchar *) - */ - public static final native void gtk_font_chooser_set_font(long fsd, byte[] fontname); - /* Sizeof */ public static final native int GtkTargetEntry_sizeof(); public static final native int GdkEvent_sizeof(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java index 5f8cb6fd426..1a7f3083a24 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java @@ -174,6 +174,24 @@ public class GTK4 { /** @param builder cast=(GdkContentFormatsBuilder *) */ public static final native long gdk_content_formats_builder_free_to_formats(long builder); + /* GtkFileChooser */ + /** @param chooser cast=(GtkFileChooser *) */ + public static final native long gtk_file_chooser_get_files(long chooser); + /** @param chooser cast=(GtkFileChooser *) */ + public static final native long gtk_file_chooser_get_file(long chooser); + /** + * @param chooser cast=(GtkFileChooser *) + * @param file cast=(GFile *) + * @param error cast=(GError **) + */ + public static final native boolean gtk_file_chooser_set_current_folder(long chooser, long file, long error); + /** + * @param chooser cast=(GtkFileChooser *) + * @param file cast=(GFile *) + * @param error cast=(GError **) + */ + public static final native boolean gtk_file_chooser_set_file(long chooser, long file, long error); + /* GtkFileDialog */ /** @method flags=dynamic **/ public static final native long gtk_file_dialog_new(); 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 4a4a2f2da55..5d135c46e8b 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 @@ -166,11 +166,11 @@ Optional openNativeChooserDialog () { long shellHandle = parent.topHandle (); Display display = parent != null ? parent.getDisplay (): Display.getCurrent (); long handle; - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { handle = GTK4.gtk_file_dialog_new(); GTK4.gtk_file_dialog_set_title(handle, titleBytes); } else { - handle = GTK3.gtk_file_chooser_native_new(titleBytes, shellHandle, GTK.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, null, null); + handle = GTK.gtk_file_chooser_native_new(titleBytes, shellHandle, GTK.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, null, null); } if (handle == 0) error (SWT.ERROR_NO_HANDLES); @@ -191,7 +191,11 @@ Optional openNativeChooserDialog () { if (ptr != 0) { if (GTK.GTK4) { long file = OS.g_file_new_for_path(buffer); - GTK4.gtk_file_dialog_set_initial_folder (handle, file); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_initial_folder (handle, file); + } else { + GTK4.gtk_file_chooser_set_current_folder (handle, file, 0); + } OS.g_object_unref(file); } else { GTK3.gtk_file_chooser_set_current_folder (handle, ptr); @@ -214,18 +218,22 @@ Optional openNativeChooserDialog () { int response; long file = 0; if (GTK.GTK4) { - file = SyncDialogUtil.run(display, new AsyncReadyCallback() { - @Override - public void async(long result) { - GTK4.gtk_file_dialog_select_folder(handle, shellHandle, 0, result, 0); - } + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + file = SyncDialogUtil.run(display, new AsyncReadyCallback() { + @Override + public void async(long result) { + GTK4.gtk_file_dialog_select_folder(handle, shellHandle, 0, result, 0); + } - @Override - public long await(long result) { - return GTK4.gtk_file_dialog_select_folder_finish(handle, result, null); - } - }); - response = file != 0 ? GTK.GTK_RESPONSE_ACCEPT : GTK.GTK_RESPONSE_CANCEL; + @Override + public long await(long result) { + return GTK4.gtk_file_dialog_select_folder_finish(handle, result, null); + } + }); + response = file != 0 ? GTK.GTK_RESPONSE_ACCEPT : GTK.GTK_RESPONSE_CANCEL; + } else { + response = SyncDialogUtil.run(display, handle, true); + } } else { display.externalEventLoop = true; display.sendPreExternalEventDispatchEvent (); @@ -240,6 +248,9 @@ public long await(long result) { if (response == GTK.GTK_RESPONSE_ACCEPT) { long path; if (GTK.GTK4) { + if (GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) { + file = GTK4.gtk_file_chooser_get_file (handle); + } path = OS.g_file_get_path(file); } else { path = GTK3.gtk_file_chooser_get_filename (handle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java index f5847e8522b..649651d0307 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java @@ -112,7 +112,11 @@ String computeResultChooserDialog (long file) { if ((style & SWT.MULTI) != 0) { long list = 0; if (GTK.GTK4) { - list = file; + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + list = file; + } else { + list = GTK4.gtk_file_chooser_get_files(handle); + } } else { if (uriMode) { list = GTK3.gtk_file_chooser_get_uris (handle); @@ -172,6 +176,9 @@ String computeResultChooserDialog (long file) { long utf8Ptr = 0; if (uriMode) { if (GTK.GTK4) { + if (GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) { + file = GTK4.gtk_file_chooser_get_file(handle); + } utf8Ptr = OS.g_file_get_uri(file); } else { utf8Ptr = GTK3.gtk_file_chooser_get_uri (handle); @@ -179,6 +186,9 @@ String computeResultChooserDialog (long file) { } else { long path; if (GTK.GTK4) { + if (GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) { + file = GTK4.gtk_file_chooser_get_file(handle); + } path = OS.g_file_get_path(file); } else { path = GTK3.gtk_file_chooser_get_filename (handle); @@ -207,10 +217,10 @@ String computeResultChooserDialog (long file) { } filterIndex = -1; long filter; - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { filter = GTK4.gtk_file_dialog_get_default_filter(handle); } else { - filter = GTK3.gtk_file_chooser_get_filter (handle); + filter = GTK.gtk_file_chooser_get_filter (handle); } if (filter != 0) { long filterNamePtr = GTK.gtk_file_filter_get_name (filter); @@ -379,13 +389,15 @@ Optional openNativeChooserDialog () { int action = (style & SWT.SAVE) != 0 ? GTK.GTK_FILE_CHOOSER_ACTION_SAVE : GTK.GTK_FILE_CHOOSER_ACTION_OPEN; long shellHandle = parent.topHandle(); Display display = parent != null ? parent.getDisplay (): Display.getCurrent(); - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { handle = GTK4.gtk_file_dialog_new(); - GTK4.gtk_file_dialog_set_title(handle, titleBytes); } else { - handle = GTK3.gtk_file_chooser_native_new(titleBytes, shellHandle, action, null, null); + handle = GTK.gtk_file_chooser_native_new(titleBytes, shellHandle, action, null, null); } if (handle == 0) error (SWT.ERROR_NO_HANDLES); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_title(handle, titleBytes); + } if (uriMode && !GTK.GTK4) { // GTK4 file chooser works on GFiles and does not need to worry about this @@ -403,46 +415,50 @@ Optional openNativeChooserDialog () { int response; long file = 0; if (GTK.GTK4) { - if ((style & SWT.MULTI) != 0) { - file = SyncDialogUtil.run(display, new AsyncReadyCallback() { - @Override - public void async(long callback) { - GTK4.gtk_file_dialog_open_multiple(handle, shellHandle, 0, callback, 0); - } - - @Override - public long await(long result) { - return GTK4.gtk_file_dialog_open_multiple_finish(handle, result, null); - } - }); - } else { - if ((style & SWT.SAVE) != 0) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + if ((style & SWT.MULTI) != 0) { file = SyncDialogUtil.run(display, new AsyncReadyCallback() { @Override public void async(long callback) { - GTK4.gtk_file_dialog_save(handle, shellHandle, 0, callback, 0); + GTK4.gtk_file_dialog_open_multiple(handle, shellHandle, 0, callback, 0); } @Override public long await(long result) { - return GTK4.gtk_file_dialog_save_finish(handle, result, null); + return GTK4.gtk_file_dialog_open_multiple_finish(handle, result, null); } }); } else { - file = SyncDialogUtil.run(display, new AsyncReadyCallback() { - @Override - public void async(long callback) { - GTK4.gtk_file_dialog_open(handle, shellHandle, 0, callback, 0); - } + if ((style & SWT.SAVE) != 0) { + file = SyncDialogUtil.run(display, new AsyncReadyCallback() { + @Override + public void async(long callback) { + GTK4.gtk_file_dialog_save(handle, shellHandle, 0, callback, 0); + } - @Override - public long await(long result) { - return GTK4.gtk_file_dialog_open_finish(handle, result, null); - } - }); + @Override + public long await(long result) { + return GTK4.gtk_file_dialog_save_finish(handle, result, null); + } + }); + } else { + file = SyncDialogUtil.run(display, new AsyncReadyCallback() { + @Override + public void async(long callback) { + GTK4.gtk_file_dialog_open(handle, shellHandle, 0, callback, 0); + } + + @Override + public long await(long result) { + return GTK4.gtk_file_dialog_open_finish(handle, result, null); + } + }); + } } + response = file != 0 ? GTK.GTK_RESPONSE_ACCEPT : GTK.GTK_RESPONSE_CANCEL; + } else { + response = SyncDialogUtil.run(display, handle, true); } - response = file != 0 ? GTK.GTK_RESPONSE_ACCEPT : GTK.GTK_RESPONSE_CANCEL; } else { display.externalEventLoop = true; display.sendPreExternalEventDispatchEvent (); @@ -469,8 +485,8 @@ public long await(long result) { void presetChooserDialog () { /* MULTI is only valid if the native dialog's action is Open */ - if (!GTK.GTK4 && (style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) { - GTK3.gtk_file_chooser_set_select_multiple (handle, true); + if ((GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) && (style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) { + GTK.gtk_file_chooser_set_select_multiple (handle, true); } if (filterPath == null) filterPath = ""; if (fileName == null) fileName = ""; @@ -484,7 +500,11 @@ void presetChooserDialog () { if (GTK.GTK4) { long file = OS.g_file_new_for_uri(buffer); - GTK4.gtk_file_dialog_set_initial_folder(handle, file); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_initial_folder(handle, file); + } else { + GTK4.gtk_file_chooser_set_current_folder (handle, file, 0); + } OS.g_object_unref(file); } else { GTK3.gtk_file_chooser_set_current_folder_uri (handle, buffer); @@ -502,7 +522,11 @@ void presetChooserDialog () { if (ptr != 0) { if (GTK.GTK4) { long file = OS.g_file_new_for_path(buffer); - GTK4.gtk_file_dialog_set_initial_folder(handle, file); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_initial_folder(handle, file); + } else { + GTK4.gtk_file_chooser_set_current_folder (handle, file, 0); + } OS.g_object_unref(file); } else { GTK3.gtk_file_chooser_set_current_folder (handle, ptr); @@ -538,10 +562,10 @@ void presetChooserDialog () { } } byte [] buffer = Converter.wcsToMbcs (filenameWithExt.toString (), true); - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { GTK4.gtk_file_dialog_set_initial_name(handle, buffer); } else { - GTK3.gtk_file_chooser_set_current_name (handle, buffer); + GTK.gtk_file_chooser_set_current_name (handle, buffer); } } } else { @@ -563,12 +587,20 @@ void presetChooserDialog () { long file; if (uriMode) { file = OS.g_file_new_for_uri(buffer); - GTK4.gtk_file_dialog_set_initial_file(handle, file); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_initial_file(handle, file); + } else { + GTK4.gtk_file_chooser_set_file (handle, file, 0); + } } else { file = OS.g_file_new_for_path(buffer); if (fileName.length() > 0) { - GTK4.gtk_file_dialog_set_initial_file(handle, file); + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + GTK4.gtk_file_dialog_set_initial_file(handle, file); + } else { + GTK4.gtk_file_chooser_set_file (handle, file, 0); + } } } @@ -609,7 +641,7 @@ void presetChooserDialog () { if (filterExtensions == null) filterExtensions = new String [0]; long initialFilter = 0; long fileFilters = 0; - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { fileFilters = OS.g_list_store_new(GTK.GTK_TYPE_FILE_FILTER()); } for (int i = 0; i < filterExtensions.length; i++) { @@ -634,25 +666,25 @@ void presetChooserDialog () { String current = filterExtensions [i].substring (start); byte [] filterString = Converter.wcsToMbcs (current, true); GTK.gtk_file_filter_add_pattern (filter, filterString); - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { OS.g_list_store_append(fileFilters, filter); } else { - GTK3.gtk_file_chooser_add_filter (handle, filter); + GTK.gtk_file_chooser_add_filter (handle, filter); } if (i == filterIndex) { initialFilter = filter; } } } - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { GTK4.gtk_file_dialog_set_filters(handle, fileFilters); OS.g_object_unref(fileFilters); } if (initialFilter != 0) { - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { GTK4.gtk_file_dialog_set_default_filter(handle, initialFilter); } else { - GTK3.gtk_file_chooser_set_filter(handle, initialFilter); + GTK.gtk_file_chooser_set_filter(handle, initialFilter); } } fullPath = null; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java index 26a75153355..dcffa7325a3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java @@ -160,14 +160,14 @@ public FontData open () { byte[] titleBytes = Converter.javaStringToCString(title); Display display = parent != null ? parent.getDisplay(): Display.getCurrent(); long handle; - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { handle = GTK4.gtk_font_dialog_new(); } else { - handle = GTK3.gtk_font_chooser_dialog_new (titleBytes, 0); + handle = GTK.gtk_font_chooser_dialog_new (titleBytes, 0); } if (handle == 0) error (SWT.ERROR_NO_HANDLES); - if (GTK.GTK4) { + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { GTK4.gtk_font_dialog_set_modal(handle, true); GTK4.gtk_font_dialog_set_title(handle, titleBytes); } else { @@ -186,7 +186,7 @@ public FontData open () { display.setModalDialog(this); // Set font chooser dialog to current font - if (fontData != null && !GTK.GTK4) { + if (fontData != null && (GTK.GTK_VERSION < OS.VERSION(4, 10, 0))) { Font font = new Font(display, fontData); long fontName = OS.pango_font_description_to_string(font.handle); @@ -196,7 +196,7 @@ public FontData open () { font.dispose(); OS.g_free(fontName); - GTK3.gtk_font_chooser_set_font(handle, buffer); + GTK.gtk_font_chooser_set_font(handle, buffer); } int signalId = 0; @@ -209,25 +209,31 @@ public FontData open () { int response; long fontDesc = 0; if (GTK.GTK4) { - long shellHandle = parent != null ? parent.topHandle() : 0; - Font font = new Font(display, fontData); - fontDesc = SyncDialogUtil.run(display, new AsyncReadyCallback() { - @Override - public void async(long callback) { - // The font dialog ignores the given font and simply picks the first installed font - // See https://gitlab.gnome.org/GNOME/gtk/-/issues/6892 - GTK4.gtk_font_dialog_choose_font(handle, shellHandle, font.handle, 0, callback, 0); - } + if (GTK.GTK_VERSION >= OS.VERSION(4, 10, 0)) { + long shellHandle = parent != null ? parent.topHandle() : 0; + Font font = fontData != null ? new Font(display, fontData) : null; + fontDesc = SyncDialogUtil.run(display, new AsyncReadyCallback() { + @Override + public void async(long callback) { + // The font dialog ignores the given font and simply picks the first installed font + // See https://gitlab.gnome.org/GNOME/gtk/-/issues/6892 + GTK4.gtk_font_dialog_choose_font(handle, shellHandle, font != null ? font.handle : 0, 0, callback, 0); + } - @Override - public long await(long result) { - return GTK4.gtk_font_dialog_choose_font_finish(handle, result, null); - } + @Override + public long await(long result) { + return GTK4.gtk_font_dialog_choose_font_finish(handle, result, null); + } - }); - font.dispose(); + }); + if (font != null) { + font.dispose(); + } - response = fontDesc != 0 ? GTK.GTK_RESPONSE_OK : GTK.GTK_RESPONSE_CANCEL; + response = fontDesc != 0 ? GTK.GTK_RESPONSE_OK : GTK.GTK_RESPONSE_CANCEL; + } else { + response = SyncDialogUtil.run(display, handle, false); + } } else { display.externalEventLoop = true; display.sendPreExternalEventDispatchEvent(); @@ -244,8 +250,8 @@ public long await(long result) { boolean success = response == GTK.GTK_RESPONSE_OK; if (success) { - if (!GTK.GTK4) { - long fontName = GTK3.gtk_font_chooser_get_font (handle); + if (GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) { + long fontName = GTK.gtk_font_chooser_get_font (handle); int length = C.strlen (fontName); byte [] buffer = new byte [length + 1]; C.memmove (buffer, fontName, length); @@ -261,7 +267,11 @@ public long await(long result) { display.removeIdleProc (); - if (!GTK.GTK4) { + if (GTK.GTK4) { + if (GTK.GTK_VERSION < OS.VERSION(4, 10, 0)) { + GTK4.gtk_window_destroy(handle); + } + } else { GTK3.gtk_widget_destroy(handle); }