comparison pidgin/gtkimhtml.c @ 17517:274ceb453176

Allow formatted text in the pounce dialog. Also, use the same code to initialize the formatting in the pounce, pref and conversation windows. This closes #1088.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 25 May 2007 22:04:18 +0000
parents 05fa005bdc59
children be7e6375ce7e
comparison
equal deleted inserted replaced
17516:8fe927fa0220 17517:274ceb453176
29 #endif 29 #endif
30 #include "debug.h" 30 #include "debug.h"
31 #include "util.h" 31 #include "util.h"
32 #include "gtkimhtml.h" 32 #include "gtkimhtml.h"
33 #include "gtksourceiter.h" 33 #include "gtksourceiter.h"
34 #include "pidgin.h"
34 #include <gtk/gtk.h> 35 #include <gtk/gtk.h>
35 #include <glib/gerror.h> 36 #include <glib/gerror.h>
36 #include <gdk/gdkkeysyms.h> 37 #include <gdk/gdkkeysyms.h>
37 #include <string.h> 38 #include <string.h>
38 #include <ctype.h> 39 #include <ctype.h>
4854 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) 4855 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f)
4855 { 4856 {
4856 g_return_if_fail(imhtml != NULL); 4857 g_return_if_fail(imhtml != NULL);
4857 imhtml->funcs = f; 4858 imhtml->funcs = f;
4858 } 4859 }
4860
4861 void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags)
4862 {
4863 if (flags & PURPLE_CONNECTION_HTML) {
4864 char color[8];
4865 GdkColor fg_color, bg_color;
4866
4867 gtk_imhtml_set_format_functions(imhtml, GTK_IMHTML_ALL);
4868 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != imhtml->edit.bold)
4869 gtk_imhtml_toggle_bold(imhtml);
4870
4871 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != imhtml->edit.italic)
4872 gtk_imhtml_toggle_italic(imhtml);
4873
4874 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != imhtml->edit.underline)
4875 gtk_imhtml_toggle_underline(imhtml);
4876
4877 gtk_imhtml_toggle_fontface(imhtml,
4878 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face"));
4879
4880 if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE))
4881 {
4882 int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size");
4883
4884 /* 3 is the default. */
4885 if (size != 3)
4886 gtk_imhtml_font_set_size(imhtml, size);
4887 }
4888
4889 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0)
4890 {
4891 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"),
4892 &fg_color);
4893 g_snprintf(color, sizeof(color), "#%02x%02x%02x",
4894 fg_color.red / 256,
4895 fg_color.green / 256,
4896 fg_color.blue / 256);
4897 } else
4898 strcpy(color, "");
4899
4900 gtk_imhtml_toggle_forecolor(imhtml, color);
4901
4902 if(!(flags & PURPLE_CONNECTION_NO_BGCOLOR) &&
4903 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0)
4904 {
4905 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"),
4906 &bg_color);
4907 g_snprintf(color, sizeof(color), "#%02x%02x%02x",
4908 bg_color.red / 256,
4909 bg_color.green / 256,
4910 bg_color.blue / 256);
4911 } else
4912 strcpy(color, "");
4913
4914 gtk_imhtml_toggle_background(imhtml, color);
4915
4916 if (flags & PURPLE_CONNECTION_FORMATTING_WBFO)
4917 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, TRUE);
4918 else
4919 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, FALSE);
4920 } else {
4921 imhtml_clear_formatting(imhtml);
4922 gtk_imhtml_set_format_functions(imhtml, 0);
4923 }
4924 }
4925