Mercurial > pidgin
comparison src/gtkimhtml.c @ 10777:ffa44a5159e0
[gaim-migrate @ 12392]
To test Tim's new code, I needed a way to set background colors, so I changed
gtkimhtmltoolbar such that now it will set the body background color unless
text is selected in which case it will set the font background color on that
text only. That seems sensible.
Then I tested Tim's new code and it went into an infinite loop. Twice ;).
Maybe I'll have time to check that out later.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 03 Apr 2005 03:51:59 +0000 |
parents | b640d066eb51 |
children | 93fd90cbf45c |
comparison
equal
deleted
inserted
replaced
10776:b640d066eb51 | 10777:ffa44a5159e0 |
---|---|
529 { | 529 { |
530 GtkTextIter start, end, cur; | 530 GtkTextIter start, end, cur; |
531 int buf_x, buf_y; | 531 int buf_x, buf_y; |
532 GSList *tags, *l; | 532 GSList *tags, *l; |
533 GdkRectangle visible_rect; | 533 GdkRectangle visible_rect; |
534 | 534 GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window)); |
535 GdkColor gcolor; | |
536 | |
535 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); | 537 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
536 gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | 538 gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), |
537 GTK_TEXT_WINDOW_TEXT, | 539 GTK_TEXT_WINDOW_TEXT, |
538 visible_rect.x, | 540 visible_rect.x, |
539 visible_rect.y, | 541 visible_rect.y, |
541 &visible_rect.y); | 543 &visible_rect.y); |
542 | 544 |
543 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | 545 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, |
544 event->area.x, event->area.y, &buf_x, &buf_y); | 546 event->area.x, event->area.y, &buf_x, &buf_y); |
545 | 547 |
548 if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { | |
549 | |
550 if (GTK_IMHTML(widget)->edit.background) { | |
551 gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); | |
552 gdk_gc_set_rgb_fg_color(gc, &gcolor); | |
553 } else { | |
554 gdk_gc_set_rgb_fg_color(gc, &(widget->style->base[GTK_WIDGET_STATE(widget)])); | |
555 } | |
556 | |
557 gdk_draw_rectangle(event->window, | |
558 gc, | |
559 TRUE, | |
560 visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height); | |
561 gdk_gc_unref(gc); | |
562 | |
563 if (GTK_WIDGET_CLASS (parent_class)->expose_event) | |
564 return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
565 (widget, event); | |
566 | |
567 return FALSE; | |
568 | |
569 } | |
570 | |
546 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); | 571 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
547 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | 572 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, |
548 buf_x + event->area.width, buf_y + event->area.height); | 573 buf_x + event->area.width, buf_y + event->area.height); |
549 | 574 |
550 | 575 |
551 | 576 |
552 cur = start; | 577 cur = start; |
553 | 578 |
554 while (gtk_text_iter_in_range(&cur, &start, &end)) { | 579 while (gtk_text_iter_in_range(&cur, &start, &end)) { |
555 GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window)); | |
556 tags = gtk_text_iter_get_tags(&cur); | 580 tags = gtk_text_iter_get_tags(&cur); |
557 | 581 |
558 for (l = tags; l; l = l->next) { | 582 for (l = tags; l; l = l->next) { |
559 GtkTextTag *tag = l->data; | 583 GtkTextTag *tag = l->data; |
560 GdkRectangle rect; | 584 GdkRectangle rect; |
561 GdkRectangle tag_area; | 585 GdkRectangle tag_area; |
562 const char *color; | 586 const char *color; |
563 GdkColor gcolor; | 587 |
564 | |
565 if (strncmp(tag->name, "BACKGROUND ", 11)) | 588 if (strncmp(tag->name, "BACKGROUND ", 11)) |
566 continue; | 589 continue; |
567 | 590 |
568 if (gtk_text_iter_ends_tag(&cur, tag)) | 591 if (gtk_text_iter_ends_tag(&cur, tag)) |
569 continue; | 592 continue; |
610 gtk_text_iter_backward_char(&cur); | 633 gtk_text_iter_backward_char(&cur); |
611 break; | 634 break; |
612 } | 635 } |
613 | 636 |
614 g_slist_free(tags); | 637 g_slist_free(tags); |
615 gdk_gc_unref(gc); | |
616 gtk_text_iter_forward_to_tag_toggle(&cur, NULL); | 638 gtk_text_iter_forward_to_tag_toggle(&cur, NULL); |
617 } | 639 } |
618 #if 0 | 640 #if 0 |
619 while (l) { | 641 while (l) { |
620 struct backcolor_tag *tag = (struct backcolor_tag*)l->data; | 642 struct backcolor_tag *tag = (struct backcolor_tag*)l->data; |
682 redraw_rect.x, win_top, redraw_rect.width, win_bottom - win_top); | 704 redraw_rect.x, win_top, redraw_rect.width, win_bottom - win_top); |
683 gdk_gc_unref(gc); | 705 gdk_gc_unref(gc); |
684 l = l->next; | 706 l = l->next; |
685 } | 707 } |
686 #endif | 708 #endif |
709 gdk_gc_unref(gc); | |
710 | |
687 if (GTK_WIDGET_CLASS (parent_class)->expose_event) | 711 if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
688 return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | 712 return (* GTK_WIDGET_CLASS (parent_class)->expose_event) |
689 (widget, event); | 713 (widget, event); |
690 | 714 |
691 return FALSE; | 715 return FALSE; |