| 736 } |
736 } |
| 737 |
737 |
| 738 return FALSE; |
738 return FALSE; |
| 739 } |
739 } |
| 740 |
740 |
| 741 static GtkIMHtmlOptions |
|
| 742 notify_imhtml_options(void) |
|
| 743 { |
|
| 744 GtkIMHtmlOptions options = 0; |
|
| 745 |
|
| 746 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting")) |
|
| 747 options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; |
|
| 748 |
|
| 749 options |= GTK_IMHTML_NO_COMMENTS; |
|
| 750 options |= GTK_IMHTML_NO_TITLE; |
|
| 751 options |= GTK_IMHTML_NO_NEWLINE; |
|
| 752 options |= GTK_IMHTML_NO_SCROLL; |
|
| 753 return options; |
|
| 754 } |
|
| 755 |
|
| 756 static void * |
741 static void * |
| 757 pidgin_notify_formatted(const char *title, const char *primary, |
742 pidgin_notify_formatted(const char *title, const char *primary, |
| 758 const char *secondary, const char *text) |
743 const char *secondary, const char *text) |
| 759 { |
744 { |
| 760 GtkWidget *window; |
745 GtkWidget *window; |
| 761 GtkWidget *vbox; |
746 GtkWidget *vbox; |
| 762 GtkWidget *label; |
747 GtkWidget *label; |
| 763 GtkWidget *button; |
748 GtkWidget *button; |
| 764 GtkWidget *imhtml; |
749 GtkWidget *web_view; |
| 765 GtkWidget *frame; |
750 GtkWidget *scrolled_window; |
| 766 char label_text[2048]; |
751 char label_text[2048]; |
| 767 char *linked_text, *primary_esc, *secondary_esc; |
752 char *linked_text, *primary_esc, *secondary_esc; |
| 768 |
753 |
| 769 window = gtk_dialog_new(); |
754 window = gtk_dialog_new(); |
| 770 gtk_window_set_title(GTK_WINDOW(window), title); |
755 gtk_window_set_title(GTK_WINDOW(window), title); |
| 795 gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
780 gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 796 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
781 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
| 797 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
782 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
| 798 gtk_widget_show(label); |
783 gtk_widget_show(label); |
| 799 |
784 |
| 800 /* Add the imhtml */ |
785 /* Add the webview */ |
| 801 frame = pidgin_create_imhtml(FALSE, &imhtml, NULL, NULL); |
786 scrolled_window = gtk_scrolled_window_new (NULL, NULL); |
| 802 gtk_widget_set_name(imhtml, "pidgin_notify_imhtml"); |
787 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); |
| 803 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), |
788 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 804 gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)) | GTK_IMHTML_IMAGE); |
789 |
| 805 gtk_widget_set_size_request(imhtml, 300, 250); |
790 web_view = gtk_webview_new (); |
| 806 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
791 gtk_container_add (GTK_CONTAINER (scrolled_window), web_view); |
| 807 gtk_widget_show(frame); |
792 |
| |
793 gtk_widget_set_name(web_view, "pidgin_notify_webview"); |
| |
794 gtk_widget_set_size_request(web_view, 300, 250); |
| |
795 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); |
| |
796 gtk_widget_show_all(scrolled_window); |
| 808 |
797 |
| 809 /* Add the Close button. */ |
798 /* Add the Close button. */ |
| 810 button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); |
799 button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); |
| 811 gtk_widget_grab_focus(button); |
800 gtk_widget_grab_focus(button); |
| 812 |
801 |
| 815 g_signal_connect(G_OBJECT(window), "key_press_event", |
804 g_signal_connect(G_OBJECT(window), "key_press_event", |
| 816 G_CALLBACK(formatted_input_cb), NULL); |
805 G_CALLBACK(formatted_input_cb), NULL); |
| 817 |
806 |
| 818 /* Make sure URLs are clickable */ |
807 /* Make sure URLs are clickable */ |
| 819 linked_text = purple_markup_linkify(text); |
808 linked_text = purple_markup_linkify(text); |
| 820 gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, notify_imhtml_options()); |
809 webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), linked_text, ""); |
| 821 g_free(linked_text); |
810 g_free(linked_text); |
| 822 |
811 |
| 823 g_object_set_data(G_OBJECT(window), "info-widget", imhtml); |
812 g_object_set_data(G_OBJECT(window), "webview-widget", web_view); |
| 824 |
813 |
| 825 /* Show the window */ |
814 /* Show the window */ |
| 826 pidgin_auto_parent_window(window); |
815 pidgin_auto_parent_window(window); |
| 827 |
816 |
| 828 gtk_widget_show(window); |
817 gtk_widget_show(window); |
| 1077 } |
1066 } |
| 1078 |
1067 |
| 1079 info = purple_notify_user_info_get_text_with_newline(user_info, "<br />"); |
1068 info = purple_notify_user_info_get_text_with_newline(user_info, "<br />"); |
| 1080 pinfo = g_hash_table_lookup(userinfo, key); |
1069 pinfo = g_hash_table_lookup(userinfo, key); |
| 1081 if (pinfo != NULL) { |
1070 if (pinfo != NULL) { |
| 1082 GtkIMHtml *imhtml = g_object_get_data(G_OBJECT(pinfo->window), "info-widget"); |
1071 GtkWidget *webview = g_object_get_data(G_OBJECT(pinfo->window), "webview-widget"); |
| 1083 char *linked_text = purple_markup_linkify(info); |
1072 char *linked_text = purple_markup_linkify(info); |
| 1084 gtk_imhtml_clear(imhtml); |
1073 g_assert (webview); |
| 1085 gtk_imhtml_append_text(imhtml, linked_text, notify_imhtml_options()); |
1074 printf ("%s\n", linked_text); |
| |
1075 gtk_webview_load_html_string_with_imgstore (GTK_WEBVIEW (webview), linked_text); |
| 1086 g_free(linked_text); |
1076 g_free(linked_text); |
| 1087 g_free(key); |
1077 g_free(key); |
| 1088 ui_handle = pinfo->window; |
1078 ui_handle = pinfo->window; |
| 1089 pinfo->count++; |
1079 pinfo->count++; |
| 1090 } else { |
1080 } else { |