comparison src/gtkimhtml.c @ 12796:e8db8f94a2db

[gaim-migrate @ 15143] (The Last) Part of SF Patch #1400162 from Sadrul "Do not change the format when the imhtml is not editable. Also, reset the formatting for the whole buffer when the imhtml has whole-buffer formatting on, or the selected text otherwise." Plus a change from me: If no text is selected, clear the formatting on the whole buffer. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 09 Jan 2006 16:04:04 +0000
parents de93d4988ad4
children cb2d493e1925
comparison
equal deleted inserted replaced
12795:ca1144227826 12796:e8db8f94a2db
3726 static void 3726 static void
3727 imhtml_clear_formatting(GtkIMHtml *imhtml) 3727 imhtml_clear_formatting(GtkIMHtml *imhtml)
3728 { 3728 {
3729 GtkTextIter start, end; 3729 GtkTextIter start, end;
3730 3730
3731 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); 3731 if (!imhtml->editable)
3732 3732 return;
3733 /* Move the selection bounds (to select everything), so the format functions 3733
3734 * will know we want to manipulate the formatting on the entire buffer. */ 3734 if (imhtml->wbfo)
3735 #if GTK_CHECK_VERSION(2,4,0) 3735 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
3736 gtk_text_buffer_select_range(imhtml->text_buffer, &end, &start); 3736 else
3737 #else 3737 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end))
3738 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end); 3738 gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
3739 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &start);
3740 #endif
3741 3739
3742 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); 3740 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
3743 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); 3741 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
3744 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); 3742 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end);
3745 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); 3743 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end);
3756 imhtml->edit.strike = 0; 3754 imhtml->edit.strike = 0;
3757 imhtml->edit.fontsize = 0; 3755 imhtml->edit.fontsize = 0;
3758 imhtml->edit.forecolor = NULL; 3756 imhtml->edit.forecolor = NULL;
3759 imhtml->edit.backcolor = NULL; 3757 imhtml->edit.backcolor = NULL;
3760 imhtml->edit.background = NULL; 3758 imhtml->edit.background = NULL;
3761
3762 /* Remove the selection, placing the cursor at the end. */
3763 #if GTK_CHECK_VERSION(2,4,0)
3764 gtk_text_buffer_select_range(imhtml->text_buffer, &end, &end);
3765 #else
3766 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end);
3767 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &end);
3768 #endif
3769 } 3759 }
3770 3760
3771 /* Editable stuff */ 3761 /* Editable stuff */
3772 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) 3762 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml)
3773 { 3763 {