# HG changeset patch # User Nathan Walp # Date 1051811252 0 # Node ID 8bd4f777489f2898c36a2d7de02e865f08b6ffaf # Parent ad299f62b9b6c353f0f725be63ae8d055ed10beb [gaim-migrate @ 5647] inserting a smiley now replaces any hilighted text, like you'd think it would. also gets rid of a gtk warning when adding a smiley committer: Tailor Script diff -r ad299f62b9b6 -r 8bd4f777489f src/dialogs.c --- a/src/dialogs.c Thu May 01 17:28:30 2003 +0000 +++ b/src/dialogs.c Thu May 01 17:47:32 2003 +0000 @@ -3473,18 +3473,31 @@ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.smiley), FALSE); } - dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.smiley); - gtk_widget_destroy(gtkconv->dialogs.smiley); - gtkconv->dialogs.smiley = NULL; + if(gtkconv->dialogs.smiley) { + dialogwindows = g_list_remove(dialogwindows, gtkconv->dialogs.smiley); + gtk_widget_destroy(gtkconv->dialogs.smiley); + gtkconv->dialogs.smiley = NULL; + } } void insert_smiley_text(GtkWidget *widget, struct gaim_conversation *c) { struct gaim_gtk_conversation *gtkconv; char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); + GtkTextMark *select_mark, *insert_mark; + GtkTextIter select_iter, insert_iter; gtkconv = GAIM_GTK_CONVERSATION(c); + select_mark = gtk_text_buffer_get_selection_bound(gtkconv->entry_buffer); + insert_mark = gtk_text_buffer_get_insert(gtkconv->entry_buffer); + + if(insert_mark != select_mark) { /* there is text selected */ + gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &select_iter, select_mark); + gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &insert_iter, insert_mark); + gtk_text_buffer_delete(gtkconv->entry_buffer, &select_iter, &insert_iter); + } + gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, smiley_text, -1); close_smiley_dialog(NULL, c); }