Skip to content

Commit

Permalink
Adding new API webui_open_url
Browse files Browse the repository at this point in the history
  • Loading branch information
hassandraga committed Jul 5, 2024
1 parent f25dd98 commit 6ca7601
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/webui.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@ WEBUI_EXPORT void webui_set_proxy(size_t window, const char* proxy_server);
*/
WEBUI_EXPORT const char* webui_get_url(size_t window);

/**
* @brief Open an URL in the native default web browser.
*
* @param url The URL to open
*
* @example webui_open_url("https://webui.me");
*/
WEBUI_EXPORT void webui_open_url(const char* url);

/**
* @brief Allow a specific window address to be accessible from a public network.
*
Expand Down
14 changes: 14 additions & 0 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,18 @@ void webui_set_proxy(size_t window, const char* proxy_server) {
win->proxy_set = true;
}

void webui_open_url(const char* url) {

#ifdef WEBUI_LOG
printf("[User] webui_open_url([%s])\n", url);
#endif

// Initialization
_webui_init();

_webui_open_url_native(url);
}

const char* webui_get_url(size_t window) {

#ifdef WEBUI_LOG
Expand Down Expand Up @@ -7495,6 +7507,8 @@ static void _webui_http_send_file(

// Send body
mg_send_file_body(client, path);

fclose(file);
}

static void _webui_http_send(
Expand Down

0 comments on commit 6ca7601

Please sign in to comment.