55include ./ bindings_prefix.nim
66
77const
8- WEBUI_VERSION * = " 2.5.0-beta.3 " # #
8+ WEBUI_VERSION * = " 2.5.0-beta.4 " # #
99 # # WebUI Library
1010 # # https://webui.me
1111 # # https://github.com/webui-dev/webui
@@ -145,6 +145,11 @@ type
145145 cookies* : cstring
146146 # # Client's full cookies
147147
148+ WebuiLoggerLevel * {.renameEnumFields .} = enum
149+ WEBUI_LOGGER_LEVEL_DEBUG = 0 , # # 0. All logs with all details
150+ WEBUI_LOGGER_LEVEL_INFO , # # 1. Only general logs
151+ WEBUI_LOGGER_LEVEL_ERROR # # 2. Only fatal error logs
152+
148153
149154proc new_window * (): csize_t {.webui , importc : " webui_new_window" .}
150155 # # -- Definitions ---------------------
@@ -335,6 +340,17 @@ proc set_high_contrast*(window: csize_t; status: bool) {.
335340 # #
336341 # # @example webui_set_high_contrast(myWindow, true);
337342 # #
343+ proc set_resizable * (window: csize_t ; status: bool ) {.
344+ webui , importc : " webui_set_resizable" .}
345+ # #
346+ # # @brief Sets whether the window frame is resizable or fixed.
347+ # # Works only on WebView window.
348+ # #
349+ # # @param window The window number
350+ # # @param status True or False
351+ # #
352+ # # @example webui_set_resizable(myWindow, true);
353+ # #
338354proc is_high_contrast * (): bool {.webui , importc : " webui_is_high_contrast" .}
339355 # #
340356 # # @brief Get OS high contrast preference.
@@ -366,6 +382,22 @@ proc close*(window: csize_t) {.webui, importc: "webui_close".}
366382 # #
367383 # # @example webui_close(myWindow);
368384 # #
385+ proc minimize * (window: csize_t ) {.webui , importc : " webui_minimize" .}
386+ # #
387+ # # @brief Minimize a WebView window.
388+ # #
389+ # # @param window The window number
390+ # #
391+ # # @example webui_minimize(myWindow);
392+ # #
393+ proc maximize * (window: csize_t ) {.webui , importc : " webui_maximize" .}
394+ # #
395+ # # @brief Maximize a WebView window.
396+ # #
397+ # # @param window The window number
398+ # #
399+ # # @example webui_maximize(myWindow);
400+ # #
369401proc close_client * (e: ptr Event ) {.webui , importc : " webui_close_client" .}
370402 # #
371403 # # @brief Close a specific client.
@@ -398,6 +430,14 @@ proc set_root_folder*(window: csize_t; path: cstring): bool {.
398430 # #
399431 # # @example webui_set_root_folder(myWindow, "/home/Foo/Bar/");
400432 # #
433+ proc set_browser_folder * (path: cstring ) {.webui , importc : " webui_set_browser_folder" .}
434+ # #
435+ # # @brief Set custom browser folder path.
436+ # #
437+ # # @param path The browser folder path
438+ # #
439+ # # @example webui_set_browser_folder("/home/Foo/Bar/");
440+ # #
401441proc set_default_root_folder * (path: cstring ): bool {.
402442 webui , importc : " webui_set_default_root_folder" .}
403443 # #
@@ -408,6 +448,20 @@ proc set_default_root_folder*(path: cstring): bool {.
408448 # #
409449 # # @example webui_set_default_root_folder("/home/Foo/Bar/");
410450 # #
451+ proc set_close_handler_wv * (window: csize_t ;
452+ close_handler: proc (window: csize_t ): bool {.webui .}) {.
453+ webui , importc : " webui_set_close_handler_wv" .}
454+ # #
455+ # # @brief Set a callback to catch the close event of the WebView window.
456+ # # Must return `false` to prevent the close event, `true` otherwise.
457+ # #
458+ # # @example
459+ # # bool myCloseEvent(size_t window) {
460+ # # // Prevent WebView window close event
461+ # # return false;
462+ # # }
463+ # # webui_set_close_handler(myWindow, myCloseEvent);
464+ # #
411465proc set_file_handler * (window: csize_t ; handler: proc (filename: cstring ;
412466 length: ptr cint ): pointer {.webui .}) {.webui , importc : " webui_set_file_handler" .}
413467 # #
@@ -591,6 +645,15 @@ proc set_position*(window: csize_t; x: cuint; y: cuint) {.
591645 # #
592646 # # @example webui_set_position(myWindow, 100, 100);
593647 # #
648+ proc set_center * (window: csize_t ) {.webui , importc : " webui_set_center" .}
649+ # #
650+ # # @brief Centers the window on the screen. Works better with
651+ # # WebView. Call this function before `webui_show()` for better results.
652+ # #
653+ # # @param window The window number
654+ # #
655+ # # @example webui_set_center(myWindow);
656+ # #
594657proc set_profile * (window: csize_t ; name: cstring ; path: cstring ) {.
595658 webui , importc : " webui_set_profile" .}
596659 # #
@@ -695,8 +758,7 @@ proc delete_profile*(window: csize_t) {.webui, importc: "webui_delete_profile".}
695758proc get_parent_process_id * (window: csize_t ): csize_t {.
696759 webui , importc : " webui_get_parent_process_id" .}
697760 # #
698- # # @brief Get the ID of the parent process (The web browser may re-create
699- # # another new process).
761+ # # @brief Get the parent process ID, which refers to the current backend application process.
700762 # #
701763 # # @param window The window number
702764 # #
@@ -707,7 +769,10 @@ proc get_parent_process_id*(window: csize_t): csize_t {.
707769proc get_child_process_id * (window: csize_t ): csize_t {.
708770 webui , importc : " webui_get_child_process_id" .}
709771 # #
710- # # @brief Get the ID of the last child process.
772+ # # @brief Get the child process ID created by the parent, which refers to the web browser window.
773+ # #
774+ # # Note: In WebView mode, this will return the parent process ID because the backend and the
775+ # # WebView window run in the same process.
711776 # #
712777 # # @param window The window number
713778 # #
@@ -727,6 +792,19 @@ proc win32_get_hwnd*(window: csize_t): pointer {.
727792 # #
728793 # # @example HWND hwnd = webui_win32_get_hwnd(myWindow);
729794 # #
795+ proc get_hwnd * (window: csize_t ): pointer {.webui , importc : " webui_get_hwnd" .}
796+ # #
797+ # # @brief Get window `HWND`. More reliable with WebView
798+ # # than web browser window, as browser PIDs may change on launch.
799+ # #
800+ # # @param window The window number
801+ # #
802+ # # @return Returns the window `hwnd` in Win32, `GtkWindow` in Linux.
803+ # #
804+ # # @example
805+ # # HWND hwnd = webui_get_hwnd(myWindow); // Win32 (Work with WebView and web browser)
806+ # # GtkWindow* window = webui_get_hwnd(myWindow); // Linux (Work with WebView only)
807+ # #
730808proc get_port * (window: csize_t ): csize_t {.webui , importc : " webui_get_port" .}
731809 # #
732810 # # @brief Get the network port of a running window.
@@ -759,6 +837,17 @@ proc get_free_port*(): csize_t {.webui, importc: "webui_get_free_port".}
759837 # #
760838 # # @example size_t port = webui_get_free_port();
761839 # #
840+ proc set_logger * (`func`: proc (level: csize_t ; log: cstring ; user_data: pointer ) {.webui .};
841+ user_data: pointer ) {.webui , importc : " webui_set_logger" .}
842+ # #
843+ # # @brief Set a custom logger function.
844+ # #
845+ # # @example
846+ # # void myLogger(size_t level, const char* log, void* user_data) {
847+ # # printf("myLogger (%d): %s", level, log);
848+ # # }
849+ # # webui_set_logger(myLogger, NULL);
850+ # #
762851proc set_config * (option: WebuiConfig ; status: bool ) {.
763852 webui , importc : " webui_set_config" .}
764853 # #
@@ -782,6 +871,26 @@ proc set_event_blocking*(window: csize_t; status: bool) {.
782871 # #
783872 # # @example webui_set_event_blocking(myWindow, true);
784873 # #
874+ proc set_frameless * (window: csize_t ; status: bool ) {.
875+ webui , importc : " webui_set_frameless" .}
876+ # #
877+ # # @brief Make a WebView window frameless.
878+ # #
879+ # # @param window The window number
880+ # # @param status The frameless status `true` or `false`
881+ # #
882+ # # @example webui_set_frameless(myWindow, true);
883+ # #
884+ proc set_transparent * (window: csize_t ; status: bool ) {.
885+ webui , importc : " webui_set_transparent" .}
886+ # #
887+ # # @brief Make a WebView window transparent.
888+ # #
889+ # # @param window The window number
890+ # # @param status The transparency status `true` or `false`
891+ # #
892+ # # @example webui_set_transparent(myWindow, true);
893+ # #
785894proc get_mime_type * (file: cstring ): cstring {.webui , importc : " webui_get_mime_type" .}
786895 # #
787896 # # @brief Get the HTTP mime type of a file.
@@ -1024,6 +1133,20 @@ proc return_bool*(e: ptr Event; b: bool) {.webui, importc: "webui_return_bool".}
10241133 # #
10251134 # # @example webui_return_bool(e, true);
10261135 # #
1136+ proc get_last_error_number * (): csize_t {.
1137+ webui , importc : " webui_get_last_error_number" .}
1138+ # #
1139+ # # @brief Get the last WebUI error code.
1140+ # #
1141+ # # @example int error_num = webui_get_last_error_number();
1142+ # #
1143+ proc get_last_error_message * (): cstring {.
1144+ webui , importc : " webui_get_last_error_message" .}
1145+ # #
1146+ # # @brief Get the last WebUI error message.
1147+ # #
1148+ # # @example const char* error_msg = webui_get_last_error_message();
1149+ # #
10271150proc interface_bind * (window: csize_t ; element: cstring ; `func`: proc (
10281151 a1: csize_t ; a2: csize_t ; a3: cstring ; a4: csize_t ; a5: csize_t ) {.webui .}): csize_t {.
10291152 webui , importc : " webui_interface_bind" .}
0 commit comments