Mercurial > pidgin
comparison src/gtkimhtml.c @ 12673:de93d4988ad4
[gaim-migrate @ 15016]
gaim_imhtml_link.patch from SF Patch #1237965 from Sadrul
"This patch fixes bug #1237289. It simply makes sure new
text in an empty text-buffer doesn't get hyperlinked."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 29 Dec 2005 15:55:30 +0000 |
parents | 4bd7e2ebb4cb |
children | e8db8f94a2db |
comparison
equal
deleted
inserted
replaced
12672:4bd7e2ebb4cb | 12673:de93d4988ad4 |
---|---|
95 gint y, | 95 gint y, |
96 guint time); | 96 guint time); |
97 | 97 |
98 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); | 98 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
99 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); | 99 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
100 static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); | |
100 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); | 101 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
101 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | 102 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); |
102 static gboolean gtk_imhtml_is_amp_escape (const gchar *string, gchar **replace, gint *length); | 103 static gboolean gtk_imhtml_is_amp_escape (const gchar *string, gchar **replace, gint *length); |
103 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); | 104 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
104 static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); | 105 static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
1378 /* See the comment for gtk_key_pressed_cb */ | 1379 /* See the comment for gtk_key_pressed_cb */ |
1379 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); | 1380 g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); |
1380 #endif | 1381 #endif |
1381 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); | 1382 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
1382 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); | 1383 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); |
1384 g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); | |
1383 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); | 1385 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
1384 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); | 1386 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
1385 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, | 1387 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
1386 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | 1388 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), |
1387 GDK_ACTION_COPY); | 1389 GDK_ACTION_COPY); |
3793 gtk_text_iter_set_offset(&start, imhtml->insert_offset); | 3795 gtk_text_iter_set_offset(&start, imhtml->insert_offset); |
3794 | 3796 |
3795 gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); | 3797 gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
3796 } | 3798 } |
3797 | 3799 |
3800 static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, GtkIMHtml *imhtml) | |
3801 { | |
3802 GSList *tags, *l; | |
3803 | |
3804 tags = gtk_text_iter_get_tags(start); | |
3805 for (l = tags; l != NULL; l = l->next) { | |
3806 GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
3807 | |
3808 if (tag && /* Remove the formatting only if */ | |
3809 gtk_text_iter_starts_word(start) && /* beginning of a word */ | |
3810 gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */ | |
3811 (!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */ | |
3812 gtk_text_iter_ends_tag(end, tag))) { | |
3813 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end); | |
3814 if (tag->name && | |
3815 strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { | |
3816 gtk_imhtml_toggle_link(imhtml, NULL); | |
3817 } | |
3818 } | |
3819 } | |
3820 g_slist_free(tags); | |
3821 } | |
3822 | |
3798 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) | 3823 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
3799 { | 3824 { |
3800 if (imhtml->edit.bold) | 3825 if (imhtml->edit.bold) |
3801 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); | 3826 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
3802 else | 3827 else |