Commit ce10e4ed authored by Balló György's avatar Balló György Committed by Michael Catanzaro

Incomplete port to WebKit2

The work is mostly done by Carlos Garcia, rebase by György. It's got
FIXMEs and serious bugs, but it's better than no Empathy at all once
WebKit1 is removed from Fedora in two short months.

https://bugzilla.gnome.org/show_bug.cgi?id=749001
parent f5276946
......@@ -69,7 +69,7 @@ LIBCANBERRA_GTK_REQUIRED=0.25
LIBNOTIFY_REQUIRED=0.7.0
LIBSOUP_REQUIRED=2.42.0
TELEPATHY_LOGGER=0.8.0
WEBKIT_REQUIRED=1.9.1
WEBKIT_REQUIRED=2.10.0
GOA_REQUIRED=3.5.1
# Optional deps
......@@ -234,7 +234,7 @@ PKG_CHECK_MODULES(EMPATHY,
gcr-3 >= $GCR_REQUIRED
libpulse
libpulse-mainloop-glib
webkitgtk-3.0 >= $WEBKIT_REQUIRED
webkit2gtk-4.0 >= $WEBKIT_REQUIRED
libsoup-2.4 >= $LIBSOUP_REQUIRED
gee-0.8
])
......
......@@ -198,7 +198,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (EmpathyChat, empathy_chat, GTK_TYPE_BOX);
#if 0
/* FIXME: We need to figure out how to fill backlog automatically with WebKit2 */
static gboolean chat_scrollable_connect (gpointer user_data);
#endif
static gboolean update_misspelled_words (gpointer data);
static void
......@@ -2532,6 +2535,8 @@ show_pending_messages (EmpathyChat *chat) {
}
}
#if 0
/* FIXME: We need to figure out how to fill backlog automatically with WebKit2 */
static gboolean
chat_scrollable_set_value (gpointer user_data)
{
......@@ -2551,6 +2556,7 @@ chat_scrollable_set_value (gpointer user_data)
return G_SOURCE_REMOVE;
}
#endif
static void
got_filtered_messages_cb (GObject *walker,
......@@ -2621,6 +2627,8 @@ out:
/* Turn back on scrolling */
empathy_theme_adium_scroll (chat->view, TRUE);
#if 0
/* FIXME: We need to figure out how to fill backlog automatically with WebKit2 */
/* We start watching the scrolling movements only after the first
* batch of logs have been fetched. Otherwise, if the
* chat->view's page size is too small the scrollbar might hit
......@@ -2653,7 +2661,7 @@ out:
g_idle_add_full (G_PRIORITY_LOW, chat_scrollable_set_value,
g_object_ref (chat), g_object_unref);
}
#endif
g_object_unref (chat);
}
......@@ -2675,6 +2683,8 @@ chat_add_logs (EmpathyChat *chat)
return G_SOURCE_REMOVE;
}
#if 0
/* FIXME: We need to figure out how to fill backlog automatically with WebKit2 */
static void
chat_schedule_logs (EmpathyChat *chat)
{
......@@ -2757,6 +2767,7 @@ chat_scrollable_connect (gpointer user_data)
return G_SOURCE_REMOVE;
}
#endif
static gint
chat_contacts_completion_func (const gchar *s1,
......@@ -3268,8 +3279,20 @@ chat_create_ui (EmpathyChat *chat)
g_signal_connect (chat->view, "focus_in_event",
G_CALLBACK (chat_text_view_focus_in_event_cb),
chat);
gtk_container_add (GTK_CONTAINER (priv->scrolled_window_chat),
GTK_WIDGET (chat->view));
if (GTK_IS_SCROLLABLE (chat->view))
{
gtk_container_add (GTK_CONTAINER (priv->scrolled_window_chat),
GTK_WIDGET (chat->view));
}
else
{
gtk_widget_hide (priv->scrolled_window_chat);
gtk_box_pack_start (GTK_BOX (priv->vbox_left),
GTK_WIDGET (chat->view),
TRUE, TRUE, 0);
gtk_box_reorder_child (GTK_BOX (priv->vbox_left),
GTK_WIDGET (chat->view), 0);
}
gtk_widget_show (GTK_WIDGET (chat->view));
/* Add input GtkTextView */
......@@ -4322,16 +4345,6 @@ empathy_chat_cut (EmpathyChat *chat)
}
}
static gboolean
copy_from_chat_view (EmpathyChat *chat)
{
if (!empathy_theme_adium_get_has_selection (chat->view))
return FALSE;
empathy_theme_adium_copy_clipboard (chat->view);
return TRUE;
}
static gboolean
copy_from_input (EmpathyChat *chat)
{
......@@ -4376,13 +4389,15 @@ copy_from_topic (EmpathyChat *chat)
return TRUE;
}
void
empathy_chat_copy (EmpathyChat *chat)
static void
theme_adium_can_copy_cb (EmpathyThemeAdium *view,
GAsyncResult *result,
EmpathyChat *chat)
{
g_return_if_fail (EMPATHY_IS_CHAT (chat));
if (copy_from_chat_view (chat))
if (empathy_theme_adium_can_copy_finish (view, result, NULL)) {
empathy_theme_adium_copy_clipboard (chat->view);
return;
}
if (copy_from_input (chat))
return;
......@@ -4390,6 +4405,16 @@ empathy_chat_copy (EmpathyChat *chat)
copy_from_topic (chat);
}
void
empathy_chat_copy (EmpathyChat *chat)
{
g_return_if_fail (EMPATHY_IS_CHAT (chat));
empathy_theme_adium_can_copy (chat->view, NULL,
(GAsyncReadyCallback)theme_adium_can_copy_cb,
chat);
}
void
empathy_chat_paste (EmpathyChat *chat)
{
......
......@@ -398,15 +398,15 @@ insert_or_change_row (EmpathyLogWindow *self,
g_string_append_c (escaped_text, c);
}
script = g_strdup_printf ("javascript:%s([%s], '%s', '%s', '%s');",
script = g_strdup_printf ("%s([%s], '%s', '%s', '%s');",
method,
g_strdelimit (str, ":", ','),
escaped_text->str,
icon != NULL ? icon : "",
date);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self->priv->webview),
script);
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self->priv->webview),
script, NULL, NULL, NULL);
g_string_free (escaped_text, TRUE);
g_free (str);
......@@ -443,11 +443,11 @@ store_events_row_deleted (GtkTreeModel *model,
char *str = gtk_tree_path_to_string (path);
char *script;
script = g_strdup_printf ("javascript:deleteRow([%s]);",
script = g_strdup_printf ("deleteRow([%s]);",
g_strdelimit (str, ":", ','));
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self->priv->webview),
script);
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self->priv->webview),
script, NULL, NULL, NULL);
g_free (str);
g_free (script);
......@@ -462,12 +462,12 @@ store_events_has_child_rows (GtkTreeModel *model,
char *str = gtk_tree_path_to_string (path);
char *script;
script = g_strdup_printf ("javascript:hasChildRows([%s], %u);",
script = g_strdup_printf ("hasChildRows([%s], %u);",
g_strdelimit (str, ":", ','),
gtk_tree_model_iter_has_child (model, iter));
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self->priv->webview),
script);
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self->priv->webview),
script, NULL, NULL, NULL);
g_free (str);
g_free (script);
......@@ -492,12 +492,12 @@ store_events_rows_reordered (GtkTreeModel *model,
new_order_s = g_strjoinv (",", new_order_strv);
script = g_strdup_printf ("javascript:reorderRows([%s], [%s]);",
script = g_strdup_printf ("reorderRows([%s], [%s]);",
str == NULL ? "" : g_strdelimit (str, ":", ','),
new_order_s);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self->priv->webview),
script);
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self->priv->webview),
script, NULL, NULL, NULL);
g_free (str);
g_free (script);
......@@ -507,17 +507,65 @@ store_events_rows_reordered (GtkTreeModel *model,
static gboolean
events_webview_handle_navigation (WebKitWebView *webview,
WebKitWebFrame *frame,
WebKitNetworkRequest *request,
WebKitWebNavigationAction *navigation_action,
WebKitWebPolicyDecision *policy_decision,
WebKitPolicyDecision *decision,
WebKitPolicyDecisionType decision_type,
EmpathyLogWindow *window)
{
empathy_url_show (GTK_WIDGET (webview),
webkit_network_request_get_uri (request));
if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
return FALSE;
webkit_web_policy_decision_ignore (policy_decision);
return TRUE;
return empathy_webkit_handle_navigation (webview, WEBKIT_NAVIGATION_POLICY_DECISION (decision));
}
static void
events_webview_load_changed (WebKitWebView *web_view,
WebKitLoadEvent event,
EmpathyLogWindow *window)
{
if (event != WEBKIT_LOAD_FINISHED)
return;
if (window->priv->store_events)
return;
/* Contacts */
log_window_events_setup (window);
log_window_who_setup (window);
log_window_what_setup (window);
log_window_when_setup (window);
log_window_create_observer (window);
log_window_who_populate (window);
g_signal_connect (window->priv->account_chooser, "changed",
G_CALLBACK (log_window_chats_accounts_changed_cb),
window);
/* listen to changes to the treemodel */
g_signal_connect (window->priv->store_events, "row-inserted",
G_CALLBACK (store_events_row_inserted), window);
g_signal_connect (window->priv->store_events, "row-changed",
G_CALLBACK (store_events_row_changed), window);
g_signal_connect (window->priv->store_events, "row-deleted",
G_CALLBACK (store_events_row_deleted), window);
g_signal_connect (window->priv->store_events, "rows-reordered",
G_CALLBACK (store_events_rows_reordered), window);
g_signal_connect (window->priv->store_events, "row-has-child-toggled",
G_CALLBACK (store_events_has_child_rows), window);
log_window_update_buttons_sensitivity (window);
}
static gboolean
events_webview_context_menu (WebKitWebView *web_view,
WebKitContextMenu *context_menu,
GdkEvent *event,
WebKitHitTestResult *hit_test_result,
EmpathyLogWindow *window)
{
empathy_webkit_populate_context_menu (web_view, context_menu, hit_test_result, 0);
return FALSE;
}
static GObject *
......@@ -612,7 +660,6 @@ empathy_log_window_init (EmpathyLogWindow *self)
gchar *filename;
GFile *gfile;
GtkWidget *vbox, *accounts, *search, *label, *closeitem;
GtkWidget *scrolledwindow_events;
gchar *uri;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
......@@ -645,7 +692,6 @@ empathy_log_window_init (EmpathyLogWindow *self)
"treeview_who", &self->priv->treeview_who,
"treeview_what", &self->priv->treeview_what,
"treeview_when", &self->priv->treeview_when,
"scrolledwindow_events", &scrolledwindow_events,
"notebook", &self->priv->notebook,
"spinner", &self->priv->spinner,
NULL);
......@@ -679,10 +725,6 @@ empathy_log_window_init (EmpathyLogWindow *self)
gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->account_chooser),
GTK_STYLE_CLASS_RAISED);
g_signal_connect (self->priv->account_chooser, "changed",
G_CALLBACK (log_window_chats_accounts_changed_cb),
self);
label = gtk_label_new (_("Show"));
gtk_box_pack_start (GTK_BOX (vbox),
......@@ -730,28 +772,27 @@ empathy_log_window_init (EmpathyLogWindow *self)
G_CALLBACK (log_window_search_entry_icon_pressed_cb),
self);
/* Contacts */
log_window_events_setup (self);
log_window_who_setup (self);
log_window_what_setup (self);
log_window_when_setup (self);
log_window_create_observer (self);
log_window_who_populate (self);
/* events */
self->priv->webview = webkit_web_view_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_events),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scrolledwindow_events),
self->priv->webview);
self->priv->webview = g_object_new (WEBKIT_TYPE_WEB_VIEW,
"web-context", empathy_webkit_get_web_context (),
"settings", empathy_webkit_get_web_settings (),
NULL);
gtk_notebook_prepend_page (GTK_NOTEBOOK (self->priv->notebook),
self->priv->webview, NULL);
gtk_widget_show (self->priv->webview);
empathy_webkit_bind_font_setting (WEBKIT_WEB_VIEW (self->priv->webview),
self->priv->gsettings_desktop,
EMPATHY_PREFS_DESKTOP_INTERFACE_FONT_NAME);
/* handle all navigation externally */
g_signal_connect (self->priv->webview, "decide-policy",
G_CALLBACK (events_webview_handle_navigation), self);
g_signal_connect (self->priv->webview, "load-changed",
G_CALLBACK (events_webview_load_changed), self);
g_signal_connect (self->priv->webview, "context-menu",
G_CALLBACK (events_webview_context_menu), self);
g_object_set (webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->webview)),
"default-encoding", "utf8",
NULL);
......@@ -765,27 +806,10 @@ empathy_log_window_init (EmpathyLogWindow *self)
g_object_unref (gfile);
g_free (uri);
/* handle all navigation externally */
g_signal_connect (self->priv->webview, "navigation-policy-decision-requested",
G_CALLBACK (events_webview_handle_navigation), self);
/* listen to changes to the treemodel */
g_signal_connect (self->priv->store_events, "row-inserted",
G_CALLBACK (store_events_row_inserted), self);
g_signal_connect (self->priv->store_events, "row-changed",
G_CALLBACK (store_events_row_changed), self);
g_signal_connect (self->priv->store_events, "row-deleted",
G_CALLBACK (store_events_row_deleted), self);
g_signal_connect (self->priv->store_events, "rows-reordered",
G_CALLBACK (store_events_rows_reordered), self);
g_signal_connect (self->priv->store_events, "row-has-child-toggled",
G_CALLBACK (store_events_has_child_rows), self);
/* track clicked row */
g_signal_connect (self->priv->webview, "button-press-event",
G_CALLBACK (log_window_events_button_press_event), self);
log_window_update_buttons_sensitivity (self);
gtk_widget_show (GTK_WIDGET (self));
empathy_geometry_bind (GTK_WINDOW (self), "log-window");
......@@ -2011,8 +2035,9 @@ log_window_find_populate (EmpathyLogWindow *self,
if (TPAW_STR_EMPTY (search_criteria))
{
tp_clear_pointer (&self->priv->hits, tpl_log_manager_search_free);
webkit_web_view_set_highlight_text_matches (
WEBKIT_WEB_VIEW (self->priv->webview), FALSE);
webkit_find_controller_search_finish (
webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (self->priv->webview)));
log_window_who_populate (self);
return;
}
......@@ -2022,8 +2047,9 @@ log_window_find_populate (EmpathyLogWindow *self,
self);
/* highlight the search text */
webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (self->priv->webview),
search_criteria, FALSE, 0);
webkit_find_controller_search (
webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (self->priv->webview)),
search_criteria, WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, G_MAXUINT);
tpl_log_manager_search_async (self->priv->log_manager,
search_criteria, TPL_EVENT_MASK_ANY,
......@@ -2577,6 +2603,16 @@ static void
log_window_find_row (EmpathyLogWindow *self,
GdkEventButton *event)
{
/* FIXME: We can't do this in this way in WebKit2, but I'm not sure we really want
* to port this, it took me a while to figure out what this was for, and I find it
* quite confusing. When you click in the web view the clicked contact is stored
* as selected contact even when there's no visual selection at all. So, for example
* if you select multiple people the video and call buttons are unsensitive, then
* you click on the web view and the buttons become sensitive if the capabilities
* are available for the internally selected contact, but the contwaxct list still have
* multiple people selected and nothing is selected in the web view.
*/
#if 0
WebKitHitTestResult *hit = webkit_web_view_get_hit_test_result (
WEBKIT_WEB_VIEW (self->priv->webview), event);
WebKitDOMNode *inner_node;
......@@ -2633,6 +2669,7 @@ log_window_find_row (EmpathyLogWindow *self,
g_object_unref (hit);
log_window_update_buttons_sensitivity (self);
#endif
}
static gboolean
......@@ -2646,11 +2683,6 @@ log_window_events_button_press_event (GtkWidget *webview,
log_window_find_row (self, event);
break;
case 3:
empathy_webkit_context_menu_for_event (
WEBKIT_WEB_VIEW (webview), event, 0);
return TRUE;
default:
break;
}
......@@ -3145,9 +3177,9 @@ log_window_maybe_expand_events (void)
/* If there's only one result, expand it */
if (gtk_tree_model_iter_n_children (model, NULL) == 1)
webkit_web_view_execute_script (
webkit_web_view_run_javascript (
WEBKIT_WEB_VIEW (log_window->priv->webview),
"javascript:expandAll()");
"expandAll()", NULL, NULL, NULL);
}
static gboolean
......@@ -3285,12 +3317,12 @@ log_window_got_messages_for_date_cb (GObject *manager,
path = gtk_tree_model_get_path (model, &iter);
str = gtk_tree_path_to_string (path);
script = g_strdup_printf ("javascript:scrollToRow([%s]);",
script = g_strdup_printf ("scrollToRow([%s]);",
g_strdelimit (str, ":", ','));
webkit_web_view_execute_script (
webkit_web_view_run_javascript (
WEBKIT_WEB_VIEW (log_window->priv->webview),
script);
script, NULL, NULL, NULL);
gtk_tree_path_free (path);
g_free (str);
......
......@@ -79,18 +79,36 @@ empathy_search_bar_update_buttons (EmpathySearchBar *self,
}
static void
empathy_search_bar_update (EmpathySearchBar *self)
empathy_search_bar_search (EmpathySearchBar *self,
gboolean next,
gboolean new_search)
{
gchar *search;
gboolean found;
gboolean match_case;
EmpathySearchBarPriv *priv = GET_PRIV (self);
EmpathySearchBarPriv *priv;
priv = GET_PRIV (self);
search = gtk_editable_get_chars (GTK_EDITABLE(priv->search_entry), 0, -1);
match_case = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (priv->search_match_case));
/* highlight & search */
empathy_theme_adium_highlight (priv->chat_view, search, match_case);
if (new_search)
empathy_theme_adium_search (priv->chat_view, search, match_case);
else if (next)
empathy_theme_adium_find_next (priv->chat_view);
else
empathy_theme_adium_find_previous (priv->chat_view);
/* FIXME: We should connect to failed-to-find-text of WebKitFindController, but this
* doesn't seem to work in any case.
*/
found = TRUE;
/* (don't) display the not found label */
gtk_widget_set_visible (priv->search_not_found,
!(found || TPAW_STR_EMPTY (search)));
/* update the buttons */
empathy_search_bar_update_buttons (self, search, match_case);
......@@ -104,7 +122,7 @@ empathy_search_bar_show (EmpathySearchBar *self)
EmpathySearchBarPriv *priv = GET_PRIV (self);
/* update the highlighting and buttons */
empathy_search_bar_update (self);
empathy_search_bar_search (self, FALSE, TRUE);
/* grab the focus to the search entry */
gtk_widget_grab_focus (priv->search_entry);
......@@ -117,56 +135,13 @@ empathy_search_bar_hide (EmpathySearchBar *self)
{
EmpathySearchBarPriv *priv = GET_PRIV (self);
empathy_theme_adium_highlight (priv->chat_view, "", FALSE);
empathy_theme_adium_search (priv->chat_view, "", FALSE);
gtk_widget_hide (GTK_WIDGET (self));
/* give the focus back to the focus-chain with the chat view */
gtk_widget_grab_focus (GTK_WIDGET (priv->chat_view));
}
static void
empathy_search_bar_search (EmpathySearchBar *self,
gboolean next,
gboolean new_search)
{
gchar *search;
gboolean found;
gboolean match_case;
EmpathySearchBarPriv *priv;
priv = GET_PRIV (self);
search = gtk_editable_get_chars (GTK_EDITABLE(priv->search_entry), 0, -1);
match_case = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (priv->search_match_case));
/* highlight & search */
empathy_theme_adium_highlight (priv->chat_view, search, match_case);
if (next)
{
found = empathy_theme_adium_find_next (priv->chat_view,
search,
new_search,
match_case);
}
else
{
found = empathy_theme_adium_find_previous (priv->chat_view,
search,
new_search,
match_case);
}
/* (don't) display the not found label */
gtk_widget_set_visible (priv->search_not_found,
!(found || TPAW_STR_EMPTY (search)));
/* update the buttons */
empathy_search_bar_update_buttons (self, search, match_case);
g_free (search);
}
static void
empathy_search_bar_close_cb (GtkButton *button,
gpointer user_data)
......@@ -212,7 +187,7 @@ static void
empathy_search_bar_match_case_toggled (GtkButton *button,
gpointer user_data)
{
empathy_search_bar_update (EMPATHY_SEARCH_BAR (user_data));
empathy_search_bar_search (EMPATHY_SEARCH_BAR (user_data), FALSE, TRUE);
}
static void
......
......@@ -168,28 +168,15 @@ free_queued_item (QueuedItem *item)
}
static gboolean
theme_adium_navigation_policy_decision_requested_cb (WebKitWebView *view,
WebKitWebFrame *web_frame,
WebKitNetworkRequest *request,
WebKitWebNavigationAction *action,
WebKitWebPolicyDecision *decision,
theme_adium_policy_decision_requested_cb (WebKitWebView *view,
WebKitPolicyDecision *decision,
WebKitPolicyDecisionType decision_type,
gpointer data)
{
const gchar *uri;
/* Only call url_show on clicks */
if (webkit_web_navigation_action_get_reason (action) !=
WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
{
webkit_web_policy_decision_use (decision);
return TRUE;
}
uri = webkit_network_request_get_uri (request);
empathy_url_show (GTK_WIDGET (view), uri);
if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
return FALSE;
webkit_web_policy_decision_ignore (decision);
return TRUE;
return empathy_webkit_handle_navigation (view, WEBKIT_NAVIGATION_POLICY_DECISION (decision));
}
/* Replace each %@ in format with string passed in args */
......@@ -238,7 +225,7 @@ theme_adium_load_template (EmpathyThemeAdium *self)
template = string_with_format (self->priv->data->template_html,
variant_path, NULL);
webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (self),
webkit_web_view_load_html (WEBKIT_WEB_VIEW (self),
template, basedir_uri);
g_free (basedir_uri);
......@@ -741,7 +728,7 @@ theme_adium_add_html (EmpathyThemeAdium *self,
}
script = g_string_free (string, FALSE);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self), script);
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self), script, NULL, NULL, NULL);
g_free (script);
}
......@@ -761,7 +748,8 @@ theme_adium_append_event_escaped (EmpathyThemeAdium *self,
self->priv->last_contact = NULL;
}
}
#if 0
/* FIXME: check what this is for and port to WebKit2 */
static void
theme_adium_remove_focus_marks (EmpathyThemeAdium *self,
WebKitDOMNodeList *nodes)
......@@ -805,10 +793,12 @@ theme_adium_remove_focus_marks (EmpathyThemeAdium *self,
g_string_free (new_class_name, TRUE);
}
}
#endif
static void
theme_adium_remove_all_focus_marks (EmpathyThemeAdium *self)
{
#if 0
/* FIXME: check what this is for and port to WebKit2 */
WebKitDOMDocument *dom;
WebKitDOMNodeList *nodes;
GError *error = NULL;
......@@ -834,6 +824,7 @@ theme_adium_remove_all_focus_marks (EmpathyThemeAdium *self)
}
theme_adium_remove_focus_marks (self, nodes);
#endif
}
enum
......@@ -1164,6 +1155,8 @@ void
empathy_theme_adium_edit_message (EmpathyThemeAdium *self,
EmpathyMessage *message)
{
#if 0
/* FIXME: this needs to be ported to WebKit2, but I have no idea what this is for */
WebKitDOMDocument *doc;
WebKitDOMElement *span;
gchar *id, *parsed_body;
......@@ -1261,6 +1254,7 @@ except:
finally:
g_free (id);
g_free (parsed_body);
#endif
}
void
......@@ -1276,19 +1270,47 @@ empathy_theme_adium_scroll (EmpathyThemeAdium *self,
void
empathy_theme_adium_scroll_down (EmpathyThemeAdium *self)
{
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self), "alignChat(true);");
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self), "alignChat(true);", NULL, NULL, NULL);
}
static void
can_copy_cb (WebKitWebView *web_view,
GAsyncResult *result,
GTask *task)
{
g_task_return_boolean (task,
webkit_web_view_can_execute_editing_command_finish (web_view, result, NULL));
g_object_unref (task);
}
void
empathy_theme_adium_can_copy (EmpathyThemeAdium *self,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
task = g_task_new (self, cancellable, callback, user_data);
webkit_web_view_can_execute_editing_command (WEBKIT_WEB_VIEW (self), WEBKIT_EDITING_COMMAND_COPY,
cancellable, (GAsyncReadyCallback)can_copy_cb, task);
}
gboolean
empathy_theme_adium_get_has_selection (EmpathyThemeAdium *self)
empathy_theme_adium_can_copy_finish (EmpathyThemeAdium *self,
GAsyncResult* result,
GError** error)
{
return webkit_web_view_has_selection (WEBKIT_WEB_VIEW (self));
if (!g_task_is_valid (result, self))
return FALSE;
return g_task_propagate_boolean (G_TASK (result), error);
}
void
empathy_theme_adium_clear (EmpathyThemeAdium *self)
{
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self), "clearPage()");
webkit_web_view_run_javascript (WEBKIT_WEB_VIEW (self), "clearPage()", NULL, NULL, NULL);
empathy_theme_adium_scroll_down (self);
/* Clear last contact to avoid trying to add a 'joined'
......@@ -1300,26 +1322,16 @@ empathy_theme_adium_clear (EmpathyThemeAdium *self)