37 |
|
|
38 |
|
|
39 |
#include "gtkpeer.h" |
#include "gtkpeer.h" |
40 |
|
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" |
41 |
#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h" |
#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h" |
42 |
|
|
43 |
static void textcomponent_commit_cb (GtkIMContext *context, |
static void textcomponent_commit_cb (GtkIMContext *context, |
150 |
GtkEditable *editable; // type of GtkEntry (TextField) |
GtkEditable *editable; // type of GtkEntry (TextField) |
151 |
GtkWidget *text = NULL; // type of GtkTextView (TextArea) |
GtkWidget *text = NULL; // type of GtkTextView (TextArea) |
152 |
GtkTextBuffer *buf; |
GtkTextBuffer *buf; |
|
GtkTextMark *mark; |
|
153 |
GtkTextIter iter; |
GtkTextIter iter; |
154 |
|
|
155 |
ptr = NSA_GET_PTR (env, obj); |
ptr = NSA_GET_PTR (env, obj); |
174 |
if (text) |
if (text) |
175 |
{ |
{ |
176 |
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); |
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text)); |
177 |
mark = gtk_text_buffer_get_insert (buf); |
gtk_text_buffer_get_iter_at_offset (buf, &iter, pos); |
178 |
gtk_text_buffer_get_iter_at_mark (buf, &iter, mark); |
gtk_text_buffer_place_cursor (buf, &iter); |
|
gtk_text_iter_set_offset (&iter, pos); |
|
179 |
} |
} |
180 |
} |
} |
181 |
|
|
416 |
const char *str; |
const char *str; |
417 |
GtkWidget *text = NULL; // type of GtkTextView (TextArea) |
GtkWidget *text = NULL; // type of GtkTextView (TextArea) |
418 |
GtkTextBuffer *buf; |
GtkTextBuffer *buf; |
|
jobject *obj_ptr; |
|
419 |
|
|
420 |
ptr = NSA_GET_PTR (env, obj); |
ptr = NSA_GET_PTR (env, obj); |
421 |
str = (*env)->GetStringUTFChars (env, contents, NULL); |
str = (*env)->GetStringUTFChars (env, contents, NULL); |
456 |
{ |
{ |
457 |
/* str is a \0-terminated UTF-8 encoded character. */ |
/* str is a \0-terminated UTF-8 encoded character. */ |
458 |
gunichar2 *jc = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL); |
gunichar2 *jc = g_utf8_to_utf16 (str, -1, NULL, NULL, NULL); |
459 |
|
GdkEvent *event = gtk_get_current_event (); |
460 |
|
|
461 |
if (jc) |
if (jc) |
462 |
(*gdk_env)->CallVoidMethod (gdk_env, peer, |
(*gdk_env)->CallVoidMethod (gdk_env, peer, |
463 |
postKeyEventID, |
postKeyEventID, |
464 |
(jint) AWT_KEY_TYPED, |
(jint) AWT_KEY_TYPED, |
465 |
/* We don't have access to the event |
(jlong) event->key.time, |
466 |
that caused this commit signal to |
keyevent_state_to_awt_mods (event), |
|
be fired. So approximate the event |
|
|
time... */ |
|
|
(jlong) gdk_event_get_time (NULL), |
|
|
/* ... and assume no modifiers. */ |
|
|
0, |
|
467 |
VK_UNDEFINED, |
VK_UNDEFINED, |
468 |
(jchar) jc[0], |
(jchar) jc[0], |
469 |
AWT_KEY_LOCATION_UNKNOWN); |
AWT_KEY_LOCATION_UNKNOWN); |
470 |
g_free (jc); |
g_free (jc); |
471 |
|
gdk_event_free (event); |
472 |
} |
} |
473 |
|
|
474 |
static void |
static void |
475 |
textcomponent_changed_cb (GtkEditable *editable, |
textcomponent_changed_cb (GtkEditable *editable, |
476 |
jobject peer) |
jobject peer) |
477 |
{ |
{ |
478 |
(*gdk_env)->CallVoidMethod (gdk_env, peer, postTextEventID); |
(*gdk_env)->CallVoidMethod (gdk_env, peer, postTextEventID); |
479 |
} |
} |