# HG changeset patch # User Tim Ringenbach # Date 1090822151 0 # Node ID a1029432ae4a7c1b16c870ec151813c702c45b0f # Parent 0ad01d743f6019858443d48532271b081562172c [gaim-migrate @ 10442] Simguy writes: This makes the insert link behavior a little better: 1) If there is a selection in the IMHTML to which you are inserting a link, prefill the Description field in the dialog. 2) Delete the selected text and replace it with whatever the description field contains when inserting the link (this is why we do #1) The former behavior was to prepend the description entered to the selection and link the whole block, which seemed illogical to me. committer: Tailor Script diff -r 0ad01d743f60 -r a1029432ae4a src/gtkimhtml.c --- a/src/gtkimhtml.c Mon Jul 26 04:05:08 2004 +0000 +++ b/src/gtkimhtml.c Mon Jul 26 06:09:11 2004 +0000 @@ -3769,6 +3769,9 @@ { GtkTextIter iter; + if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) + gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); + gtk_imhtml_toggle_link(imhtml, url); gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); diff -r 0ad01d743f60 -r a1029432ae4a src/gtkimhtmltoolbar.c --- a/src/gtkimhtmltoolbar.c Mon Jul 26 04:05:08 2004 +0000 +++ b/src/gtkimhtmltoolbar.c Mon Jul 26 06:09:11 2004 +0000 @@ -382,7 +382,9 @@ GaimRequestFields *fields; GaimRequestFieldGroup *group; GaimRequestField *field; + GtkTextIter start, end; char *msg; + char *desc = NULL; fields = gaim_request_fields_new(); @@ -394,8 +396,11 @@ gaim_request_field_group_add_field(group, field); if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) { + if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, &start, &end)) { + desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end); + } field = gaim_request_field_string_new("description", _("_Description"), - NULL, FALSE); + desc, FALSE); gaim_request_field_group_add_field(group, field); msg = g_strdup(_("Please enter the URL and description of the " "link that you want to insert. The description " @@ -414,6 +419,7 @@ _("Cancel"), G_CALLBACK(cancel_link_cb), toolbar); g_free(msg); + g_free(desc); } else { close_link_dialog(toolbar); }