Skip to content

Commit 5f27ded

Browse files
authored
Merge pull request #1 from YesDrX/fix_workflows
change webui to nightly; fix workflows
2 parents 0193337 + 40028b6 commit 5f27ded

File tree

5 files changed

+134
-9
lines changed

5 files changed

+134
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
*.exe
99
*.so
1010
*.a
11+
.vscode
12+
.vscode/*

examples/public_network_access.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ proc main =
7676
# Public Window
7777
public_window.public = true # Make URL accessible from public networks
7878
public_window.bind("") do (e: Event): # Bind all events
79-
if e.eventType == weConnected:
79+
if e.eventType == WebuiEvent.weConnected:
8080
private_window.run("document.getElementById('Logs').value += 'New connection.\\n';")
81-
elif e.eventType == weDisconnected:
81+
elif e.eventType == WebuiEvent.weDisconnected:
8282
private_window.run("document.getElementById('Logs').value += 'Disconnected.\\n';")
8383

84-
public_window.show(publicHtml, wbNoBrowser) # Set public window HTML
84+
public_window.show(publicHtml, WebuiBrowser.wbNoBrowser) # Set public window HTML
8585
let public_win_url = public_window.url # Get URL of public window
8686

8787
# Main Private Window

webui.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "2.5.0.1"
3+
version = "2.5.0.2"
44
author = "Jasmine"
55
description = "Wrapper for WebUI"
66
license = "MIT"

webui/bindings.nim

Lines changed: 127 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
include ./bindings_prefix.nim
66

77
const
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

149154
proc 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+
##
338354
proc 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+
##
369401
proc 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+
##
401441
proc 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+
##
411465
proc 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+
##
594657
proc 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".}
695758
proc 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 {.
707769
proc 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+
##
730808
proc 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+
##
762851
proc 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+
##
785894
proc 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+
##
10271150
proc 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".}

webui/webui

Submodule webui updated 61 files

0 commit comments

Comments
 (0)