Mercurial > pidgin.yaz
diff src/dialogs.c @ 5275:8bd4f777489f
[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 <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 01 May 2003 17:47:32 +0000 |
parents | 4ac135a2f422 |
children | d579d5367836 |
line wrap: on
line diff
--- 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); }