148 |
|
|
149 |
gdk_threads_leave (); |
gdk_threads_leave (); |
150 |
} |
} |
151 |
|
|
152 |
|
JNIEXPORT void JNICALL |
153 |
|
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkSetFont |
154 |
|
(JNIEnv *env, jobject obj, jstring jname, jint size) |
155 |
|
{ |
156 |
|
const char *xlfd; |
157 |
|
# define FBUFSZ 200 |
158 |
|
char buf[FBUFSZ]; |
159 |
|
void *ptr; |
160 |
|
GdkFont * new_font; |
161 |
|
GtkStyle * style; |
162 |
|
GtkWidget * text; |
163 |
|
|
164 |
|
ptr = NSA_GET_PTR (env, obj); |
165 |
|
text = GTK_WIDGET (ptr); |
166 |
|
|
167 |
|
xlfd = (*env)->GetStringUTFChars (env, jname, NULL); |
168 |
|
snprintf(buf, FBUFSZ, xlfd, size); |
169 |
|
(*env)->ReleaseStringUTFChars (env, jname, xlfd); |
170 |
|
gdk_threads_enter(); |
171 |
|
new_font = gdk_font_load(buf); /* FIXME: deprecated. Replacement? */ |
172 |
|
if (new_font == NULL) |
173 |
|
{ |
174 |
|
/* Fail quietly for now. */ |
175 |
|
gdk_threads_leave(); |
176 |
|
return; |
177 |
|
} |
178 |
|
style = gtk_style_copy (gtk_widget_get_style (text)); |
179 |
|
style -> font = new_font; |
180 |
|
gtk_widget_set_style (text , style); |
181 |
|
/* FIXME: Documentation varies as to whether we should unref style. */ |
182 |
|
gdk_threads_leave(); |
183 |
|
} |