# HG changeset patch # User Richard Laager # Date 1124146100 0 # Node ID 17ebda61c6cef2d8561a589c6d2c64eed0dc5b66 # Parent ffc86d9ad8b76e3b266d24e8b5f5f53a1d6ef4a6 [gaim-migrate @ 13463] Revert part of my last commit because I'm dumb. Then, fix the Ctrl-Up and Ctrl-Down that I broke when fixing the clear button. Now both of those (along with everything else I fixed) should work... I hope! committer: Tailor Script diff -r ffc86d9ad8b7 -r 17ebda61c6ce src/gtkconv.c --- a/src/gtkconv.c Mon Aug 15 19:46:32 2005 +0000 +++ b/src/gtkconv.c Mon Aug 15 22:48:20 2005 +0000 @@ -1765,12 +1765,24 @@ gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); } - if (conv->send_history->next && - conv->send_history->next->data) { + if (conv->send_history->next && conv->send_history->next->data) { + GObject *object; GtkTextIter iter; GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); conv->send_history = conv->send_history->next; + + /* Block the signal to prevent application of default formatting. */ + object = g_object_ref(G_OBJECT(gtkconv->entry)); + g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, gtkconv); + /* Clear the formatting. */ + gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); + /* Unblock the signal. */ + g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, gtkconv); + g_object_unref(object); + gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); gtk_imhtml_append_text_with_images( GTK_IMHTML(gtkconv->entry), conv->send_history->data, @@ -1788,12 +1800,24 @@ if (!conv->send_history) break; - if (conv->send_history->prev && - conv->send_history->prev->data) { + if (conv->send_history->prev && conv->send_history->prev->data) { + GObject *object; GtkTextIter iter; GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); conv->send_history = conv->send_history->prev; + + /* Block the signal to prevent application of default formatting. */ + object = g_object_ref(G_OBJECT(gtkconv->entry)); + g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, gtkconv); + /* Clear the formatting. */ + gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); + /* Unblock the signal. */ + g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, + NULL, gtkconv); + g_object_unref(object); + gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); gtk_imhtml_append_text_with_images( GTK_IMHTML(gtkconv->entry), conv->send_history->data, diff -r ffc86d9ad8b7 -r 17ebda61c6ce src/gtkimhtml.c --- a/src/gtkimhtml.c Mon Aug 15 19:46:32 2005 +0000 +++ b/src/gtkimhtml.c Mon Aug 15 22:48:20 2005 +0000 @@ -3835,13 +3835,13 @@ gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - /* Move the selection bounds, so the format functions will know we want to - * manipulate the formatting on the entire buffer. */ + /* Move the selection bounds (to select everything), so the format functions + * will know we want to manipulate the formatting on the entire buffer. */ #if GTK_CHECK_VERSION(2,4,0) - gtk_text_buffer_select_range(imhtml->text_buffer, &end, &end); + gtk_text_buffer_select_range(imhtml->text_buffer, &end, &start); #else gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end); - gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &end); + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &start); #endif gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); @@ -3865,9 +3865,18 @@ object = g_object_ref(G_OBJECT(imhtml)); g_signal_emit(object, signals[CLEAR_FORMAT], 0); - g_object_unref(object); + + /* Remove the selection, placing the cursor at the end. */ +#if GTK_CHECK_VERSION(2,4,0) + gtk_text_buffer_select_range(imhtml->text_buffer, &end, &end); +#else + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end); + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &end); +#endif gtk_widget_grab_focus(GTK_WIDGET(imhtml)); + + g_object_unref(object); } /* @@ -3958,14 +3967,12 @@ gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { if (imhtml->edit.bold) gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); + } } @@ -3992,11 +3999,8 @@ gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - - if (imhtml->edit.bold) + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { + if (imhtml->edit.italic) gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); @@ -4025,11 +4029,8 @@ gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - - if (imhtml->edit.bold) + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { + if (imhtml->edit.underline) gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); @@ -4059,11 +4060,8 @@ gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - - if (imhtml->edit.bold) + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { + if (imhtml->edit.strike) gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); else gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); @@ -4093,10 +4091,7 @@ remove_font_size(imhtml, &start, &end, TRUE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { remove_font_size(imhtml, &start, &end, FALSE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); @@ -4124,10 +4119,7 @@ remove_font_size(imhtml, &start, &end, TRUE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { remove_font_size(imhtml, &start, &end, FALSE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); @@ -4162,10 +4154,7 @@ remove_font_size(imhtml, &start, &end, TRUE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); - } else if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - + } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { remove_font_size(imhtml, &start, &end, FALSE); gtk_text_buffer_apply_tag(imhtml->text_buffer, find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); @@ -4201,10 +4190,7 @@ } else { \ gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, \ gtk_text_buffer_get_mark(imhtml->text_buffer, "insert")); \ - if (imhtml->editable) { \ - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) \ - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); \ -\ + if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { \ remove_func(imhtml, &start, &end, FALSE); \ gtk_text_buffer_apply_tag(imhtml->text_buffer, \ find_func(imhtml, \ @@ -4271,10 +4257,7 @@ g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); - if (imhtml->editable) { - if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) - gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); - + if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { remove_font_link(imhtml, &start, &end, FALSE); gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); }