comparison pidgin/gtklog.c @ 32576:7c346c5a05d4

propagate from branch 'im.pidgin.pidgin' (head 1bcd0bb175fd417fd165aa7b52e219c97b0e30c6) to branch 'im.pidgin.soc.2009.webkitmessageview' (head 75ffceeee02a5b5f52aac4008a35ac04f5f5a5f4)
author tdrhq@soc.pidgin.im
date Wed, 14 Oct 2009 02:41:11 +0000
parents fe75cd926073
children 041d5144730f
comparison
equal deleted inserted replaced
28749:5550823608cb 32576:7c346c5a05d4
33 #include "request.h" 33 #include "request.h"
34 #include "util.h" 34 #include "util.h"
35 35
36 #include "pidginstock.h" 36 #include "pidginstock.h"
37 #include "gtkblist.h" 37 #include "gtkblist.h"
38 #include "gtkimhtml.h"
39 #include "gtklog.h" 38 #include "gtklog.h"
40 #include "gtkutils.h" 39 #include "gtkutils.h"
40 #include "gtkwebview.h"
41 41
42 static GHashTable *log_viewers = NULL; 42 static GHashTable *log_viewers = NULL;
43 static void populate_log_tree(PidginLogViewer *lv); 43 static void populate_log_tree(PidginLogViewer *lv);
44 static PidginLogViewer *syslog_viewer = NULL; 44 static PidginLogViewer *syslog_viewer = NULL;
45 45
128 /* reset the tree */ 128 /* reset the tree */
129 gtk_tree_store_clear(lv->treestore); 129 gtk_tree_store_clear(lv->treestore);
130 populate_log_tree(lv); 130 populate_log_tree(lv);
131 g_free(lv->search); 131 g_free(lv->search);
132 lv->search = NULL; 132 lv->search = NULL;
133 gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml)); 133 webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(lv->web_view));
134 select_first_log(lv); 134 select_first_log(lv);
135 return; 135 return;
136 } 136 }
137 137
138 if (lv->search != NULL && !strcmp(lv->search, search_term)) 138 if (lv->search != NULL && !strcmp(lv->search, search_term))
139 { 139 {
140 /* Searching for the same term acts as "Find Next" */ 140 /* Searching for the same term acts as "Find Next" */
141 gtk_imhtml_search_find(GTK_IMHTML(lv->imhtml), lv->search); 141 webkit_web_view_search_text (WEBKIT_WEB_VIEW(lv->web_view), lv->search, FALSE, TRUE, TRUE);
142 return; 142 return;
143 } 143 }
144 144
145 pidgin_set_cursor(lv->window, GDK_WATCH); 145 pidgin_set_cursor(lv->window, GDK_WATCH);
146 146
147 g_free(lv->search); 147 g_free(lv->search);
148 lv->search = g_strdup(search_term); 148 lv->search = g_strdup(search_term);
149 149
150 gtk_tree_store_clear(lv->treestore); 150 gtk_tree_store_clear(lv->treestore);
151 gtk_imhtml_clear(GTK_IMHTML(lv->imhtml)); 151 webkit_web_view_open (WEBKIT_WEB_VIEW (lv->web_view), "about:blank"); /* clear the view */
152 152
153 for (logs = lv->logs; logs != NULL; logs = logs->next) { 153 for (logs = lv->logs; logs != NULL; logs = logs->next) {
154 char *read = purple_log_read((PurpleLog*)logs->data, NULL); 154 char *read = purple_log_read((PurpleLog*)logs->data, NULL);
155 if (read && *read && purple_strcasestr(read, search_term)) { 155 if (read && *read && purple_strcasestr(read, search_term)) {
156 GtkTreeIter iter; 156 GtkTreeIter iter;
420 } 420 }
421 421
422 static gboolean search_find_cb(gpointer data) 422 static gboolean search_find_cb(gpointer data)
423 { 423 {
424 PidginLogViewer *viewer = data; 424 PidginLogViewer *viewer = data;
425 gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search); 425 webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (viewer->web_view), viewer->search, FALSE, 0);
426 webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (viewer->web_view), TRUE);
427 webkit_web_view_search_text (WEBKIT_WEB_VIEW (viewer->web_view), viewer->search, FALSE, TRUE, TRUE);
426 return FALSE; 428 return FALSE;
427 } 429 }
428 430
429 static void log_select_cb(GtkTreeSelection *sel, PidginLogViewer *viewer) { 431 static void log_select_cb(GtkTreeSelection *sel, PidginLogViewer *viewer) {
430 GtkTreeIter iter; 432 GtkTreeIter iter;
461 } 463 }
462 464
463 read = purple_log_read(log, &flags); 465 read = purple_log_read(log, &flags);
464 viewer->flags = flags; 466 viewer->flags = flags;
465 467
466 gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml)); 468 webkit_web_view_open (WEBKIT_WEB_VIEW(viewer->web_view), "about:blank");
467 gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml),
468 purple_account_get_protocol_name(log->account));
469 469
470 purple_signal_emit(pidgin_log_get_handle(), "log-displaying", viewer, log); 470 purple_signal_emit(pidgin_log_get_handle(), "log-displaying", viewer, log);
471 471
472 gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read, 472 webkit_web_view_load_html_string (WEBKIT_WEB_VIEW(viewer->web_view), read, "");
473 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
474 ((flags & PURPLE_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0));
475 g_free(read); 473 g_free(read);
476 474
477 if (viewer->search != NULL) { 475 if (viewer->search != NULL) {
478 gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml)); 476 webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(viewer->web_view));
479 g_idle_add(search_find_cb, viewer); 477 g_idle_add(search_find_cb, viewer);
480 } 478 }
481 479
482 pidgin_clear_cursor(viewer->window); 480 pidgin_clear_cursor(viewer->window);
483 } 481 }
656 /* A fancy little box ************/ 654 /* A fancy little box ************/
657 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 655 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
658 gtk_paned_add2(GTK_PANED(pane), vbox); 656 gtk_paned_add2(GTK_PANED(pane), vbox);
659 657
660 /* Viewer ************/ 658 /* Viewer ************/
661 frame = pidgin_create_imhtml(FALSE, &lv->imhtml, NULL, NULL); 659 sw = gtk_scrolled_window_new (NULL, NULL);
662 gtk_widget_set_name(lv->imhtml, "pidgin_log_imhtml"); 660 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
663 gtk_widget_set_size_request(lv->imhtml, 320, 200); 661 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
664 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); 662
665 gtk_widget_show(frame); 663 lv->web_view = gtk_webview_new ();
664 gtk_container_add (GTK_CONTAINER (sw), lv->web_view);
665 gtk_widget_set_name(lv->web_view, "pidgin_log_web_view");
666 gtk_widget_set_size_request(lv->web_view, 320, 200);
667 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
668 gtk_widget_show(sw);
666 669
667 /* Search box **********/ 670 /* Search box **********/
668 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 671 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
669 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 672 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
670 lv->entry = gtk_entry_new(); 673 lv->entry = gtk_entry_new();