From 81a85587af589d591983cfc29f580c8094fd6b6e Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 12 Feb 2017 09:08:01 +0100 Subject: [PATCH] Expose spell checking support API in the Browser object (#274). See also Issue #274 to see command line switches related to spell checking support. Run wxpython example after compile. Fix linux make-setup.py. Update tools/toc.py. --- api/API-index.md | 2 ++ api/Browser.md | 23 +++++++++++++++++++++++ src/browser.pyx | 10 ++++++++++ src/extern/cef/cef_browser.pxd | 4 ++++ src/linux/compile.py | 1 + src/linux/installer/make-setup.py | 4 ++-- tools/toc.py | 4 ++++ 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/api/API-index.md b/api/API-index.md index ee8882a4..94b887a9 100644 --- a/api/API-index.md +++ b/api/API-index.md @@ -35,6 +35,7 @@ * [user_data_path](ApplicationSettings.md#user_data_path) * [windowless_rendering_enabled](ApplicationSettings.md#windowless_rendering_enabled) * [Browser (object)](Browser.md) + * [AddWordToDictionary](Browser.md#addwordtodictionary) * [CanGoBack](Browser.md#cangoback) * [CanGoForward](Browser.md#cangoforward) * [CloseBrowser](Browser.md#closebrowser) @@ -84,6 +85,7 @@ * [ParentWindowWillClose](Browser.md#parentwindowwillclose) * [Reload](Browser.md#reload) * [ReloadIgnoreCache](Browser.md#reloadignorecache) + * [ReplaceMisspelling](Browser.md#replacemisspelling) * [SetBounds](Browser.md#setbounds) * [SendKeyEvent](Browser.md#sendkeyevent) * [SendMouseClickEvent](Browser.md#sendmouseclickevent) diff --git a/api/Browser.md b/api/Browser.md index 2f02c60f..46135cc0 100644 --- a/api/Browser.md +++ b/api/Browser.md @@ -12,6 +12,7 @@ just assign a None value to a "browser" variable. Table of contents: * [Notes](#notes) * [Methods](#methods) + * [AddWordToDictionary](#addwordtodictionary) * [CanGoBack](#cangoback) * [CanGoForward](#cangoforward) * [CloseBrowser](#closebrowser) @@ -61,6 +62,7 @@ Table of contents: * [ParentWindowWillClose](#parentwindowwillclose) * [Reload](#reload) * [ReloadIgnoreCache](#reloadignorecache) + * [ReplaceMisspelling](#replacemisspelling) * [SetBounds](#setbounds) * [SendKeyEvent](#sendkeyevent) * [SendMouseClickEvent](#sendmouseclickevent) @@ -99,6 +101,16 @@ Methods available in upstream CEF which were not yet exposed in CEF Python ## Methods +### AddWordToDictionary + +| Parameter | Type | +| --- | --- | +| word | string | +| __Return__ | void | + +Add the specified |word| to the spelling dictionary. + + ### CanGoBack | | | @@ -658,6 +670,17 @@ Reload the current page. Reload the current page ignoring any cached data. +### ReplaceMisspelling + +| Parameter | Type | +| --- | --- | +| word | string | +| __Return__ | void | + +If a misspelled word is currently selected in an editable node calling +this method will replace it with the specified |word|. + + ### SetBounds | Parameter | Type | diff --git a/src/browser.pyx b/src/browser.pyx index dba50285..83b0d417 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -251,6 +251,11 @@ cdef class PyBrowser: # CEF API. # -------------- + cpdef py_void AddWordToDictionary(self, py_string word): + cdef CefString cef_word + PyToCefString(word, cef_word) + self.GetCefBrowserHost().get().AddWordToDictionary(cef_word) + cpdef py_bool CanGoBack(self): return self.GetCefBrowser().get().CanGoBack() @@ -404,6 +409,11 @@ cdef class PyBrowser: cpdef py_void ReloadIgnoreCache(self): self.GetCefBrowser().get().ReloadIgnoreCache() + cpdef py_void ReplaceMisspelling(self, py_string word): + cdef CefString cef_word + PyToCefString(word, cef_word) + self.GetCefBrowserHost().get().ReplaceMisspelling(cef_word) + cpdef py_void SetBounds(self, int x, int y, int width, int height): if platform.system() == "Linux": x11.SetX11WindowBounds(self.GetCefBrowser(), x, y, width, height) diff --git a/src/extern/cef/cef_browser.pxd b/src/extern/cef/cef_browser.pxd index 26b2b314..663fcb2b 100644 --- a/src/extern/cef/cef_browser.pxd +++ b/src/extern/cef/cef_browser.pxd @@ -79,6 +79,10 @@ cdef extern from "include/cef_browser.h": void DragSourceEndedAt(int x, int y, cef_types.cef_drag_operations_mask_t op) void DragSourceSystemDragEnded() + # Spell checking + void ReplaceMisspelling(const CefString& word) + void AddWordToDictionary(const CefString& word) + cdef cppclass CefBrowser: diff --git a/src/linux/compile.py b/src/linux/compile.py index 125c5dda..623c3b07 100644 --- a/src/linux/compile.py +++ b/src/linux/compile.py @@ -303,6 +303,7 @@ def check_cython_version(): run_examples = " && {python} ../src/linux/binaries_64bit/kivy_.py" else: run_examples = (" && {python} hello_world.py" + " && {python} wxpython.py" " && {python} gtk2.py" " && {python} gtk2.py --message-loop-timer" # " && {python} gtk3.py" diff --git a/src/linux/installer/make-setup.py b/src/linux/installer/make-setup.py index f2700e57..bd016cb1 100644 --- a/src/linux/installer/make-setup.py +++ b/src/linux/installer/make-setup.py @@ -189,9 +189,9 @@ def main(): # assert ret == 0 print("Copying wx/ to package dir") - wx_subpackage_dir = os.path.abspath(INSTALLER_DIR+"/../../wx/") + wx_subpackage_dir = os.path.abspath(INSTALLER_DIR+"/../../cefpython3.wx/") ret = os.system("cp -rf " + wx_subpackage_dir + "/* " + package_dir - + "/cefpython3.wx/") + + "/wx/") assert ret == 0 # print("Moving wx examples from wx/examples to examples/wx") diff --git a/tools/toc.py b/tools/toc.py index a0791e0b..3e4d698c 100644 --- a/tools/toc.py +++ b/tools/toc.py @@ -14,9 +14,13 @@ import re import glob +API_DIR = os.path.join(os.path.dirname(__file__), "..", "api") + def main(): """Main entry point.""" + if len(sys.argv) == 1: + sys.argv.append(API_DIR) if (len(sys.argv) == 1 or "-h" in sys.argv or "--help" in sys.argv or