Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
7987:fc6b362f9c26 | 7988:d9e831876c28 |
---|---|
691 } | 691 } |
692 | 692 |
693 static void do_insert_link(GtkWidget *w, int resp, struct linkdlg *a) | 693 static void do_insert_link(GtkWidget *w, int resp, struct linkdlg *a) |
694 { | 694 { |
695 GaimGtkConversation *gtkconv; | 695 GaimGtkConversation *gtkconv; |
696 char *open_tag; | |
696 const char *urltext, *showtext; | 697 const char *urltext, *showtext; |
697 | 698 |
698 gtkconv = GAIM_GTK_CONVERSATION(a->c); | 699 gtkconv = GAIM_GTK_CONVERSATION(a->c); |
699 | 700 |
700 if (resp == GTK_RESPONSE_OK) { | 701 if (resp == GTK_RESPONSE_OK) { |
702 showtext = gtk_entry_get_text(GTK_ENTRY(a->text)); | 703 showtext = gtk_entry_get_text(GTK_ENTRY(a->text)); |
703 | 704 |
704 if (!strlen(showtext)) | 705 if (!strlen(showtext)) |
705 showtext = urltext; | 706 showtext = urltext; |
706 | 707 |
707 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), urltext, showtext); | 708 open_tag = g_strdup_printf("<A HREF=\"%s\">%s", urltext, showtext); |
708 gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>"); | 709 gaim_gtk_surround(gtkconv, open_tag, "</A>"); |
710 g_free(open_tag); | |
709 } | 711 } |
710 | 712 |
711 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), FALSE); | 713 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link), FALSE); |
712 } | 714 } |
713 | 715 |
857 /* GTK_IS_EDITABLE(c->entry); huh? */ | 859 /* GTK_IS_EDITABLE(c->entry); huh? */ |
858 | 860 |
859 gtkconv = GAIM_GTK_CONVERSATION(c); | 861 gtkconv = GAIM_GTK_CONVERSATION(c); |
860 | 862 |
861 gtkconv->fg_color = text_color; | 863 gtkconv->fg_color = text_color; |
862 g_snprintf(open_tag, 23, "#%02X%02X%02X", | 864 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", |
863 text_color.red / 256, | 865 text_color.red / 256, |
864 text_color.green / 256, | 866 text_color.green / 256, |
865 text_color.blue / 256); | 867 text_color.blue / 256); |
866 gtk_imhtml_toggle_forecolor(GTK_IMHTML(gtkconv->entry), open_tag); | 868 gaim_gtk_surround(gtkconv, open_tag, "</FONT>"); |
867 | 869 |
870 gaim_debug(GAIM_DEBUG_MISC, "fgcolor dialog", "#%02X%02X%02X\n", | |
871 text_color.red / 256, | |
872 text_color.green / 256, | |
873 text_color.blue / 256); | |
868 g_free(open_tag); | 874 g_free(open_tag); |
869 cancel_fgcolor(NULL, c); | 875 cancel_fgcolor(NULL, c); |
870 } | 876 } |
871 | 877 |
872 void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) | 878 void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel) |
884 /* GTK_IS_EDITABLE(c->entry); huh? */ | 890 /* GTK_IS_EDITABLE(c->entry); huh? */ |
885 | 891 |
886 gtkconv = GAIM_GTK_CONVERSATION(c); | 892 gtkconv = GAIM_GTK_CONVERSATION(c); |
887 | 893 |
888 gtkconv->bg_color = text_color; | 894 gtkconv->bg_color = text_color; |
889 g_snprintf(open_tag, 25, "#%02X%02X%02X", | 895 g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", |
890 text_color.red / 256, | 896 text_color.red / 256, |
891 text_color.green / 256, | 897 text_color.green / 256, |
892 text_color.blue / 256); | 898 text_color.blue / 256); |
893 gtk_imhtml_toggle_backcolor(GTK_IMHTML(gtkconv->entry), open_tag); | 899 gaim_gtk_surround(gtkconv, open_tag, "</BODY>"); |
894 | 900 gaim_debug(GAIM_DEBUG_MISC, "bgcolor dialog", "#%02X%02X%02X\n", |
901 text_color.red / 256, | |
902 text_color.green / 256, | |
903 text_color.blue / 256); | |
904 | |
895 g_free(open_tag); | 905 g_free(open_tag); |
896 cancel_bgcolor(NULL, c); | 906 cancel_bgcolor(NULL, c); |
897 } | 907 } |
898 | 908 |
899 void show_fgcolor_dialog(GaimConversation *c, GtkWidget *color) | 909 void show_fgcolor_dialog(GaimConversation *c, GtkWidget *color) |
1337 | 1347 |
1338 void insert_smiley_text(GtkWidget *widget, GaimConversation *c) | 1348 void insert_smiley_text(GtkWidget *widget, GaimConversation *c) |
1339 { | 1349 { |
1340 GaimGtkConversation *gtkconv; | 1350 GaimGtkConversation *gtkconv; |
1341 char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); | 1351 char *smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); |
1342 GaimPlugin *proto = gaim_find_prpl(gaim_account_get_protocol_id(gaim_conversation_get_account(c))); | 1352 GtkTextMark *select_mark, *insert_mark; |
1353 GtkTextIter select_iter, insert_iter; | |
1343 | 1354 |
1344 gtkconv = GAIM_GTK_CONVERSATION(c); | 1355 gtkconv = GAIM_GTK_CONVERSATION(c); |
1345 | 1356 |
1346 gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), proto->info->name, smiley_text); | 1357 select_mark = gtk_text_buffer_get_selection_bound(gtkconv->entry_buffer); |
1347 | 1358 insert_mark = gtk_text_buffer_get_insert(gtkconv->entry_buffer); |
1359 | |
1360 if(insert_mark != select_mark) { /* there is text selected */ | |
1361 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &select_iter, select_mark); | |
1362 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &insert_iter, insert_mark); | |
1363 gtk_text_buffer_delete(gtkconv->entry_buffer, &select_iter, &insert_iter); | |
1364 } | |
1365 | |
1366 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, smiley_text, -1); | |
1348 close_smiley_dialog(NULL, c); | 1367 close_smiley_dialog(NULL, c); |
1349 } | 1368 } |
1350 | 1369 |
1351 static void add_smiley(GaimConversation *c, GtkWidget *table, int row, int col, char *filename, char *face) | 1370 static void add_smiley(GaimConversation *c, GtkWidget *table, int row, int col, char *filename, char *face) |
1352 { | 1371 { |