/[classpath]/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
ViewVC logotype

Diff of /classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by mark, Sat Jul 2 20:32:53 2005 UTC revision 1.11 by fitzsim, Mon Jul 11 23:27:43 2005 UTC
# Line 43  jmethodID stringSelectionReceivedID; Line 43  jmethodID stringSelectionReceivedID;
43  jmethodID stringSelectionHandlerID;  jmethodID stringSelectionHandlerID;
44  jmethodID selectionClearID;  jmethodID selectionClearID;
45    
46  void selection_received (GtkWidget *, GtkSelectionData *, guint, gpointer);  void selection_received_cb (GtkWidget *, GtkSelectionData *, guint, gpointer);
47  void selection_get (GtkWidget *, GtkSelectionData *, guint, guint, gpointer);  void selection_get_cb (GtkWidget *, GtkSelectionData *, guint, guint, gpointer);
48  gint selection_clear (GtkWidget *, GdkEventSelection *);  gint selection_clear_cb (GtkWidget *, GdkEventSelection *);
49    
50  GtkWidget *clipboard;  GtkWidget *clipboard;
51  jobject cb_obj;  jobject cb_obj;
# Line 54  JNIEXPORT void JNICALL Line 54  JNIEXPORT void JNICALL
54  Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,  Java_gnu_java_awt_peer_gtk_GtkClipboard_initNativeState (JNIEnv *env,
55                                                           jobject obj)                                                           jobject obj)
56  {  {
57      gdk_threads_enter ();
58    
59    if (!stringSelectionReceivedID)    if (!stringSelectionReceivedID)
60      {      {
61        jclass gtkclipboard;        jclass gtkclipboard;
# Line 72  Java_gnu_java_awt_peer_gtk_GtkClipboard_ Line 74  Java_gnu_java_awt_peer_gtk_GtkClipboard_
74    
75    cb_obj = (*env)->NewGlobalRef (env, obj);    cb_obj = (*env)->NewGlobalRef (env, obj);
76    
   gdk_threads_enter ();  
77    clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL);    clipboard = gtk_window_new (GTK_WINDOW_TOPLEVEL);
78    
79    g_signal_connect (G_OBJECT(clipboard), "selection_received",    g_signal_connect (G_OBJECT(clipboard), "selection_received",
80                        GTK_SIGNAL_FUNC (selection_received), NULL);                        GTK_SIGNAL_FUNC (selection_received_cb), NULL);
81    
82    g_signal_connect (G_OBJECT(clipboard), "selection_clear_event",    g_signal_connect (G_OBJECT(clipboard), "selection_clear_event",
83                        GTK_SIGNAL_FUNC (selection_clear), NULL);                        GTK_SIGNAL_FUNC (selection_clear_cb), NULL);
84    
85    gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY,    gtk_selection_add_target (clipboard, GDK_SELECTION_PRIMARY,
86                              GDK_TARGET_STRING, 0);                              GDK_TARGET_STRING, 0);
87    
88    g_signal_connect (G_OBJECT(clipboard), "selection_get",    g_signal_connect (G_OBJECT(clipboard), "selection_get",
89                        GTK_SIGNAL_FUNC (selection_get), NULL);                        GTK_SIGNAL_FUNC (selection_get_cb), NULL);
90    
91    gdk_threads_leave ();    gdk_threads_leave ();
92  }  }
# Line 95  Java_gnu_java_awt_peer_gtk_GtkClipboard_ Line 96  Java_gnu_java_awt_peer_gtk_GtkClipboard_
96    (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))    (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
97  {  {
98    gdk_threads_enter ();    gdk_threads_enter ();
99    
100    gtk_selection_convert (clipboard, GDK_SELECTION_PRIMARY,    gtk_selection_convert (clipboard, GDK_SELECTION_PRIMARY,
101                           GDK_TARGET_STRING, GDK_CURRENT_TIME);                           GDK_TARGET_STRING, GDK_CURRENT_TIME);
102    
103    gdk_threads_leave ();    gdk_threads_leave ();
104  }  }
105    
106  void  void
107  selection_received (GtkWidget *widget __attribute__((unused)),  selection_received_cb (GtkWidget *widget __attribute__((unused)),
108                      GtkSelectionData *selection_data __attribute__((unused)),                         GtkSelectionData *selection_data __attribute__((unused)),
109                      guint time __attribute__((unused)),                         guint time __attribute__((unused)),
110                      gpointer data __attribute__((unused)))                         gpointer data __attribute__((unused)))
111  {  {
112    /* Check to see if retrieval succeeded  */    /* Check to see if retrieval succeeded  */
113    if (selection_data->length < 0    if (selection_data->length < 0
114        || selection_data->type != GDK_SELECTION_TYPE_STRING)        || selection_data->type != GDK_SELECTION_TYPE_STRING)
115      {      {
116          gdk_threads_leave ();
117    
118        (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,        (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,
119                                      NULL);                                      NULL);
120    
121          gdk_threads_enter ();
122      }      }
123    else    else
124      {      {
125        char *str = (char *) selection_data->data;        char *str = (char *) selection_data->data;
126                
127          gdk_threads_leave ();
128    
129        (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,        (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, stringSelectionReceivedID,
130                                      (*gdk_env())->NewStringUTF (gdk_env(), str));                                      (*gdk_env())->NewStringUTF (gdk_env(), str));
131    
132          gdk_threads_enter ();
133      }      }
134    
135    return;    return;
136  }  }
137    
138  void  void
139  selection_get (GtkWidget *widget __attribute__((unused)),  selection_get_cb (GtkWidget *widget __attribute__((unused)),
140                 GtkSelectionData *selection_data,                    GtkSelectionData *selection_data,
141                 guint      info __attribute__((unused)),                    guint      info __attribute__((unused)),
142                 guint      time __attribute__((unused)),                    guint      time __attribute__((unused)),
143                 gpointer   data __attribute__((unused)))                    gpointer   data __attribute__((unused)))
144  {  {
145    jstring jstr;    jstring jstr;
146    const char *utf;    const char *utf;
147    jsize utflen;    jsize utflen;
148    
149      gdk_threads_leave ();
150    
151    jstr = (*gdk_env())->CallObjectMethod (gdk_env(), cb_obj,    jstr = (*gdk_env())->CallObjectMethod (gdk_env(), cb_obj,
152                                         stringSelectionHandlerID);                                         stringSelectionHandlerID);
153    
154      gdk_threads_enter ();
155    
156    if (!jstr)    if (!jstr)
157      {      {
158        gtk_selection_data_set (selection_data,        gtk_selection_data_set (selection_data,
# Line 174  Java_gnu_java_awt_peer_gtk_GtkClipboard_ Line 189  Java_gnu_java_awt_peer_gtk_GtkClipboard_
189  }  }
190    
191  gint  gint
192  selection_clear (GtkWidget *widget __attribute__((unused)),  selection_clear_cb (GtkWidget *widget __attribute__((unused)),
193                   GdkEventSelection *event __attribute__((unused)))                      GdkEventSelection *event __attribute__((unused)))
194  {  {
195      gdk_threads_leave ();
196    
197    (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, selectionClearID);    (*gdk_env())->CallVoidMethod (gdk_env(), cb_obj, selectionClearID);
198    
199      gdk_threads_enter ();
200    
201    return TRUE;    return TRUE;
202  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26