Mercurial > pidgin
diff src/dialogs.c @ 7988:d9e831876c28
[gaim-migrate @ 8665]
Here's my best attempt to rip WYSIWYG editing out of gaim, kicking and
screaming all the way.
We'll be releasing 0.75 in the very near future, once the translators are
alerted, and any bugs from this dissection show themselves.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 04 Jan 2004 06:59:09 +0000 |
parents | 1b8261f374ea |
children | fa6395637e2c |
line wrap: on
line diff
--- a/src/dialogs.c Sun Jan 04 05:14:39 2004 +0000 +++ b/src/dialogs.c Sun Jan 04 06:59:09 2004 +0000 @@ -693,6 +693,7 @@ static void do_insert_link(GtkWidget *w, int resp, struct linkdlg *a) { GaimGtkConversation *gtkconv; + char *open_tag; const char *urltext, *showtext; gtkconv = GAIM_GTK_CONVERSATION(a->c); @@ -704,8 +705,9 @@ if (!strlen(showtext)) showtext = urltext; - gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), urltext, showtext); - gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>"); + open_tag = g_strdup_printf("<A HREF=\"%s\">%s", urltext, showtext); + gaim_gtk_surround(gtkconv, open_tag, "</A>"); + g_free(open_tag); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), FALSE); @@ -859,12 +861,16 @@ gtkconv = GAIM_GTK_CONVERSATION(c); gtkconv->fg_color = text_color; - g_snprintf(open_tag, 23, "#%02X%02X%02X", + g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red / 256, text_color.green / 256, text_color.blue / 256); - gtk_imhtml_toggle_forecolor(GTK_IMHTML(gtkconv->entry), open_tag); + gaim_gtk_surround(gtkconv, open_tag, "</FONT>"); + gaim_debug(GAIM_DEBUG_MISC, "fgcolor dialog", "#%02X%02X%02X\n", + text_color.red / 256, + text_color.green / 256, + text_color.blue / 256); g_free(open_tag); cancel_fgcolor(NULL, c); } @@ -886,12 +892,16 @@ gtkconv = GAIM_GTK_CONVERSATION(c); gtkconv->bg_color = text_color; - g_snprintf(open_tag, 25, "#%02X%02X%02X", + g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red / 256, text_color.green / 256, text_color.blue / 256); - gtk_imhtml_toggle_backcolor(GTK_IMHTML(gtkconv->entry), open_tag); - + gaim_gtk_surround(gtkconv, open_tag, "</BODY>"); + gaim_debug(GAIM_DEBUG_MISC, "bgcolor dialog", "#%02X%02X%02X\n", + text_color.red / 256, + text_color.green / 256, + text_color.blue / 256); + g_free(open_tag); cancel_bgcolor(NULL, c); } @@ -1339,12 +1349,21 @@ { GaimGtkConversation *gtkconv; char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); - GaimPlugin *proto = gaim_find_prpl(gaim_account_get_protocol_id(gaim_conversation_get_account(c))); + GtkTextMark *select_mark, *insert_mark; + GtkTextIter select_iter, insert_iter; gtkconv = GAIM_GTK_CONVERSATION(c); - gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), proto->info->name, smiley_text); + 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); }