pidgin/gtkimhtml.c

changeset 17879
3e3f85138f1a
parent 17695
5e7fcc2f23cc
parent 17877
1b4384bff09a
child 18185
d4f1719d812b
equal deleted inserted replaced
17751:87854ccfae54 17879:3e3f85138f1a
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>
4897 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) 4898 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f)
4898 { 4899 {
4899 g_return_if_fail(imhtml != NULL); 4900 g_return_if_fail(imhtml != NULL);
4900 imhtml->funcs = f; 4901 imhtml->funcs = f;
4901 } 4902 }
4903
4904 void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags)
4905 {
4906 if (flags & PURPLE_CONNECTION_HTML) {
4907 char color[8];
4908 GdkColor fg_color, bg_color;
4909
4910 gtk_imhtml_set_format_functions(imhtml, GTK_IMHTML_ALL);
4911 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != imhtml->edit.bold)
4912 gtk_imhtml_toggle_bold(imhtml);
4913
4914 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != imhtml->edit.italic)
4915 gtk_imhtml_toggle_italic(imhtml);
4916
4917 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != imhtml->edit.underline)
4918 gtk_imhtml_toggle_underline(imhtml);
4919
4920 gtk_imhtml_toggle_fontface(imhtml,
4921 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face"));
4922
4923 if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE))
4924 {
4925 int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size");
4926
4927 /* 3 is the default. */
4928 if (size != 3)
4929 gtk_imhtml_font_set_size(imhtml, size);
4930 }
4931
4932 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0)
4933 {
4934 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"),
4935 &fg_color);
4936 g_snprintf(color, sizeof(color), "#%02x%02x%02x",
4937 fg_color.red / 256,
4938 fg_color.green / 256,
4939 fg_color.blue / 256);
4940 } else
4941 strcpy(color, "");
4942
4943 gtk_imhtml_toggle_forecolor(imhtml, color);
4944
4945 if(!(flags & PURPLE_CONNECTION_NO_BGCOLOR) &&
4946 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0)
4947 {
4948 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"),
4949 &bg_color);
4950 g_snprintf(color, sizeof(color), "#%02x%02x%02x",
4951 bg_color.red / 256,
4952 bg_color.green / 256,
4953 bg_color.blue / 256);
4954 } else
4955 strcpy(color, "");
4956
4957 gtk_imhtml_toggle_background(imhtml, color);
4958
4959 if (flags & PURPLE_CONNECTION_FORMATTING_WBFO)
4960 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, TRUE);
4961 else
4962 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, FALSE);
4963 } else {
4964 imhtml_clear_formatting(imhtml);
4965 gtk_imhtml_set_format_functions(imhtml, 0);
4966 }
4967 }
4968

mercurial