src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 21,44 **** --- 21,48 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ + #include <X11/Xlib.h> #include <jni.h> #include <stdio.h> #include <jni_util.h> #include <string.h> #include "gtk2_interface.h" #include "sun_awt_X11_GtkFileDialogPeer.h" #include "java_awt_FileDialog.h" #include "debug_assert.h" + extern Display *awt_display; + static JavaVM *jvm; /* To cache some method IDs */ static jmethodID filenameFilterCallbackMethodID = NULL; static jmethodID setFileInternalMethodID = NULL; + static jmethodID notifyConfigureMethodID = NULL; static jfieldID widgetFieldID = NULL; JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs (JNIEnv *env, jclass cx) {
*** 48,57 **** --- 52,65 ---- setFileInternalMethodID = (*env)->GetMethodID(env, cx, "setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V"); DASSERT(setFileInternalMethodID != NULL); + notifyConfigureMethodID = (*env)->GetMethodID(env, cx, + "notifyConfigure", "(JIIII)V"); + DASSERT(notifyConfigureMethodID != NULL); + widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J"); DASSERT(widgetFieldID != NULL); } static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj)
*** 279,295 **** --- 287,313 ---- fp_g_free(current_folder); quit(env, (jobject)obj, TRUE); } + gboolean handle_configure(GtkWidget *dialog, GdkEventConfigure *e, gpointer obj) { + JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); + + (*env)->CallVoidMethod(env, obj, notifyConfigureMethodID, + fp_gdk_x11_drawable_get_xid(dialog->window), e->x, e->y, e->width, e->height); + + return FALSE; + } + /* * Class: sun_awt_X11_GtkFileDialogPeer * Method: run * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V */ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, + jlong owner, jstring jtitle, jint mode, jstring jdir, jstring jfile, jobject jfilter, jboolean multiple, int x, int y) { GtkWidget *dialog = NULL; GtkFileFilter *filter;
*** 363,376 **** // 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( handle_response), jpeer); ! (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog)); fp_gtk_widget_show(dialog); fp_gtk_main(); fp_gdk_threads_leave(); --- 381,401 ---- // NOTE: it doesn't set the initial size for the file chooser // as it seems like the file chooser overrides the size internally } + (*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog)); + fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK( handle_response), jpeer); + fp_g_signal_connect(G_OBJECT(dialog), "configure-event", G_CALLBACK( + handle_configure), jpeer); ! if (owner && dialog) { ! fp_gtk_widget_realize(dialog); ! XSetTransientForHint(awt_display, fp_gdk_x11_drawable_get_xid(dialog->window), owner); ! } fp_gtk_widget_show(dialog); fp_gtk_main(); fp_gdk_threads_leave();