From a0f0e5368807f17685ec8836be24eef43541e329 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Tue, 31 May 2011 22:47:13 +0200 Subject: Add suggestions to correct misspellings to the context menu When the user right-clicks on a misspelled word a number of possible corrections will be offered by Epiphany. Selecting one of them will replace the misspelled word by the suggestion. --- src/popup-commands.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/popup-commands.c') diff --git a/src/popup-commands.c b/src/popup-commands.c index e7064f16d..14867c411 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -478,6 +478,33 @@ save_temp_source (const char *address) g_free (dest_uri); } +void +popup_replace_spelling (GtkAction *action, + EphyWindow *window) +{ + EphyEmbed *embed; + WebKitWebView *view; + WebKitWebFrame *frame; + WebKitDOMDOMSelection *selection; + WebKitDOMDocument *document; + WebKitDOMDOMWindow *default_view; + + embed = ephy_embed_container_get_active_child + (EPHY_EMBED_CONTAINER (window)); + g_return_if_fail (embed != NULL); + + view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed)); + g_return_if_fail (view != NULL); + + document = webkit_web_view_get_dom_document (view); + default_view = webkit_dom_document_get_default_view (document); + selection = webkit_dom_dom_window_get_selection (default_view); + webkit_dom_dom_selection_modify (selection, "move", "backward", "word"); + webkit_dom_dom_selection_modify (selection, "extend", "forward", "word"); + frame = webkit_web_view_get_focused_frame (view); + webkit_web_frame_replace_selection (frame, gtk_action_get_label (action)); +} + void popup_cmd_open_image (GtkAction *action, EphyWindow *window) -- cgit