提交 c4e9a49b 编写于 作者: D dcherepanov

7009114: GTK FileDialog lies about it's Bounds

Reviewed-by: art, anthony
上级 832e5e9d
...@@ -432,6 +432,7 @@ SUNWprivate_1.1 { ...@@ -432,6 +432,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_GtkFileDialogPeer_run; Java_sun_awt_X11_GtkFileDialogPeer_run;
Java_sun_awt_X11_GtkFileDialogPeer_quit; Java_sun_awt_X11_GtkFileDialogPeer_quit;
Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_awt_X11_GtkFileDialogPeer_toFront;
Java_sun_awt_X11_GtkFileDialogPeer_setBounds;
Java_sun_print_CUPSPrinter_initIDs; Java_sun_print_CUPSPrinter_initIDs;
Java_sun_print_CUPSPrinter_getCupsServer; Java_sun_print_CUPSPrinter_getCupsServer;
......
...@@ -56,12 +56,14 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer { ...@@ -56,12 +56,14 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
} }
private native void run(String title, int mode, String dir, String file, private native void run(String title, int mode, String dir, String file,
FilenameFilter filter, boolean isMultipleMode); FilenameFilter filter, boolean isMultipleMode, int x, int y);
private native void quit(); private native void quit();
@Override @Override
public native void toFront(); public native void toFront();
@Override
public native void setBounds(int x, int y, int width, int height, int op);
/** /**
* Called exclusively by the native C code. * Called exclusively by the native C code.
...@@ -106,9 +108,8 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer { ...@@ -106,9 +108,8 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
Thread t = new Thread() { Thread t = new Thread() {
public void run() { public void run() {
GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(), GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(),
fd.getDirectory(), fd.getFile(), fd fd.getDirectory(), fd.getFile(), fd.getFilenameFilter(), fd.isMultipleMode(),
.getFilenameFilter(), fd fd.getX(), fd.getY());
.isMultipleMode());
fd.setVisible(false); fd.setVisible(false);
} }
}; };
......
...@@ -608,7 +608,10 @@ gboolean gtk2_load() ...@@ -608,7 +608,10 @@ gboolean gtk2_load()
fp_gtk_viewport_new = dl_symbol("gtk_viewport_new"); fp_gtk_viewport_new = dl_symbol("gtk_viewport_new");
fp_gtk_window_new = dl_symbol("gtk_window_new"); fp_gtk_window_new = dl_symbol("gtk_window_new");
fp_gtk_window_present = dl_symbol("gtk_window_present"); fp_gtk_window_present = dl_symbol("gtk_window_present");
fp_gtk_dialog_new = dl_symbol("gtk_dialog_new"); fp_gtk_window_move = dl_symbol("gtk_window_move");
fp_gtk_window_resize = dl_symbol("gtk_window_resize");
fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
fp_gtk_frame_new = dl_symbol("gtk_frame_new"); fp_gtk_frame_new = dl_symbol("gtk_frame_new");
fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new"); fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new");
......
...@@ -750,7 +750,8 @@ int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf); ...@@ -750,7 +750,8 @@ int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error); GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
void (*fp_gtk_widget_destroy)(GtkWidget *widget); void (*fp_gtk_widget_destroy)(GtkWidget *widget);
void (*fp_gtk_window_present)(GtkWindow *window); void (*fp_gtk_window_present)(GtkWindow *window);
void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
/** /**
* Function Pointers for GtkFileChooser * Function Pointers for GtkFileChooser
......
...@@ -102,6 +102,33 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront ...@@ -102,6 +102,33 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
fp_gdk_threads_leave(); fp_gdk_threads_leave();
} }
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: setBounds
* Signature: (IIIII)V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
(JNIEnv * env, jobject jpeer, jint x, jint y, jint width, jint height, jint op)
{
GtkWindow* dialog;
fp_gdk_threads_enter();
dialog = (GtkWindow*)jlong_to_ptr(
(*env)->GetLongField(env, jpeer, widgetFieldID));
if (dialog != NULL) {
if (x >= 0 && y >= 0) {
fp_gtk_window_move(dialog, (gint)x, (gint)y);
}
if (width > 0 && height > 0) {
fp_gtk_window_resize(dialog, (gint)width, (gint)height);
}
}
fp_gdk_threads_leave();
}
/** /**
* Convert a GSList to an array of filenames (without the parent folder) * Convert a GSList to an array of filenames (without the parent folder)
*/ */
...@@ -175,12 +202,12 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj) ...@@ -175,12 +202,12 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
/* /*
* Class: sun_awt_X11_GtkFileDialogPeer * Class: sun_awt_X11_GtkFileDialogPeer
* Method: run * Method: run
* Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
jstring jtitle, jint mode, jstring jdir, jstring jfile, jstring jtitle, jint mode, jstring jdir, jstring jfile,
jobject jfilter, jboolean multiple) jobject jfilter, jboolean multiple, int x, int y)
{ {
GtkWidget *dialog = NULL; GtkWidget *dialog = NULL;
GtkFileFilter *filter; GtkFileFilter *filter;
...@@ -244,6 +271,14 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, ...@@ -244,6 +271,14 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
dialog), TRUE); dialog), TRUE);
} }
/* Set the initial location */
if (x >= 0 && y >= 0) {
fp_gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
// NOTE: it doesn't set the initial size for the file chooser
// as it seems like the file chooser overrides the size internally
}
fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK( fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
handle_response), jpeer); handle_response), jpeer);
......
...@@ -20,10 +20,10 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs ...@@ -20,10 +20,10 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
/* /*
* Class: sun_awt_X11_GtkFileDialogPeer * Class: sun_awt_X11_GtkFileDialogPeer
* Method: run * Method: run
* Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V
*/ */
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run
(JNIEnv *, jobject, jstring, jint, jstring, jstring, jobject, jboolean); (JNIEnv *, jobject, jstring, jint, jstring, jstring, jobject, jboolean, jint, jint);
/* /*
* Class: sun_awt_X11_GtkFileDialogPeer * Class: sun_awt_X11_GtkFileDialogPeer
...@@ -41,6 +41,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit ...@@ -41,6 +41,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: setBounds
* Signature: (IIIII)V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
(JNIEnv * env, jobject jpeer, jint x, jint y, jint width, jint height, jint op);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册