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

Expose _webui_find_the_best_browser as webui_get_best_browser #326

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/webui.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ WEBUI_EXPORT size_t webui_get_new_window_id(void);
*/
WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));

/**
* @brief Get the "best" browser to be used. If running "webui::show()"
* or passing AnyBrowser to "webui::show_browser()", this function will
* return the same browser that will be used.
*
* @param window The window number
*
* @return Returns the best browser to be used.
*
* @example size_t browser = webui_get_best_browser(myWindow);
*/
WEBUI_EXPORT size_t webui_get_best_browser(size_t window);

/**
* @brief Show a window using embedded HTML, or a file. If the window is already
* open, it will be refreshed.
Expand Down
2 changes: 2 additions & 0 deletions include/webui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class window {
// Get the ID of the last child process spawned by the browser.
size_t get_child_process_id() const { return webui_get_child_process_id(webui_window); }

size_t get_best_browser() const { return webui_get_best_browser(webui_window); }

// Set the web-server root folder path for this specific window.
bool set_root_folder(const std::string_view path) const {
return webui_set_root_folder(webui_window, path.data());
Expand Down
6 changes: 6 additions & 0 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,12 @@ size_t webui_bind(size_t window, const char* element, void( * func)(webui_event_
return cb_index;
}

size_t webui_get_best_browser(size_t window) {
// This just exposes the existing function
_webui_window_t * win = _webui_core.wins[window];
return _webui_find_the_best_browser(win);
}

const char* webui_get_string_at(webui_event_t* e, size_t index) {

#ifdef WEBUI_LOG
Expand Down
Loading