Bug 561047 - Require Gtk 3.20+ as minimum
Remove non-native file/directory dialogs.
Change-Id: I022c0e38dce0578513241f6746439c9ad0ff7b64
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
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 290fff4..5388fc4 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
@@ -5413,28 +5413,6 @@
}
#endif
-#ifndef NO_gtk_1file_1chooser_1dialog_1new
-JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1file_1chooser_1dialog_1new)
- (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1, jint arg2, jbyteArray arg3, jint arg4, jbyteArray arg5, jint arg6, jlong arg7)
-{
- jbyte *lparg0=NULL;
- jbyte *lparg3=NULL;
- jbyte *lparg5=NULL;
- jlong rc = 0;
- GTK_NATIVE_ENTER(env, that, gtk_1file_1chooser_1dialog_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 (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
- rc = (jlong)gtk_file_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1, arg2, (const gchar *)lparg3, arg4, lparg5, arg6, (const gchar *)NULL);
-fail:
- if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
- 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_1dialog_1new_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO_gtk_1file_1chooser_1get_1filename
JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1file_1chooser_1get_1filename)
(JNIEnv *env, jclass that, jlong arg0)
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 aecbde2..2295ed2 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
@@ -460,7 +460,6 @@
"gtk_1expander_1set_1expanded",
"gtk_1expander_1set_1label_1widget",
"gtk_1file_1chooser_1add_1filter",
- "gtk_1file_1chooser_1dialog_1new",
"gtk_1file_1chooser_1get_1filename",
"gtk_1file_1chooser_1get_1filenames",
"gtk_1file_1chooser_1get_1filter",
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 78cc5b7..fc25816 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
@@ -458,7 +458,6 @@
gtk_1expander_1set_1expanded_FUNC,
gtk_1expander_1set_1label_1widget_FUNC,
gtk_1file_1chooser_1add_1filter_FUNC,
- gtk_1file_1chooser_1dialog_1new_FUNC,
gtk_1file_1chooser_1get_1filename_FUNC,
gtk_1file_1chooser_1get_1filenames_FUNC,
gtk_1file_1chooser_1get_1filter_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 aad099a..7acc941 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
@@ -911,13 +911,6 @@
* @param filter cast=(GtkFileFilter *)
*/
public static final native void gtk_file_chooser_add_filter(long chooser, long filter);
- /**
- * @param title cast=(const gchar *),flags=no_out
- * @param parent cast=(GtkWindow *)
- * @param first_button_text cast=(const gchar *),flags=no_out
- * @param terminator cast=(const gchar *),flags=sentinel
- */
- public static final native long gtk_file_chooser_dialog_new(byte[] title, long parent, int action, byte[] first_button_text, int first_button_id, byte[] second_button_text, int second_button_id, long terminator);
/** @param chooser cast=(GtkFileChooser *) */
public static final native long gtk_file_chooser_get_filename(long chooser);
/** @param chooser cast=(GtkFileChooser *) */
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 825f8ea..450331d 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
@@ -120,11 +120,7 @@
* </ul>
*/
public String open () {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
return openNativeChooserDialog();
- } else {
- return openChooserDialog ();
- }
}
/**
* Open the file chooser dialog using the GtkFileChooserNative API (GTK3.20+) for running applications
@@ -221,113 +217,6 @@
display.removeIdleProc ();
return answer;
}
-String openChooserDialog () {
- byte [] titleBytes = Converter.wcsToMbcs (title, true);
- long shellHandle = parent.topHandle ();
- Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
- long handle = 0;
- if (display.getDismissalAlignment() == SWT.RIGHT) {
- handle = GTK.gtk_file_chooser_dialog_new (titleBytes, shellHandle, GTK.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK.GTK_NAMED_LABEL_CANCEL, GTK.GTK_RESPONSE_CANCEL, GTK.GTK_NAMED_LABEL_OK, GTK.GTK_RESPONSE_OK, 0);
- } else {
- handle = GTK.gtk_file_chooser_dialog_new (titleBytes, shellHandle, GTK.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK.GTK_NAMED_LABEL_OK, GTK.GTK_RESPONSE_OK, GTK.GTK_NAMED_LABEL_CANCEL, GTK.GTK_RESPONSE_CANCEL, 0);
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- long group = GTK.gtk_window_get_group(0);
- GTK.gtk_window_group_add_window (group, handle);
- GTK.gtk_window_set_modal (handle, true);
- long pixbufs = GTK.gtk_window_get_icon_list (shellHandle);
- if (pixbufs != 0) {
- GTK.gtk_window_set_icon_list (handle, pixbufs);
- OS.g_list_free (pixbufs);
- }
- if (filterPath != null && filterPath.length () > 0) {
- StringBuilder stringBuilder = new StringBuilder ();
- /* filename must be a full path */
- if (!filterPath.startsWith (SEPARATOR)) {
- stringBuilder.append (SEPARATOR);
- }
- stringBuilder.append (filterPath);
- byte [] buffer = Converter.wcsToMbcs (stringBuilder.toString (), true);
- /*
- * in GTK version 2.10, gtk_file_chooser_set_current_folder requires path
- * to be true canonical path. So using realpath to convert the path to
- * true canonical path.
- */
- long ptr = OS.realpath (buffer, null);
- if (ptr != 0) {
- GTK.gtk_file_chooser_set_current_folder (handle, ptr);
- OS.g_free (ptr);
- }
- }
- if (message.length () > 0) {
- byte [] buffer = Converter.wcsToMbcs (message, true);
- long box = GTK.gtk_box_new (GTK.GTK_ORIENTATION_HORIZONTAL, 0);
- GTK.gtk_box_set_homogeneous (box, false);
- if (box == 0) error (SWT.ERROR_NO_HANDLES);
- long label = GTK.gtk_label_new (buffer);
- if (label == 0) error (SWT.ERROR_NO_HANDLES);
- GTK.gtk_container_add (box, label);
- GTK.gtk_widget_show (label);
- GTK.gtk_label_set_line_wrap (label, true);
- GTK.gtk_label_set_justify (label, GTK.GTK_JUSTIFY_CENTER);
- GTK.gtk_file_chooser_set_extra_widget (handle, box);
- }
- String answer = null;
- display.addIdleProc ();
- Dialog oldModal = null;
- if (GTK.gtk_window_get_modal (handle)) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
- }
- int signalId = 0;
- long hookId = 0;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- signalId = OS.g_signal_lookup (OS.map, GTK.GTK_TYPE_WIDGET());
- hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
- }
- display.externalEventLoop = true;
- display.sendPreExternalEventDispatchEvent ();
- int response = GTK.gtk_dialog_run (handle);
- /*
- * This call to gdk_threads_leave() is a temporary work around
- * to avoid deadlocks when gdk_threads_init() is called by native
- * code outside of SWT (i.e AWT, etc). It ensures that the current
- * thread leaves the GTK lock acquired by the function above.
- */
- if (!GTK.GTK4) GDK.gdk_threads_leave();
- display.externalEventLoop = false;
- display.sendPostExternalEventDispatchEvent ();
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- OS.g_signal_remove_emission_hook (signalId, hookId);
- }
- if (GTK.gtk_window_get_modal (handle)) {
- display.setModalDialog (oldModal);
- }
- if (response == GTK.GTK_RESPONSE_OK) {
- long path = GTK.gtk_file_chooser_get_filename (handle);
- if (path != 0) {
- long utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, null, null);
- if (utf8Ptr == 0) utf8Ptr = OS.g_filename_display_name (path);
- if (path != utf8Ptr) OS.g_free (path);
- if (utf8Ptr != 0) {
- long [] items_written = new long [1];
- long utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- OS.g_free (utf8Ptr);
- if (utf16Ptr != 0) {
- int clength = (int)items_written [0];
- char [] chars = new char [clength];
- C.memmove (chars, utf16Ptr, clength * 2);
- OS.g_free (utf16Ptr);
- answer = new String (chars);
- filterPath = answer;
- }
- }
- }
- }
- display.removeIdleProc ();
- GTK.gtk_widget_destroy (handle);
- return answer;
-}
/**
* Sets the path that the dialog will use to filter
* the directories it shows to the argument, which may
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 59049a2..9329d83 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
@@ -301,11 +301,7 @@
* </ul>
*/
public String open () {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
- return openNativeChooserDialog();
- } else {
- return openChooserDialog();
- }
+ return openNativeChooserDialog();
}
/**
* Open the file chooser dialog using the GtkFileChooserNative API (GTK3.20+) for running applications
@@ -316,7 +312,6 @@
* @return a string describing the absolute path of the first selected file, or null
*/
String openNativeChooserDialog () {
- assert GTK.GTK_VERSION >= OS.VERSION(3, 20, 0);
byte [] titleBytes = Converter.wcsToMbcs (title, true);
int action = (style & SWT.SAVE) != 0 ? GTK.GTK_FILE_CHOOSER_ACTION_SAVE : GTK.GTK_FILE_CHOOSER_ACTION_OPEN;
long shellHandle = parent.topHandle ();
@@ -358,69 +353,7 @@
display.removeIdleProc ();
return answer;
}
-String openChooserDialog () {
- byte [] titleBytes = Converter.wcsToMbcs (title, true);
- 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 (display.getDismissalAlignment() == SWT.RIGHT) {
- handle = GTK.gtk_file_chooser_dialog_new (titleBytes, shellHandle, action, GTK.GTK_NAMED_LABEL_CANCEL, GTK.GTK_RESPONSE_CANCEL, GTK.GTK_NAMED_LABEL_OK, GTK.GTK_RESPONSE_OK, 0);
- } else {
- handle = GTK.gtk_file_chooser_dialog_new (titleBytes, shellHandle, action, GTK.GTK_NAMED_LABEL_OK, GTK.GTK_RESPONSE_OK, GTK.GTK_NAMED_LABEL_CANCEL, GTK.GTK_RESPONSE_CANCEL, 0);
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- GTK.gtk_window_set_modal (handle, true);
- long group = GTK.gtk_window_get_group(0);
- GTK.gtk_window_group_add_window (group, handle);
- long pixbufs = GTK.gtk_window_get_icon_list (shellHandle);
- if (pixbufs != 0) {
- GTK.gtk_window_set_icon_list (handle, pixbufs);
- OS.g_list_free (pixbufs);
- }
- if (uriMode) {
- GTK.gtk_file_chooser_set_local_only (handle, false);
- }
- presetChooserDialog ();
- display.addIdleProc ();
- String answer = null;
- Dialog oldModal = null;
- if (GTK.gtk_window_get_modal (handle)) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
- }
- int signalId = 0;
- long hookId = 0;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- signalId = OS.g_signal_lookup (OS.map, GTK.GTK_TYPE_WIDGET());
- hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
- }
- display.externalEventLoop = true;
- display.sendPreExternalEventDispatchEvent ();
- int response = GTK.gtk_dialog_run (handle);
- /*
- * This call to gdk_threads_leave() is a temporary work around
- * to avoid deadlocks when gdk_threads_init() is called by native
- * code outside of SWT (i.e AWT, etc). It ensures that the current
- * thread leaves the GTK lock acquired by the function above.
- */
- if (!GTK.GTK4) GDK.gdk_threads_leave();
- display.externalEventLoop = false;
- display.sendPostExternalEventDispatchEvent ();
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- OS.g_signal_remove_emission_hook (signalId, hookId);
- }
- if (GTK.gtk_window_get_modal (handle)) {
- display.setModalDialog (oldModal);
- }
- if (response == GTK.GTK_RESPONSE_OK) {
- answer = computeResultChooserDialog ();
- }
- display.removeIdleProc ();
- GTK.gtk_widget_destroy (handle);
- return answer;
-}
+
void presetChooserDialog () {
/* MULTI is only valid if the native dialog's action is Open */
if ((style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) {