comparison src/gtkimhtmltoolbar.c @ 9599:a1029432ae4a

[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 <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 26 Jul 2004 06:09:11 +0000
parents 4399fc6e667a
children 4d05b6e9e9cd
comparison
equal deleted inserted replaced
9598:0ad01d743f60 9599:a1029432ae4a
380 { 380 {
381 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) { 381 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))) {
382 GaimRequestFields *fields; 382 GaimRequestFields *fields;
383 GaimRequestFieldGroup *group; 383 GaimRequestFieldGroup *group;
384 GaimRequestField *field; 384 GaimRequestField *field;
385 GtkTextIter start, end;
385 char *msg; 386 char *msg;
387 char *desc = NULL;
386 388
387 fields = gaim_request_fields_new(); 389 fields = gaim_request_fields_new();
388 390
389 group = gaim_request_field_group_new(NULL); 391 group = gaim_request_field_group_new(NULL);
390 gaim_request_fields_add_group(fields, group); 392 gaim_request_fields_add_group(fields, group);
392 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE); 394 field = gaim_request_field_string_new("url", _("_URL"), NULL, FALSE);
393 gaim_request_field_set_required(field, TRUE); 395 gaim_request_field_set_required(field, TRUE);
394 gaim_request_field_group_add_field(group, field); 396 gaim_request_field_group_add_field(group, field);
395 397
396 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) { 398 if(GTK_IMHTML(toolbar->imhtml)->format_functions & GTK_IMHTML_LINKDESC) {
399 if (gtk_text_buffer_get_selection_bounds(GTK_IMHTML(toolbar->imhtml)->text_buffer, &start, &end)) {
400 desc = gtk_imhtml_get_text(GTK_IMHTML(toolbar->imhtml), &start, &end);
401 }
397 field = gaim_request_field_string_new("description", _("_Description"), 402 field = gaim_request_field_string_new("description", _("_Description"),
398 NULL, FALSE); 403 desc, FALSE);
399 gaim_request_field_group_add_field(group, field); 404 gaim_request_field_group_add_field(group, field);
400 msg = g_strdup(_("Please enter the URL and description of the " 405 msg = g_strdup(_("Please enter the URL and description of the "
401 "link that you want to insert. The description " 406 "link that you want to insert. The description "
402 "is optional.")); 407 "is optional."));
403 } else { 408 } else {
412 fields, 417 fields,
413 _("_Insert"), G_CALLBACK(do_insert_link_cb), 418 _("_Insert"), G_CALLBACK(do_insert_link_cb),
414 _("Cancel"), G_CALLBACK(cancel_link_cb), 419 _("Cancel"), G_CALLBACK(cancel_link_cb),
415 toolbar); 420 toolbar);
416 g_free(msg); 421 g_free(msg);
422 g_free(desc);
417 } else { 423 } else {
418 close_link_dialog(toolbar); 424 close_link_dialog(toolbar);
419 } 425 }
420 gtk_widget_grab_focus(toolbar->imhtml); 426 gtk_widget_grab_focus(toolbar->imhtml);
421 } 427 }