Mercurial > pidgin
comparison src/gtkimhtml.c @ 10169:a0529cf29ad4
[gaim-migrate @ 11258]
Applying to HEAD.
This should fix bug number 1057811, where typing right before a previously
inserted smiley would lose the formatting. Since smileys aren't text,
the tags weren't getting applied to them (they're child anchors, btw) so
typing right before them picked up this lack of formatting.
So I fixed it by applying tags to child anchors like we do normal text.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Thu, 11 Nov 2004 02:26:44 +0000 |
parents | 5c3b27763126 |
children | f6918ab1624a |
comparison
equal
deleted
inserted
replaced
10168:e6372844a4b8 | 10169:a0529cf29ad4 |
---|---|
80 gint y, | 80 gint y, |
81 guint time); | 81 guint time); |
82 | 82 |
83 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); | 83 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
84 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); | 84 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
85 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); | |
86 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
85 static gboolean gtk_imhtml_is_amp_escape (const gchar *string, gchar **replace, gint *length); | 87 static gboolean gtk_imhtml_is_amp_escape (const gchar *string, gchar **replace, gint *length); |
86 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); | 88 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
87 static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); | 89 static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
88 static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml); | 90 static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml); |
89 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); | 91 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
1073 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); | 1075 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); |
1074 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); | 1076 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); |
1075 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); | 1077 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
1076 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); | 1078 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); |
1077 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); | 1079 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
1080 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); | |
1078 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, | 1081 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
1079 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | 1082 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), |
1080 GDK_ACTION_COPY); | 1083 GDK_ACTION_COPY); |
1081 g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | 1084 g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); |
1082 g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); | 1085 g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
3247 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | 3250 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) |
3248 { | 3251 { |
3249 imhtml->insert_offset = gtk_text_iter_get_offset(iter); | 3252 imhtml->insert_offset = gtk_text_iter_get_offset(iter); |
3250 } | 3253 } |
3251 | 3254 |
3255 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) | |
3256 { | |
3257 GtkTextIter start; | |
3258 | |
3259 start = *arg1; | |
3260 gtk_text_iter_backward_char(&start); | |
3261 | |
3262 gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
3263 } | |
3264 | |
3252 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) | 3265 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
3253 { | 3266 { |
3254 GtkTextIter start; | 3267 GtkTextIter start; |
3255 | 3268 |
3256 if (!len) | 3269 if (!len) |
3257 return; | 3270 return; |
3258 | 3271 |
3259 start = *end; | 3272 start = *end; |
3260 gtk_text_iter_set_offset(&start, imhtml->insert_offset); | 3273 gtk_text_iter_set_offset(&start, imhtml->insert_offset); |
3261 | 3274 |
3275 gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); | |
3276 } | |
3277 | |
3278 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) | |
3279 { | |
3262 if (imhtml->edit.bold) | 3280 if (imhtml->edit.bold) |
3263 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, end); | 3281 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
3264 else | 3282 else |
3265 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, end); | 3283 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
3266 | 3284 |
3267 if (imhtml->edit.italic) | 3285 if (imhtml->edit.italic) |
3268 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, end); | 3286 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
3269 else | 3287 else |
3270 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, end); | 3288 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
3271 | 3289 |
3272 if (imhtml->edit.underline) | 3290 if (imhtml->edit.underline) |
3273 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, end); | 3291 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
3274 else | 3292 else |
3275 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, end); | 3293 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
3276 | 3294 |
3277 if (imhtml->edit.strike) | 3295 if (imhtml->edit.strike) |
3278 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, end); | 3296 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
3279 else | 3297 else |
3280 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, end); | 3298 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
3281 | 3299 |
3282 if (imhtml->edit.forecolor) { | 3300 if (imhtml->edit.forecolor) { |
3283 remove_font_forecolor(imhtml, &start, end, TRUE); | 3301 remove_font_forecolor(imhtml, start, end, TRUE); |
3284 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 3302 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
3285 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | 3303 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), |
3286 &start, end); | 3304 start, end); |
3287 } | 3305 } |
3288 | 3306 |
3289 if (imhtml->edit.backcolor) { | 3307 if (imhtml->edit.backcolor) { |
3290 remove_font_backcolor(imhtml, &start, end, TRUE); | 3308 remove_font_backcolor(imhtml, start, end, TRUE); |
3291 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 3309 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
3292 find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | 3310 find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), |
3293 &start, end); | 3311 start, end); |
3294 } | 3312 } |
3295 | 3313 |
3296 if (imhtml->edit.fontface) { | 3314 if (imhtml->edit.fontface) { |
3297 remove_font_face(imhtml, &start, end, TRUE); | 3315 remove_font_face(imhtml, start, end, TRUE); |
3298 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 3316 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
3299 find_font_face_tag(imhtml, imhtml->edit.fontface), | 3317 find_font_face_tag(imhtml, imhtml->edit.fontface), |
3300 &start, end); | 3318 start, end); |
3301 } | 3319 } |
3302 | 3320 |
3303 if (imhtml->edit.fontsize) { | 3321 if (imhtml->edit.fontsize) { |
3304 remove_font_size(imhtml, &start, end, TRUE); | 3322 remove_font_size(imhtml, start, end, TRUE); |
3305 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 3323 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
3306 find_font_size_tag(imhtml, imhtml->edit.fontsize), | 3324 find_font_size_tag(imhtml, imhtml->edit.fontsize), |
3307 &start, end); | 3325 start, end); |
3308 } | 3326 } |
3309 | 3327 |
3310 if (imhtml->edit.link) { | 3328 if (imhtml->edit.link) { |
3311 remove_font_link(imhtml, &start, end, TRUE); | 3329 remove_font_link(imhtml, start, end, TRUE); |
3312 gtk_text_buffer_apply_tag(imhtml->text_buffer, | 3330 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
3313 imhtml->edit.link, | 3331 imhtml->edit.link, |
3314 &start, end); | 3332 start, end); |
3315 } | 3333 } |
3316 | |
3317 } | 3334 } |
3318 | 3335 |
3319 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | 3336 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) |
3320 { | 3337 { |
3321 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | 3338 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); |