| 266 static void |
266 static void |
| 267 entry_changed_cb(GtkTextBuffer *buffer, void *data) |
267 entry_changed_cb(GtkTextBuffer *buffer, void *data) |
| 268 { |
268 { |
| 269 GtkTextIter start, end; |
269 GtkTextIter start, end; |
| 270 char *xmlstr, *str; |
270 char *xmlstr, *str; |
| 271 #if 0 |
271 GtkTextIter iter; |
| 272 int wrapped_lines; |
272 int wrapped_lines; |
| 273 int lines; |
273 int lines; |
| 274 GdkRectangle oneline; |
274 GdkRectangle oneline; |
| 275 int height; |
275 int height; |
| 276 int pad_top, pad_inside, pad_bottom; |
276 int pad_top, pad_inside, pad_bottom; |
| 277 #endif |
|
| 278 PurpleXmlNode *node; |
277 PurpleXmlNode *node; |
| 279 GtkStyleContext *style; |
278 GtkStyleContext *style; |
| 280 |
279 |
| 281 #if 0 |
|
| 282 /* TODO WebKit: Do entry auto-sizing... */ |
|
| 283 wrapped_lines = 1; |
280 wrapped_lines = 1; |
| 284 gtk_text_buffer_get_start_iter(buffer, &iter); |
281 gtk_text_buffer_get_start_iter(buffer, &iter); |
| 285 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); |
282 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); |
| 286 while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) |
283 while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), |
| |
284 &iter)) { |
| 287 wrapped_lines++; |
285 wrapped_lines++; |
| |
286 } |
| 288 |
287 |
| 289 lines = gtk_text_buffer_get_line_count(buffer); |
288 lines = gtk_text_buffer_get_line_count(buffer); |
| 290 |
289 |
| 291 /* Show a maximum of 64 lines */ |
290 /* Show a maximum of 64 lines */ |
| 292 lines = MIN(lines, 6); |
291 lines = MIN(lines, 6); |
| 298 |
297 |
| 299 height = (oneline.height + pad_top + pad_bottom) * lines; |
298 height = (oneline.height + pad_top + pad_bottom) * lines; |
| 300 height += (oneline.height + pad_inside) * (wrapped_lines - lines); |
299 height += (oneline.height + pad_inside) * (wrapped_lines - lines); |
| 301 |
300 |
| 302 gtk_widget_set_size_request(console->sw, -1, height + 6); |
301 gtk_widget_set_size_request(console->sw, -1, height + 6); |
| 303 #endif |
|
| 304 |
302 |
| 305 gtk_text_buffer_get_bounds(buffer, &start, &end); |
303 gtk_text_buffer_get_bounds(buffer, &start, &end); |
| 306 str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); |
304 str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); |
| 307 if (!str) |
305 if (!str) { |
| 308 return; |
306 return; |
| |
307 } |
| |
308 |
| 309 xmlstr = g_strdup_printf("<xml>%s</xml>", str); |
309 xmlstr = g_strdup_printf("<xml>%s</xml>", str); |
| 310 node = purple_xmlnode_from_str(xmlstr, -1); |
310 node = purple_xmlnode_from_str(xmlstr, -1); |
| 311 style = gtk_widget_get_style_context(console->entry); |
311 style = gtk_widget_get_style_context(console->entry); |
| 312 if (node) { |
312 if (node) { |
| 313 gtk_style_context_remove_class(style, GTK_STYLE_CLASS_ERROR); |
313 gtk_style_context_remove_class(style, GTK_STYLE_CLASS_ERROR); |