67 |
static jmethodID provideImageID; |
static jmethodID provideImageID; |
68 |
static jmethodID provideURIsID; |
static jmethodID provideURIsID; |
69 |
|
|
70 |
|
/* Called when clipboard owner changes. Used to update available targets. */ |
71 |
|
#if GTK_MINOR_VERSION > 4 |
72 |
static void |
static void |
73 |
clipboard_owner_change_cb (GtkClipboard *clipboard __attribute__((unused)), |
clipboard_owner_change_cb (GtkClipboard *clipboard __attribute__((unused)), |
74 |
GdkEvent *event __attribute__((unused)), |
GdkEvent *event __attribute__((unused)), |
81 |
(*env)->CallStaticVoidMethod (env, gtk_clipboard_class, |
(*env)->CallStaticVoidMethod (env, gtk_clipboard_class, |
82 |
setSystemContentsID); |
setSystemContentsID); |
83 |
} |
} |
84 |
|
#endif |
85 |
|
|
86 |
JNIEXPORT jboolean JNICALL |
JNIEXPORT jboolean JNICALL |
87 |
Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, |
Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env, |
108 |
cp_gtk_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
cp_gtk_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
109 |
|
|
110 |
display = gtk_clipboard_get_display (cp_gtk_clipboard); |
display = gtk_clipboard_get_display (cp_gtk_clipboard); |
111 |
|
/* Check for support for clipboard owner changes. */ |
112 |
|
#if GTK_MINOR_VERSION > 4 |
113 |
if (gdk_display_supports_selection_notification (display)) |
if (gdk_display_supports_selection_notification (display)) |
114 |
{ |
{ |
115 |
g_signal_connect (cp_gtk_clipboard, "owner-change", |
g_signal_connect (cp_gtk_clipboard, "owner-change", |
119 |
can_cache = JNI_TRUE; |
can_cache = JNI_TRUE; |
120 |
} |
} |
121 |
else |
else |
122 |
|
#endif |
123 |
can_cache = JNI_FALSE; |
can_cache = JNI_FALSE; |
124 |
gdk_threads_leave (); |
gdk_threads_leave (); |
125 |
|
|
186 |
gtk_selection_data_set_text (selection, text, len); |
gtk_selection_data_set_text (selection, text, len); |
187 |
(*env)->ReleaseStringUTFChars (env, string, text); |
(*env)->ReleaseStringUTFChars (env, string, text); |
188 |
} |
} |
189 |
|
/* Images and URIs/Files support only available with gtk+2.6 or higher. */ |
190 |
|
#if GTK_MINOR_VERSION > 4 |
191 |
else if (info == IMAGE_TARGET) |
else if (info == IMAGE_TARGET) |
192 |
{ |
{ |
193 |
jobject gtkimage; |
jobject gtkimage; |
254 |
free (list[i]); |
free (list[i]); |
255 |
JCL_free (env, list); |
JCL_free (env, list); |
256 |
} |
} |
257 |
|
#endif |
258 |
} |
} |
259 |
|
|
260 |
static void |
static void |
275 |
(JNIEnv *env, |
(JNIEnv *env, |
276 |
jobject instance, |
jobject instance, |
277 |
jobjectArray mime_array, |
jobjectArray mime_array, |
278 |
jboolean add_text, |
#if GTK_MINOR_VERSION > 4 |
279 |
|
jboolean add_text, jboolean add_images, jboolean add_uris) |
280 |
|
#else |
281 |
|
jboolean add_text __attribute__((unused)), |
282 |
jboolean add_images __attribute__((unused)), |
jboolean add_images __attribute__((unused)), |
283 |
jboolean add_uris __attribute__((unused))) |
jboolean add_uris __attribute__((unused))) |
284 |
|
#endif |
285 |
{ |
{ |
286 |
GtkTargetList *target_list; |
GtkTargetList *target_list; |
287 |
GList *list; |
GList *list; |
315 |
} |
} |
316 |
|
|
317 |
/* Add extra targets that gtk+ can provide/translate for us. */ |
/* Add extra targets that gtk+ can provide/translate for us. */ |
318 |
|
#if GTK_MINOR_VERSION > 4 |
319 |
if (add_text) |
if (add_text) |
320 |
gtk_target_list_add_text_targets (target_list, TEXT_TARGET); |
gtk_target_list_add_text_targets (target_list, TEXT_TARGET); |
321 |
if (add_images) |
if (add_images) |
322 |
gtk_target_list_add_image_targets (target_list, IMAGE_TARGET, TRUE); |
gtk_target_list_add_image_targets (target_list, IMAGE_TARGET, TRUE); |
323 |
if (add_uris) |
if (add_uris) |
324 |
gtk_target_list_add_uri_targets (target_list, URI_TARGET); |
gtk_target_list_add_uri_targets (target_list, URI_TARGET); |
325 |
|
#else |
326 |
|
if (add_text) |
327 |
|
gtk_target_list_add (target_list, |
328 |
|
gdk_atom_intern ("STRING", FALSE), |
329 |
|
0, TEXT_TARGET); |
330 |
|
#endif |
331 |
|
|
332 |
|
|
333 |
/* Turn list into a target table. */ |
/* Turn list into a target table. */ |
334 |
n = g_list_length (target_list->list); |
n = g_list_length (target_list->list); |
346 |
} |
} |
347 |
|
|
348 |
/* Set the targets plus callback functions and ask for the clipboard |
/* Set the targets plus callback functions and ask for the clipboard |
349 |
to be stored when the application exists. */ |
to be stored when the application exists if supported. */ |
350 |
current_selection++; |
current_selection++; |
351 |
if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n, |
if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n, |
352 |
clipboard_get_func, |
clipboard_get_func, |
386 |
if (provideURIsID == NULL) |
if (provideURIsID == NULL) |
387 |
return; |
return; |
388 |
} |
} |
389 |
|
#if GTK_MINOR_VERSION > 4 |
390 |
gtk_clipboard_set_can_store (cp_gtk_clipboard, NULL, 0); |
gtk_clipboard_set_can_store (cp_gtk_clipboard, NULL, 0); |
391 |
|
#endif |
392 |
} |
} |
393 |
else |
else |
394 |
{ |
{ |