Skip to content

Commit

Permalink
Expose spell checking support API in the Browser object (#274).
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cztomczak committed Feb 12, 2017
1 parent be10dba commit 81a8558
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/API-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions api/Browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -61,6 +62,7 @@ Table of contents:
* [ParentWindowWillClose](#parentwindowwillclose)
* [Reload](#reload)
* [ReloadIgnoreCache](#reloadignorecache)
* [ReplaceMisspelling](#replacemisspelling)
* [SetBounds](#setbounds)
* [SendKeyEvent](#sendkeyevent)
* [SendMouseClickEvent](#sendmouseclickevent)
Expand Down Expand Up @@ -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

| | |
Expand Down Expand Up @@ -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 |
Expand Down
10 changes: 10 additions & 0 deletions src/browser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/extern/cef/cef_browser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions src/linux/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/linux/installer/make-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions tools/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 81a8558

Please sign in to comment.