Mercurial > pidgin.yaz
diff pidgin/gtknotify.c @ 32520:fe75cd926073
Webkit Message views.
This commit is a squashed commit of the series of commits from my git repository which I was using for development.
(git://github.com/tdrhq/pidgin-clone.git, branch webkit)
author | tdrhq@soc.pidgin.im |
---|---|
date | Fri, 24 Jul 2009 01:18:07 +0000 |
parents | 975a29213f35 |
children | 1ca2df744414 |
line wrap: on
line diff
--- a/pidgin/gtknotify.c Thu Jul 23 04:05:31 2009 +0000 +++ b/pidgin/gtknotify.c Fri Jul 24 01:18:07 2009 +0000 @@ -36,10 +36,10 @@ #include "util.h" #include "gtkblist.h" -#include "gtkimhtml.h" #include "gtknotify.h" #include "gtkpounce.h" #include "gtkutils.h" +#include "gtkwebview.h" typedef struct { @@ -738,21 +738,6 @@ return FALSE; } -static GtkIMHtmlOptions -notify_imhtml_options(void) -{ - GtkIMHtmlOptions options = 0; - - if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting")) - options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; - - options |= GTK_IMHTML_NO_COMMENTS; - options |= GTK_IMHTML_NO_TITLE; - options |= GTK_IMHTML_NO_NEWLINE; - options |= GTK_IMHTML_NO_SCROLL; - return options; -} - static void * pidgin_notify_formatted(const char *title, const char *primary, const char *secondary, const char *text) @@ -761,8 +746,8 @@ GtkWidget *vbox; GtkWidget *label; GtkWidget *button; - GtkWidget *imhtml; - GtkWidget *frame; + GtkWidget *web_view; + GtkWidget *scrolled_window; char label_text[2048]; char *linked_text, *primary_esc, *secondary_esc; @@ -797,14 +782,18 @@ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); - /* Add the imhtml */ - frame = pidgin_create_imhtml(FALSE, &imhtml, NULL, NULL); - gtk_widget_set_name(imhtml, "pidgin_notify_imhtml"); - gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), - gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)) | GTK_IMHTML_IMAGE); - gtk_widget_set_size_request(imhtml, 300, 250); - gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); - gtk_widget_show(frame); + /* Add the webview */ + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + web_view = gtk_webview_new (); + gtk_container_add (GTK_CONTAINER (scrolled_window), web_view); + + gtk_widget_set_name(web_view, "pidgin_notify_webview"); + gtk_widget_set_size_request(web_view, 300, 250); + gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); + gtk_widget_show_all(scrolled_window); /* Add the Close button. */ button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); @@ -817,10 +806,10 @@ /* Make sure URLs are clickable */ linked_text = purple_markup_linkify(text); - gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, notify_imhtml_options()); + webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), linked_text, ""); g_free(linked_text); - g_object_set_data(G_OBJECT(window), "info-widget", imhtml); + g_object_set_data(G_OBJECT(window), "webview-widget", web_view); /* Show the window */ pidgin_auto_parent_window(window); @@ -1079,10 +1068,11 @@ info = purple_notify_user_info_get_text_with_newline(user_info, "<br />"); pinfo = g_hash_table_lookup(userinfo, key); if (pinfo != NULL) { - GtkIMHtml *imhtml = g_object_get_data(G_OBJECT(pinfo->window), "info-widget"); + GtkWidget *webview = g_object_get_data(G_OBJECT(pinfo->window), "webview-widget"); char *linked_text = purple_markup_linkify(info); - gtk_imhtml_clear(imhtml); - gtk_imhtml_append_text(imhtml, linked_text, notify_imhtml_options()); + g_assert (webview); + printf ("%s\n", linked_text); + gtk_webview_load_html_string_with_imgstore (GTK_WEBVIEW (webview), linked_text); g_free(linked_text); g_free(key); ui_handle = pinfo->window;