Mercurial > pidgin.yaz
comparison src/gtkimhtml.c @ 6066:c99959f1bb73
[gaim-migrate @ 6516]
Re-add javabsp's F2 patch. I didn't feel like taking it out of my CVS
again, and I think he'll be able to get it working without the weird
highlight behavior.
Also fixed the ctlr+a/ctrl+pgup/ctrl+pgdown thing in gtkimhtml rather
than gtkconv.c. So now it applies to info windows and other stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 09 Jul 2003 00:33:06 +0000 |
parents | 395116fdd270 |
children | 16fd7811effd |
comparison
equal
deleted
inserted
replaced
6065:3a40666c08b4 | 6066:c99959f1bb73 |
---|---|
296 GTK_IMHTML(imhtml)->tip_timer = 0; | 296 GTK_IMHTML(imhtml)->tip_timer = 0; |
297 } | 297 } |
298 gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->arrow_cursor); | 298 gdk_window_set_cursor(event->window, GTK_IMHTML(imhtml)->arrow_cursor); |
299 | 299 |
300 /* propogate the event normally */ | 300 /* propogate the event normally */ |
301 return FALSE; | |
302 } | |
303 | |
304 /* | |
305 * XXX - This should be removed eventually. | |
306 * | |
307 * This function exists to work around a gross bug in GtkTextView. | |
308 * Basically, we short circuit ctrl+a and ctrl+end because they make | |
309 * el program go boom. | |
310 * | |
311 * It's supposed to be fixed in gtk2.2. You can view the bug report at | |
312 * http://bugzilla.gnome.org/show_bug.cgi?id=107939 | |
313 */ | |
314 gboolean gtk_key_pressed_cb(GtkWidget *imhtml, GdkEventKey *event, gpointer data) | |
315 { | |
316 if (event->state & GDK_CONTROL_MASK) | |
317 switch (event->keyval) { | |
318 case 'a': | |
319 return TRUE; | |
320 break; | |
321 | |
322 case GDK_Home: | |
323 return TRUE; | |
324 break; | |
325 | |
326 case GDK_End: | |
327 return TRUE; | |
328 break; | |
329 } | |
330 | |
301 return FALSE; | 331 return FALSE; |
302 } | 332 } |
303 | 333 |
304 | 334 |
305 | 335 |
383 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ | 413 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
384 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | 414 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); |
385 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | 415 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
386 | 416 |
387 imhtml->show_smileys = TRUE; | 417 imhtml->show_smileys = TRUE; |
388 imhtml->show_comments = TRUE; | |
389 | 418 |
390 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, | 419 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
391 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); | 420 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
392 imhtml->default_smilies = gtk_smiley_tree_new(); | 421 imhtml->default_smilies = gtk_smiley_tree_new(); |
393 | 422 |
394 g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); | 423 g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); |
395 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); | 424 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); |
396 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); | 425 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); |
426 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); | |
397 gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK); | 427 gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK); |
398 | 428 |
399 imhtml->tip = NULL; | 429 imhtml->tip = NULL; |
400 imhtml->tip_timer = 0; | 430 imhtml->tip_timer = 0; |
401 imhtml->tip_window = NULL; | 431 imhtml->tip_window = NULL; |
402 | 432 |
403 imhtml->scalables = NULL; | 433 imhtml->scalables = NULL; |
434 | |
435 gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "invisible", FALSE, NULL); | |
404 } | 436 } |
405 | 437 |
406 GtkWidget *gtk_imhtml_new(void *a, void *b) | 438 GtkWidget *gtk_imhtml_new(void *a, void *b) |
407 { | 439 { |
408 return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); | 440 return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
959 scalable->add_to(scalable, imhtml, &iter); \ | 991 scalable->add_to(scalable, imhtml, &iter); \ |
960 scalable->scale(scalable, rect.width, rect.height); \ | 992 scalable->scale(scalable, rect.width, rect.height); \ |
961 imhtml->scalables = g_list_append(imhtml->scalables, scalable); \ | 993 imhtml->scalables = g_list_append(imhtml->scalables, scalable); \ |
962 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ | 994 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ |
963 } \ | 995 } \ |
996 if (x == NEW_COMMENT_BIT) { \ | |
997 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "comment", &siter, &iter); \ | |
998 } \ | |
964 | 999 |
965 | 1000 |
966 | 1001 |
967 GString* gtk_imhtml_append_text (GtkIMHtml *imhtml, | 1002 GString* gtk_imhtml_append_text (GtkIMHtml *imhtml, |
968 const gchar *text, | 1003 const gchar *text, |
1315 case 56: /* SPAN */ | 1350 case 56: /* SPAN */ |
1316 case 57: /* /SPAN */ | 1351 case 57: /* /SPAN */ |
1317 break; | 1352 break; |
1318 case 59: /* comment */ | 1353 case 59: /* comment */ |
1319 NEW_BIT (NEW_TEXT_BIT); | 1354 NEW_BIT (NEW_TEXT_BIT); |
1320 if (imhtml->show_comments) | 1355 wpos = g_snprintf (ws, len, "%s", tag); |
1321 wpos = g_snprintf (ws, len, "%s", tag); | |
1322 NEW_BIT (NEW_COMMENT_BIT); | 1356 NEW_BIT (NEW_COMMENT_BIT); |
1323 break; | 1357 break; |
1324 default: | 1358 default: |
1325 break; | 1359 break; |
1326 } | 1360 } |
1444 } | 1478 } |
1445 | 1479 |
1446 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, | 1480 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
1447 gboolean show) | 1481 gboolean show) |
1448 { | 1482 { |
1449 imhtml->show_comments = show; | 1483 GtkTextIter iter; |
1484 GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); | |
1485 GtkTextTag *tag = gtk_text_tag_table_lookup(table, "comment"); | |
1486 g_object_set(G_OBJECT(tag), "invisible", !show, NULL); | |
1487 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
1488 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); | |
1489 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &iter); | |
1490 | |
1450 } | 1491 } |
1451 | 1492 |
1452 void | 1493 void |
1453 gtk_imhtml_clear (GtkIMHtml *imhtml) | 1494 gtk_imhtml_clear (GtkIMHtml *imhtml) |
1454 { | 1495 { |