Add prof.get_current_window to Retrieve Current Window Title (API change) #35

Manually merged
jabber.developer merged 1 commits from feat/api/get_current_window into master 2025-10-29 23:08:13 +00:00

This PR introduces the prof.get_current_window API to the plugin interface, allowing plugins to retrieve the title of the currently active window as displayed in the titlebar. This addresses a key gap for context-aware plugins and is especially useful for plugin windows, where the title equals the tag used for API communication (e.g., in prof_win_show). Plugins use window tags to target operations like displaying messages. By retrieving the title, plugins can dynamically get the tag for the active plugin window and interact with it directly. Additionally, this PR suggests (but does not yet implement) extending api_win_show to support non-plugin window types, e.g., by falling back to cons_show if the tag matches a console window, for broader compatibility (including in forks like cproof).

Changes

  • Implemented prof.get_current_window() -> str in the Python API, backed by the C function prof_get_current_window.
  • Added documentation for prof.get_current_window in the Python API reference, including special cases for MUC configuration and vCard windows
  • Updated C API with char* prof_get_current_window(void) to return the window title

Why

  • Fills a gap in the API, as no existing function retrieves the current window's title.
  • Crucial for plugin windows, where title = tag, enabling dynamic communication via functions like prof_win_show.
  • Enables plugins to act on the window's titlebar content for UI customization or context-aware commands.

Testing

  • Manually (via test plugin) verified the function returns correct titles for all window types (console, chat, MUC, plugin, etc.), including tags for plugin windows
  • Confirmed memory management in C (caller must free the returned string).
  • Tested in various contexts to ensure compatibility with plugin communication patterns.

Closes #34
Checklist:

  • Added Python and C implementations.
  • Updated API documentation with plugin tag rationale.
  • Tested across different window types, including plugins.
  • Ensured memory safety and efficiency (valgrind).
This PR introduces the `prof.get_current_window` API to the plugin interface, allowing plugins to retrieve the title of the currently active window as displayed in the titlebar. This addresses a key gap for context-aware plugins and is especially useful for plugin windows, where the title equals the tag used for API communication (e.g., in prof_win_show). Plugins use window tags to target operations like displaying messages. By retrieving the title, plugins can dynamically get the tag for the active plugin window and interact with it directly. Additionally, this PR suggests (but does not yet implement) extending `api_win_show` to support non-plugin window types, e.g., by falling back to cons_show if the tag matches a console window, for broader compatibility (including in forks like cproof). ### Changes - Implemented `prof.get_current_window() -> str` in the Python API, backed by the C function prof_get_current_window. - Added documentation for `prof.get_current_window` in the Python API reference, including special cases for MUC configuration and vCard windows - Updated C API with `char* prof_get_current_window(void)` to return the window title ### Why - Fills a gap in the API, as no existing function retrieves the current window's title. - Crucial for plugin windows, where `title` = `tag`, enabling dynamic communication via functions like `prof_win_show`. - Enables plugins to act on the window's titlebar content for UI customization or context-aware commands. ### Testing - [x] Manually (via test plugin) verified the function returns correct titles for all window types (console, chat, MUC, plugin, etc.), including tags for plugin windows - [x] Confirmed memory management in C (caller must free the returned string). - [x] Tested in various contexts to ensure compatibility with plugin communication patterns. ### Related Issue Closes #34 Checklist: - [x] Added Python and C implementations. - [x] Updated API documentation with plugin tag rationale. - [x] Tested across different window types, including plugins. - [x] Ensured memory safety and efficiency (`valgrind`).
jabber.developer added 1 commit 2025-10-01 15:57:57 +00:00
feat(api): add get_current_window call
Some checks failed
CI API Docs / Test C API Documentation Generation (pull_request) Successful in 31s
CI API Docs / Test Python API Documentation Generation (pull_request) Failing after 32s
CI Code / Check coding style (pull_request) Successful in 37s
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Linux (ubuntu) (pull_request) Successful in 13m12s
CI Code / Linux (arch) (pull_request) Successful in 13m52s
CI Code / Linux (debian) (pull_request) Successful in 15m5s
899f4eced8
Add prof_get_current_window API to retrieve the title of the currently active window, matching the titlebar display.

The feature is especially useful to track currently used plugin window.
admin force-pushed feat/api/get_current_window from 899f4eced8 to e36f7d5964 2025-10-01 16:03:15 +00:00 Compare
jabber.developer force-pushed feat/api/get_current_window from e36f7d5964 to 266f5aa046 2025-10-20 17:01:04 +00:00 Compare
jabber.developer manually merged commit 266f5aa046 into master 2025-10-29 23:08:13 +00:00
Sign in to join this conversation.
No description provided.