author | anthony |
Tue, 30 Nov 2010 17:36:56 +0300 | |
changeset 7243 | 4678eab93673 |
parent 7150 | 6c95b4f80a72 |
child 7774 | 279c38a42ae5 |
permissions | -rw-r--r-- |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
1 |
#include <jni.h> |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
2 |
#include <stdio.h> |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
3 |
#include <jni_util.h> |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
4 |
#include <string.h> |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
5 |
#include "gtk2_interface.h" |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
6 |
#include "sun_awt_X11_GtkFileDialogPeer.h" |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
7 |
#include "debug_assert.h" |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
8 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
9 |
static JavaVM *jvm; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
10 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
11 |
/* To cache some method IDs */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
12 |
static jmethodID filenameFilterCallbackMethodID = NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
13 |
static jmethodID setFileInternalMethodID = NULL; |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
14 |
static jfieldID widgetFieldID = NULL; |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
15 |
|
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
16 |
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
17 |
(JNIEnv *env, jclass cx) |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
18 |
{ |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
19 |
filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx, |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
20 |
"filenameFilterCallback", "(Ljava/lang/String;)Z"); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
21 |
DASSERT(filenameFilterCallbackMethodID != NULL); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
22 |
|
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
23 |
setFileInternalMethodID = (*env)->GetMethodID(env, cx, |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
24 |
"setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V"); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
25 |
DASSERT(setFileInternalMethodID != NULL); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
26 |
|
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
27 |
widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J"); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
28 |
DASSERT(widgetFieldID != NULL); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
29 |
} |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
30 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
31 |
static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
32 |
{ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
33 |
JNIEnv *env; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
34 |
jclass cx; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
35 |
jstring filename; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
36 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
37 |
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
38 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
39 |
filename = (*env)->NewStringUTF(env, filter_info->filename); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
40 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
41 |
return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
42 |
filename); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
43 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
44 |
|
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
45 |
static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler) |
5943
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
46 |
{ |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
47 |
GtkWidget * dialog = (GtkWidget*)jlong_to_ptr( |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
48 |
(*env)->GetLongField(env, jpeer, widgetFieldID)); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
49 |
|
5943
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
50 |
if (dialog != NULL) |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
51 |
{ |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
52 |
// Callbacks from GTK signals are made within the GTK lock |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
53 |
// So, within a signal handler there is no need to call |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
54 |
// gdk_threads_enter() / fp_gdk_threads_leave() |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
55 |
if (!isSignalHandler) { |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
56 |
fp_gdk_threads_enter(); |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
57 |
} |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
58 |
|
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
59 |
fp_gtk_widget_hide (dialog); |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
60 |
fp_gtk_widget_destroy (dialog); |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
61 |
|
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
62 |
fp_gtk_main_quit (); |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
63 |
|
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
64 |
(*env)->SetLongField(env, jpeer, widgetFieldID, 0); |
5943
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
65 |
|
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
66 |
if (!isSignalHandler) { |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
67 |
fp_gdk_threads_leave(); |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
68 |
} |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
69 |
} |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
70 |
} |
240bcabaca0f
6966643: GTK FileDialog hangs when user manually closes it
dcherepanov
parents:
5759
diff
changeset
|
71 |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
72 |
/* |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
73 |
* Class: sun_awt_X11_GtkFileDialogPeer |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
74 |
* Method: quit |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
75 |
* Signature: ()V |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
76 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
77 |
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
78 |
(JNIEnv * env, jobject jpeer) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
79 |
{ |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
80 |
quit(env, jpeer, FALSE); |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
81 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
82 |
|
7243 | 83 |
/* |
84 |
* Class: sun_awt_X11_GtkFileDialogPeer |
|
85 |
* Method: toFront |
|
86 |
* Signature: ()V |
|
87 |
*/ |
|
88 |
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront |
|
89 |
(JNIEnv * env, jobject jpeer) |
|
90 |
{ |
|
91 |
GtkWidget * dialog; |
|
92 |
||
93 |
fp_gdk_threads_enter(); |
|
94 |
||
95 |
dialog = (GtkWidget*)jlong_to_ptr( |
|
96 |
(*env)->GetLongField(env, jpeer, widgetFieldID)); |
|
97 |
||
98 |
if (dialog != NULL) { |
|
99 |
fp_gtk_window_present((GtkWindow*)dialog); |
|
100 |
} |
|
101 |
||
102 |
fp_gdk_threads_leave(); |
|
103 |
} |
|
104 |
||
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
105 |
/** |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
106 |
* Convert a GSList to an array of filenames (without the parent folder) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
107 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
108 |
static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
109 |
{ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
110 |
jstring str; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
111 |
jclass stringCls; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
112 |
GSList *iterator; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
113 |
jobjectArray array; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
114 |
int i; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
115 |
char* entry; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
116 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
117 |
if (NULL == list) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
118 |
return NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
119 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
120 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
121 |
stringCls = (*env)->FindClass(env, "java/lang/String"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
122 |
if (stringCls == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
123 |
JNU_ThrowInternalError(env, "Could not get java.lang.String class"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
124 |
return NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
125 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
126 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
127 |
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
128 |
NULL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
129 |
if (array == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
130 |
JNU_ThrowInternalError(env, "Could not instantiate array files array"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
131 |
return NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
132 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
133 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
134 |
i = 0; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
135 |
for (iterator = list; iterator; iterator = iterator->next) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
136 |
entry = (char*) iterator->data; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
137 |
entry = strrchr(entry, '/') + 1; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
138 |
str = (*env)->NewStringUTF(env, entry); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
139 |
(*env)->SetObjectArrayElement(env, array, i, str); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
140 |
i++; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
141 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
142 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
143 |
return array; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
144 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
145 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
146 |
static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
147 |
{ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
148 |
JNIEnv *env; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
149 |
char *current_folder; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
150 |
GSList *filenames; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
151 |
jclass cx; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
152 |
jstring jcurrent_folder; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
153 |
jobjectArray jfilenames; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
154 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
155 |
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
156 |
current_folder = NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
157 |
filenames = NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
158 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
159 |
if (responseId == GTK_RESPONSE_ACCEPT) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
160 |
current_folder = fp_gtk_file_chooser_get_current_folder( |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
161 |
GTK_FILE_CHOOSER(aDialog)); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
162 |
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog)); |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
163 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
164 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
165 |
jcurrent_folder = (*env)->NewStringUTF(env, current_folder); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
166 |
jfilenames = toFilenamesArray(env, filenames); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
167 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
168 |
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
169 |
jfilenames); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
170 |
fp_g_free(current_folder); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
171 |
|
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
172 |
quit(env, (jobject)obj, TRUE); |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
173 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
174 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
175 |
/* |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
176 |
* Class: sun_awt_X11_GtkFileDialogPeer |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
177 |
* Method: run |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
178 |
* Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
179 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
180 |
JNIEXPORT void JNICALL |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
181 |
Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
182 |
jstring jtitle, jint mode, jstring jdir, jstring jfile, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
183 |
jobject jfilter, jboolean multiple) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
184 |
{ |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
185 |
GtkWidget *dialog = NULL; |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
186 |
GtkFileFilter *filter; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
187 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
188 |
if (jvm == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
189 |
(*env)->GetJavaVM(env, &jvm); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
190 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
191 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
192 |
fp_gdk_threads_enter(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
193 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
194 |
const char *title = (*env)->GetStringUTFChars(env, jtitle, 0); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
195 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
196 |
if (mode == 1) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
197 |
/* Save action */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
198 |
dialog = fp_gtk_file_chooser_dialog_new(title, NULL, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
199 |
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
200 |
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
201 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
202 |
else { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
203 |
/* Default action OPEN */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
204 |
dialog = fp_gtk_file_chooser_dialog_new(title, NULL, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
205 |
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
206 |
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
207 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
208 |
/* Set multiple selection mode, that is allowed only in OPEN action */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
209 |
if (multiple) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
210 |
fp_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
211 |
multiple); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
212 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
213 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
214 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
215 |
(*env)->ReleaseStringUTFChars(env, jtitle, title); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
216 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
217 |
/* Set the directory */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
218 |
if (jdir != NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
219 |
const char *dir = (*env)->GetStringUTFChars(env, jdir, 0); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
220 |
fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
221 |
(*env)->ReleaseStringUTFChars(env, jdir, dir); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
222 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
223 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
224 |
/* Set the filename */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
225 |
if (jfile != NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
226 |
const char *filename = (*env)->GetStringUTFChars(env, jfile, 0); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
227 |
fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
228 |
(*env)->ReleaseStringUTFChars(env, jfile, filename); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
229 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
230 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
231 |
/* Set the file filter */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
232 |
if (jfilter != NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
233 |
filter = fp_gtk_file_filter_new(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
234 |
fp_gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME, |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
235 |
filenameFilterCallback, jpeer, NULL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
236 |
fp_gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
237 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
238 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
239 |
/* Other Properties */ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
240 |
if (fp_gtk_check_version(2, 8, 0) == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
241 |
fp_gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
242 |
dialog), TRUE); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
243 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
244 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
245 |
fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
246 |
handle_response), jpeer); |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
247 |
|
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
248 |
(*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog)); |
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
249 |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
250 |
fp_gtk_widget_show(dialog); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
251 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
252 |
fp_gtk_main(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
253 |
fp_gdk_threads_leave(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
diff
changeset
|
254 |
} |
7150
6c95b4f80a72
6960655: GTKFileDialogPeer shouldn't be a singletone
anthony
parents:
5943
diff
changeset
|
255 |