Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new natlink function for controlling the message window #213

Open
drmfinlay opened this issue Oct 16, 2024 · 1 comment
Open

Add a new natlink function for controlling the message window #213

drmfinlay opened this issue Oct 16, 2024 · 1 comment
Assignees

Comments

@drmfinlay
Copy link
Member

This was an idea that developed from my thinking on issue #198.

In a nutshell, an additional, setTrayIcon-like function could be added to enable/disable the Natlink message window and to handle user events (as preferred) in Python. This would allow us to hide the window for users in a multi-user system who don't have Natlink enabled and to use it in remote python.exe processes (at least for testing).

The function name I propose to use is setMessageWindow(). This function would take a single parameter: a callback function to handle user events. Adding a new File>Exit menu item to the window seems appropriate as part of this change. Ditto for detaching the window from the NatSpeak connection.

The following is the documentation I came up with:

setMessageWindow( callback )
This function enables and disables Natlink's message window. It may be called before or after natConnect().

This function has one required parameter whose value should be a Python function or None. If a function is passed, it should take one parameter which is the type of message window event:
idd_reload or idd_exit (each defined in natlinkutils)

Note: The idd_reload event occurs when the File>Reload menu item is activated. Before this function's callback is invoked, Natlink will unload all loaded grammars, destroy all existing ResObjs and DictObjs, and clear all callbacks except the message window callback (this one).

Passing a callback function enables the message window, passing None disables it. If None is passed and the message window exists, a File>Exit event (idd_exit) will be sent to the callback and the window will be destroyed.

I have this planned out and will try to make pull requests for review soon. I think it would be useful...

@drmfinlay drmfinlay self-assigned this Oct 16, 2024
drmfinlay added a commit to drmfinlay/natlink that referenced this issue Oct 17, 2024
Re: dictation-toolbox#213.

This item is grayed out (disabled) by default, for now.  I've added
a separator between it and the File>Reload item.
@drmfinlay
Copy link
Member Author

I think I'll leave completely detaching the window from the NatSpeak connection for now. It is possible, but not strictly necessary here.

drmfinlay added a commit to drmfinlay/natlink that referenced this issue Oct 22, 2024
Re: dictation-toolbox#213.

This item is grayed out (disabled) by default, for now.  I've added
a separator between it and the File>Reload item.
drmfinlay added a commit to drmfinlay/natlink that referenced this issue Oct 22, 2024
Re: dictation-toolbox#213.

The new function is setMessageWindow().  I have documented it in the
NatlinkSource/natlink.txt file.

It is now necessary to call this function with a Python callback to
enable the message window.  The default callback will soon reside in
the natlinkcore code and be set from appsupp.cpp.

Since it is related, this changeset includes modifications to the
message window's File>Reload logic, re: dictation-toolbox#28.  The default callback
will do a narrower reloading of user modules.
drmfinlay added a commit to drmfinlay/natlink that referenced this issue Oct 22, 2024
dougransom pushed a commit that referenced this issue Nov 26, 2024
* Fix Natlink message window pop-up menu initialization

Re: #184.

The message window's pop-up menu is now loaded from the executable
resource data.  It is easier to change now.

* Add an Exit item to the Natlink message window's File sub-menu

Re: #213.

This item is grayed out (disabled) by default, for now.  I've added
a separator between it and the File>Reload item.

* Adjust File>Exit menu item changes to do things the C++/Windows way

Re: #184.

That is, use boolean flags and a dedicated user window message to
convey updates to the output window.  This makes it easier to update
the pop-up menu later down the line, if desired, by adding and hand-
ling new flags.

* Add a new function for controlling Natlink's message window

Re: #213.

The new function is setMessageWindow().  I have documented it in the
NatlinkSource/natlink.txt file.

It is now necessary to call this function with a Python callback to
enable the message window.  The default callback will soon reside in
the natlinkcore code and be set from appsupp.cpp.

Since it is related, this changeset includes modifications to the
message window's File>Reload logic, re: #28.  The default callback
will do a narrower reloading of user modules.

* Fix global callbacks that fail without thread safety

This changes the CDragonCode::makeCallback() method to hold Python's
GIL regardless of whether Natlink thread safety is enabled.  A crash
occurs if this is not done.

* Adjust and fix the message window changes a little

Re: #213.

* Update appsupp

- Show the message window before natConnect().
- Remove the now unused reloadPython() method.

* Fix some indentation issues in two files

* Fix a problem with setMessageWindow()

* Stop releasing natlink objects on IDD_RELOAD

This can cause inconsistent state in user/library code.

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant