Beispiel #1
0
void
cp_gtk_filedialog_init_jni (void)
{
    jclass gtkfiledialogpeer;

    gtkfiledialogpeer =
        (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
                                        "gnu/java/awt/peer/gtk/GtkFileDialogPeer");

    gtkDisposeFileDialogID =
        (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
                                          gtkfiledialogpeer,
                                          "gtkDisposeFileDialog", "()V");

    gtkHideFileDialogID =
        (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
                                          gtkfiledialogpeer,
                                          "gtkHideFileDialog", "()V");

    gtkSetFilenameID =
        (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
                                          gtkfiledialogpeer,
                                          "gtkSetFilename",
                                          "(Ljava/lang/String;)V");

    filenameFilterCallbackID =
        (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
                                          gtkfiledialogpeer,
                                          "filenameFilterCallback",
                                          "(Ljava/lang/String;)Z");
}
static void
selection_changed_cb (GtkComboBox *combobox, jobject peer)
{
  gint index = gtk_combo_box_get_active(combobox);

  if (index >= 0)
    (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
					 postChoiceItemEventID, (jint)index );
}
static void
item_toggled_cb (GtkToggleButton *item, jobject peer)
{
  (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(), peer,
                                postItemEventID,
                                peer,
                                item->active ?
                                (jint) AWT_ITEM_SELECTED :
                                (jint) AWT_ITEM_DESELECTED);
}
void
cp_gtk_list_init_jni (void)
{
  jclass gtklistpeer;

  gtklistpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
                                         "gnu/java/awt/peer/gtk/GtkListPeer");

  postListItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtklistpeer,
                                                   "postItemEvent",
                                                   "(II)V");
}
void
cp_gtk_choice_init_jni (void)
{
  jclass gtkchoicepeer;

  gtkchoicepeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
                                        "gnu/java/awt/peer/gtk/GtkChoicePeer");

  postChoiceItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkchoicepeer,
                                               "postChoiceItemEvent",
                                               "(I)V");
}
void
cp_gtk_checkbox_init_jni (void)
{
  jclass gtkcheckboxpeer;

  gtkcheckboxpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
                                             "gnu/java/awt/peer/gtk/GtkCheckboxPeer");

  postItemEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcheckboxpeer,
                                               "postItemEvent", 
                                               "(Ljava/lang/Object;I)V");
}
Beispiel #7
0
/* This function interfaces with the Java callback method of the same name.
   This function extracts the filename from the GtkFileFilterInfo object,
   and passes it to the Java method.  The Java method will call the filter's
   accept() method and will give back the return value. */
static gboolean filename_filter_cb (const GtkFileFilterInfo *filter_info,
                                    gpointer obj)
{
    jstring *filename;
    gboolean accepted;

    filename = (*cp_gtk_gdk_env())->NewStringUTF(cp_gtk_gdk_env(), filter_info->filename);

    accepted = (*cp_gtk_gdk_env())->CallBooleanMethod(cp_gtk_gdk_env(), obj,
               filenameFilterCallbackID,
               filename);

    return accepted;
}
/**
 * A callback function that implements gdk_threads_enter(). This is
 * implemented to wrap the JNI MonitorEnter() function.
 */
static void jni_lock_cb()
{
  JNIEnv * env = cp_gtk_gdk_env();
  if ((*env)->MonitorEnter(env, global_lock) != JNI_OK)
    {
      printf("failure while entering GTK monitor\n");
    }
}
/**
 * A callback function that implements gdk_threads_leave(). This is
 * implemented to wrap the JNI MonitorExit() function.
 */
static void jni_unlock_cb()
{

  JNIEnv * env = cp_gtk_gdk_env();
  if ((*env)->MonitorExit(env, global_lock))
    {
      printf("failure while exiting GTK monitor\n");
    }
}
void
cp_gtk_component_init_jni (void)
 {
  jclass gtkcomponentpeer;

  gtkcomponentpeer = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
                                     "gnu/java/awt/peer/gtk/GtkComponentPeer");

  postMouseEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
                                               "postMouseEvent", "(IJIIIIZ)V");

  postMouseWheelEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(),
						        gtkcomponentpeer,
						        "postMouseWheelEvent",
							"(IJIIIIZIII)V");

  postExposeEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
                                                 "postExposeEvent", "(IIII)V");

  postFocusEventID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gtkcomponentpeer,
                                                "postFocusEvent", "(IZ)V");
}
static jclass gtk_clipboard_class;

static jmethodID setSystemContentsID;
static jmethodID provideContentID;
static jmethodID provideTextID;
static jmethodID provideImageID;
static jmethodID provideURIsID;

/* Called when clipboard owner changes. Used to update available targets. */
#if GTK_MINOR_VERSION > 4
static void
clipboard_owner_change_cb (GtkClipboard *clipboard,
			   GdkEvent *event __attribute__((unused)),
			   gpointer user_data __attribute__((unused)))
{
  JNIEnv *env = cp_gtk_gdk_env ();
  if (clipboard == cp_gtk_clipboard)
    (*env)->CallVoidMethod (env, cp_gtk_clipboard_instance,
			    setSystemContentsID, JNI_FALSE);
  else
    (*env)->CallVoidMethod (env, cp_gtk_selection_instance,
                            setSystemContentsID, JNI_FALSE);

}
#endif

JNIEXPORT jboolean JNICALL 
Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,
							 jclass clz,
							 jobject gtkclipboard,
							 jobject gtkselection,