Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 29018:1929b7a0c2c8
merged with im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 25 Nov 2009 13:40:01 +0900 |
parents | 3e5a37c743df ed0c4defd3dd |
children | 39bc284215ce |
comparison
equal
deleted
inserted
replaced
28977:2ecd4bc80500 | 29018:1929b7a0c2c8 |
---|---|
472 gdk_color_parse(styles[i].def, &defcolor); | 472 gdk_color_parse(styles[i].def, &defcolor); |
473 g_object_set(tag, "foreground-gdk", &defcolor, NULL); | 473 g_object_set(tag, "foreground-gdk", &defcolor, NULL); |
474 } | 474 } |
475 } | 475 } |
476 parent_style_set(widget, prev_style); | 476 parent_style_set(widget, prev_style); |
477 } | |
478 | |
479 static gboolean | |
480 imhtml_get_iter_bounds(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) | |
481 { | |
482 if (imhtml->wbfo) { | |
483 gtk_text_buffer_get_bounds(imhtml->text_buffer, start, end); | |
484 return TRUE; | |
485 } else if (imhtml->editable) { | |
486 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, start, end)) { | |
487 GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); | |
488 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, start, mark); | |
489 *end = *start; | |
490 } | |
491 return TRUE; | |
492 } | |
493 | |
494 return FALSE; | |
477 } | 495 } |
478 | 496 |
479 static void | 497 static void |
480 gtk_imhtml_set_link_color(GtkIMHtml *imhtml, GtkTextTag *tag) | 498 gtk_imhtml_set_link_color(GtkIMHtml *imhtml, GtkTextTag *tag) |
481 { | 499 { |
2417 { | 2435 { |
2418 GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); | 2436 GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); |
2419 return proto ? proto->length : 0; | 2437 return proto ? proto->length : 0; |
2420 } | 2438 } |
2421 | 2439 |
2440 static gboolean smooth_scroll_cb(gpointer data); | |
2441 | |
2422 /* | 2442 /* |
2423 <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming | 2443 <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
2424 | 2444 |
2425 | 2445 |
2426 [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | 2446 [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) |
2471 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | 2491 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
2472 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); | 2492 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
2473 | 2493 |
2474 if (((y + height) - (rect.y + rect.height)) > height && | 2494 if (((y + height) - (rect.y + rect.height)) > height && |
2475 gtk_text_buffer_get_char_count(imhtml->text_buffer)) { | 2495 gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
2476 options |= GTK_IMHTML_NO_SCROLL; | 2496 /* If we are in the middle of smooth-scrolling, then take a scroll step. |
2497 * If we are not in the middle of smooth-scrolling, that means we were | |
2498 * not looking at the end of the buffer before the new text was added, | |
2499 * so do not scroll. */ | |
2500 if (imhtml->scroll_time) | |
2501 smooth_scroll_cb(imhtml); | |
2502 else | |
2503 options |= GTK_IMHTML_NO_SCROLL; | |
2477 } | 2504 } |
2478 } | 2505 } |
2479 | 2506 |
2480 gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | 2507 gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); |
2481 | 2508 |
2500 /* | 2527 /* |
2501 * Smoothly scroll a GtkIMHtml. | 2528 * Smoothly scroll a GtkIMHtml. |
2502 * | 2529 * |
2503 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | 2530 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. |
2504 */ | 2531 */ |
2505 static gboolean scroll_cb(gpointer data) | 2532 static gboolean smooth_scroll_cb(gpointer data) |
2506 { | 2533 { |
2507 GtkIMHtml *imhtml = data; | 2534 GtkIMHtml *imhtml = data; |
2508 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | 2535 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; |
2509 gdouble max_val = adj->upper - adj->page_size; | 2536 gdouble max_val = adj->upper - adj->page_size; |
2510 gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); | 2537 gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
2514 if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { | 2541 if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
2515 /* time's up. jump to the end and kill the timer */ | 2542 /* time's up. jump to the end and kill the timer */ |
2516 gtk_adjustment_set_value(adj, max_val); | 2543 gtk_adjustment_set_value(adj, max_val); |
2517 g_timer_destroy(imhtml->scroll_time); | 2544 g_timer_destroy(imhtml->scroll_time); |
2518 imhtml->scroll_time = NULL; | 2545 imhtml->scroll_time = NULL; |
2546 g_source_remove(imhtml->scroll_src); | |
2547 imhtml->scroll_src = 0; | |
2519 return FALSE; | 2548 return FALSE; |
2520 } | 2549 } |
2521 | 2550 |
2522 /* scroll by 1/3rd the remaining distance */ | 2551 /* scroll by 1/3rd the remaining distance */ |
2523 gtk_adjustment_set_value(adj, scroll_val); | 2552 gtk_adjustment_set_value(adj, scroll_val); |
2524 return TRUE; | 2553 return TRUE; |
2525 } | |
2526 | |
2527 static gboolean smooth_scroll_idle_cb(gpointer data) | |
2528 { | |
2529 GtkIMHtml *imhtml = data; | |
2530 imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); | |
2531 return FALSE; | |
2532 } | 2554 } |
2533 | 2555 |
2534 static gboolean scroll_idle_cb(gpointer data) | 2556 static gboolean scroll_idle_cb(gpointer data) |
2535 { | 2557 { |
2536 GtkIMHtml *imhtml = data; | 2558 GtkIMHtml *imhtml = data; |
2548 g_timer_destroy(imhtml->scroll_time); | 2570 g_timer_destroy(imhtml->scroll_time); |
2549 if (imhtml->scroll_src) | 2571 if (imhtml->scroll_src) |
2550 g_source_remove(imhtml->scroll_src); | 2572 g_source_remove(imhtml->scroll_src); |
2551 if(smooth) { | 2573 if(smooth) { |
2552 imhtml->scroll_time = g_timer_new(); | 2574 imhtml->scroll_time = g_timer_new(); |
2553 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, smooth_scroll_idle_cb, imhtml, NULL); | 2575 imhtml->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, imhtml, NULL); |
2554 } else { | 2576 } else { |
2555 imhtml->scroll_time = NULL; | 2577 imhtml->scroll_time = NULL; |
2556 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | 2578 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); |
2557 } | 2579 } |
2558 } | 2580 } |
4317 GtkTextIter start, end; | 4339 GtkTextIter start, end; |
4318 | 4340 |
4319 if (!imhtml->editable) | 4341 if (!imhtml->editable) |
4320 return; | 4342 return; |
4321 | 4343 |
4322 if (imhtml->wbfo) | 4344 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4323 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4345 return; |
4324 else | |
4325 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) | |
4326 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
4327 | 4346 |
4328 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | 4347 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
4329 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | 4348 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
4330 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | 4349 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
4331 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | 4350 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
4664 { | 4683 { |
4665 GtkTextIter start, end; | 4684 GtkTextIter start, end; |
4666 | 4685 |
4667 imhtml->edit.bold = !imhtml->edit.bold; | 4686 imhtml->edit.bold = !imhtml->edit.bold; |
4668 | 4687 |
4669 if (imhtml->wbfo) { | 4688 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4670 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4689 return; |
4671 if (imhtml->edit.bold) | 4690 |
4672 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | 4691 if (imhtml->edit.bold) |
4673 else | 4692 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
4674 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | 4693 else |
4675 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | 4694 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
4676 if (imhtml->edit.bold) | |
4677 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
4678 else | |
4679 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
4680 | |
4681 } | |
4682 } | 4695 } |
4683 | 4696 |
4684 void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) | 4697 void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
4685 { | 4698 { |
4686 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); | 4699 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
4690 { | 4703 { |
4691 GtkTextIter start, end; | 4704 GtkTextIter start, end; |
4692 | 4705 |
4693 imhtml->edit.italic = !imhtml->edit.italic; | 4706 imhtml->edit.italic = !imhtml->edit.italic; |
4694 | 4707 |
4695 if (imhtml->wbfo) { | 4708 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4696 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4709 return; |
4697 if (imhtml->edit.italic) | 4710 |
4698 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | 4711 if (imhtml->edit.italic) |
4699 else | 4712 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
4700 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | 4713 else |
4701 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | 4714 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
4702 if (imhtml->edit.italic) | |
4703 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
4704 else | |
4705 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
4706 } | |
4707 } | 4715 } |
4708 | 4716 |
4709 void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) | 4717 void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
4710 { | 4718 { |
4711 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); | 4719 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
4715 { | 4723 { |
4716 GtkTextIter start, end; | 4724 GtkTextIter start, end; |
4717 | 4725 |
4718 imhtml->edit.underline = !imhtml->edit.underline; | 4726 imhtml->edit.underline = !imhtml->edit.underline; |
4719 | 4727 |
4720 if (imhtml->wbfo) { | 4728 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4721 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4729 return; |
4722 if (imhtml->edit.underline) | 4730 |
4723 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | 4731 if (imhtml->edit.underline) |
4724 else | 4732 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
4725 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | 4733 else |
4726 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | 4734 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
4727 if (imhtml->edit.underline) | |
4728 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
4729 else | |
4730 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
4731 } | |
4732 } | 4735 } |
4733 | 4736 |
4734 void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) | 4737 void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
4735 { | 4738 { |
4736 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); | 4739 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
4740 { | 4743 { |
4741 GtkTextIter start, end; | 4744 GtkTextIter start, end; |
4742 | 4745 |
4743 imhtml->edit.strike = !imhtml->edit.strike; | 4746 imhtml->edit.strike = !imhtml->edit.strike; |
4744 | 4747 |
4745 if (imhtml->wbfo) { | 4748 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4746 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4749 return; |
4747 if (imhtml->edit.strike) | 4750 |
4748 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | 4751 if (imhtml->edit.strike) |
4749 else | 4752 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
4750 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | 4753 else |
4751 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | 4754 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
4752 if (imhtml->edit.strike) | |
4753 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
4754 else | |
4755 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
4756 } | |
4757 } | 4755 } |
4758 | 4756 |
4759 void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) | 4757 void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
4760 { | 4758 { |
4761 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); | 4759 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
4766 GObject *object; | 4764 GObject *object; |
4767 GtkTextIter start, end; | 4765 GtkTextIter start, end; |
4768 | 4766 |
4769 imhtml->edit.fontsize = size; | 4767 imhtml->edit.fontsize = size; |
4770 | 4768 |
4771 if (imhtml->wbfo) { | 4769 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4772 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4770 return; |
4773 remove_font_size(imhtml, &start, &end, TRUE); | 4771 |
4774 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 4772 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
4775 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | 4773 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
4776 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | 4774 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
4777 remove_font_size(imhtml, &start, &end, FALSE); | |
4778 gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
4779 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
4780 } | |
4781 | 4775 |
4782 object = g_object_ref(G_OBJECT(imhtml)); | 4776 object = g_object_ref(G_OBJECT(imhtml)); |
4783 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); | 4777 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
4784 g_object_unref(object); | 4778 g_object_unref(object); |
4785 } | 4779 } |
4794 if (!imhtml->edit.fontsize) | 4788 if (!imhtml->edit.fontsize) |
4795 imhtml->edit.fontsize = 2; | 4789 imhtml->edit.fontsize = 2; |
4796 else | 4790 else |
4797 imhtml->edit.fontsize--; | 4791 imhtml->edit.fontsize--; |
4798 | 4792 |
4799 if (imhtml->wbfo) { | 4793 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4800 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4794 return; |
4801 remove_font_size(imhtml, &start, &end, TRUE); | 4795 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
4802 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 4796 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
4803 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | 4797 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
4804 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | |
4805 remove_font_size(imhtml, &start, &end, FALSE); | |
4806 gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
4807 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
4808 } | |
4809 } | 4798 } |
4810 | 4799 |
4811 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) | 4800 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
4812 { | 4801 { |
4813 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); | 4802 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
4823 if (!imhtml->edit.fontsize) | 4812 if (!imhtml->edit.fontsize) |
4824 imhtml->edit.fontsize = 4; | 4813 imhtml->edit.fontsize = 4; |
4825 else | 4814 else |
4826 imhtml->edit.fontsize++; | 4815 imhtml->edit.fontsize++; |
4827 | 4816 |
4828 if (imhtml->wbfo) { | 4817 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
4829 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | 4818 return; |
4830 remove_font_size(imhtml, &start, &end, TRUE); | 4819 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
4831 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 4820 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
4832 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | 4821 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
4833 } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | |
4834 remove_font_size(imhtml, &start, &end, FALSE); | |
4835 gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
4836 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
4837 } | |
4838 } | 4822 } |
4839 | 4823 |
4840 void gtk_imhtml_font_grow(GtkIMHtml *imhtml) | 4824 void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
4841 { | 4825 { |
4842 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); | 4826 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
4855 | 4839 |
4856 if (value && strcmp(value, "") != 0) | 4840 if (value && strcmp(value, "") != 0) |
4857 { | 4841 { |
4858 *edit_field = g_strdup(value); | 4842 *edit_field = g_strdup(value); |
4859 | 4843 |
4860 if (imhtml->wbfo) | 4844 if (imhtml_get_iter_bounds(imhtml, &start, &end)) { |
4861 { | 4845 remove_func(imhtml, &start, &end, imhtml->wbfo); |
4862 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
4863 remove_func(imhtml, &start, &end, TRUE); | |
4864 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 4846 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
4865 find_func(imhtml, *edit_field), &start, &end); | 4847 find_func(imhtml, *edit_field), &start, &end); |
4866 } | |
4867 else | |
4868 { | |
4869 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, | |
4870 gtk_text_buffer_get_mark(imhtml->text_buffer, "insert")); | |
4871 if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) | |
4872 { | |
4873 remove_func(imhtml, &start, &end, FALSE); | |
4874 gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
4875 find_func(imhtml, | |
4876 *edit_field), | |
4877 &start, &end); | |
4878 } | |
4879 } | 4848 } |
4880 } | 4849 } |
4881 else | 4850 else |
4882 { | 4851 { |
4883 if (imhtml->wbfo) | 4852 if (imhtml_get_iter_bounds(imhtml, &start, &end)) |
4884 { | 4853 remove_func(imhtml, &start, &end, TRUE); /* 'TRUE' or 'imhtml->wbfo'? */ |
4885 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
4886 remove_func(imhtml, &start, &end, TRUE); | |
4887 } | |
4888 else | |
4889 { | |
4890 if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) | |
4891 remove_func(imhtml, &start, &end, TRUE); | |
4892 } | |
4893 } | 4854 } |
4894 | 4855 |
4895 object = g_object_ref(G_OBJECT(imhtml)); | 4856 object = g_object_ref(G_OBJECT(imhtml)); |
4896 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); | 4857 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
4897 g_object_unref(object); | 4858 g_object_unref(object); |