[gaim-migrate @ 10442]

Mon, 26 Jul 2004 06:09:11 +0000

author
Tim Ringenbach <marv@pidgin.im>
date
Mon, 26 Jul 2004 06:09:11 +0000
changeset 9599
1089c73e0586
parent 9598
952f38eaf13d
child 9600
fa9aabd7d38a

[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.

src/gtkimhtml.c file | annotate | diff | comparison | revisions
src/gtkimhtmltoolbar.c file | annotate | diff | comparison | revisions
--- 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);
--- 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);
 	}

mercurial