1#[doc = " Missing dependency."]
4pub const webview_error_t_WEBVIEW_ERROR_MISSING_DEPENDENCY: webview_error_t = -5;
5#[doc = " Operation canceled."]
6pub const webview_error_t_WEBVIEW_ERROR_CANCELED: webview_error_t = -4;
7#[doc = " Invalid state detected."]
8pub const webview_error_t_WEBVIEW_ERROR_INVALID_STATE: webview_error_t = -3;
9#[doc = " One or more invalid arguments have been specified e.g. in a function call."]
10pub const webview_error_t_WEBVIEW_ERROR_INVALID_ARGUMENT: webview_error_t = -2;
11#[doc = " An unspecified error occurred. A more specific error code may be needed."]
12pub const webview_error_t_WEBVIEW_ERROR_UNSPECIFIED: webview_error_t = -1;
13#[doc = " OK/Success. Functions that return error codes will typically return this\n to signify successful operations."]
14pub const webview_error_t_WEBVIEW_ERROR_OK: webview_error_t = 0;
15#[doc = " Signifies that something already exists."]
16pub const webview_error_t_WEBVIEW_ERROR_DUPLICATE: webview_error_t = 1;
17#[doc = " Signifies that something does not exist."]
18pub const webview_error_t_WEBVIEW_ERROR_NOT_FOUND: webview_error_t = 2;
19#[doc = " @brief Error codes returned to callers of the API.\n\n The following codes are commonly used in the library:\n - @c WEBVIEW_ERROR_OK\n - @c WEBVIEW_ERROR_UNSPECIFIED\n - @c WEBVIEW_ERROR_INVALID_ARGUMENT\n - @c WEBVIEW_ERROR_INVALID_STATE\n\n With the exception of @c WEBVIEW_ERROR_OK which is normally expected,\n the other common codes do not normally need to be handled specifically.\n Refer to specific functions regarding handling of other codes."]
20pub type webview_error_t = ::std::os::raw::c_int;
21#[doc = " Holds the elements of a MAJOR.MINOR.PATCH version number."]
22#[repr(C)]
23#[derive(Debug, Copy, Clone)]
24pub struct webview_version_t {
25 #[doc = " Major version."]
26 pub major: ::std::os::raw::c_uint,
27 #[doc = " Minor version."]
28 pub minor: ::std::os::raw::c_uint,
29 #[doc = " Patch version."]
30 pub patch: ::std::os::raw::c_uint,
31}
32#[doc = " Holds the library's version information."]
33#[repr(C)]
34#[derive(Debug, Copy, Clone)]
35pub struct webview_version_info_t {
36 #[doc = " The elements of the version number."]
37 pub version: webview_version_t,
38 #[doc = " SemVer 2.0.0 version number in MAJOR.MINOR.PATCH format."]
39 pub version_number: [::std::os::raw::c_char; 32usize],
40 #[doc = " SemVer 2.0.0 pre-release labels prefixed with \"-\" if specified, otherwise\n an empty string."]
41 pub pre_release: [::std::os::raw::c_char; 48usize],
42 #[doc = " SemVer 2.0.0 build metadata prefixed with \"+\", otherwise an empty string."]
43 pub build_metadata: [::std::os::raw::c_char; 48usize],
44}
45#[doc = " Pointer to a webview instance."]
46pub type webview_t = *mut ::std::os::raw::c_void;
47#[doc = " Top-level window. @c GtkWindow pointer (GTK), @c NSWindow pointer (Cocoa)\n or @c HWND (Win32)."]
48pub const webview_native_handle_kind_t_WEBVIEW_NATIVE_HANDLE_KIND_UI_WINDOW:
49 webview_native_handle_kind_t = 0;
50#[doc = " Browser widget. @c GtkWidget pointer (GTK), @c NSView pointer (Cocoa) or\n @c HWND (Win32)."]
51pub const webview_native_handle_kind_t_WEBVIEW_NATIVE_HANDLE_KIND_UI_WIDGET:
52 webview_native_handle_kind_t = 1;
53#[doc = " Browser controller. @c WebKitWebView pointer (WebKitGTK), @c WKWebView\n pointer (Cocoa/WebKit) or @c ICoreWebView2Controller pointer\n (Win32/WebView2)."]
54pub const webview_native_handle_kind_t_WEBVIEW_NATIVE_HANDLE_KIND_BROWSER_CONTROLLER:
55 webview_native_handle_kind_t = 2;
56#[doc = " Native handle kind. The actual type depends on the backend."]
57pub type webview_native_handle_kind_t = ::std::os::raw::c_uint;
58#[doc = " Width and height are default size."]
59pub const webview_hint_t_WEBVIEW_HINT_NONE: webview_hint_t = 0;
60#[doc = " Width and height are minimum bounds."]
61pub const webview_hint_t_WEBVIEW_HINT_MIN: webview_hint_t = 1;
62#[doc = " Width and height are maximum bounds."]
63pub const webview_hint_t_WEBVIEW_HINT_MAX: webview_hint_t = 2;
64#[doc = " Window size can not be changed by a user."]
65pub const webview_hint_t_WEBVIEW_HINT_FIXED: webview_hint_t = 3;
66#[doc = " Window size hints"]
67pub type webview_hint_t = ::std::os::raw::c_uint;
68unsafe extern "C" {
69 #[doc = " Creates a new webview instance.\n\n @param debug Enable developer tools if supported by the backend.\n @param window Optional native window handle, i.e. @c GtkWindow pointer\n @c NSWindow pointer (Cocoa) or @c HWND (Win32). If non-null,\n the webview widget is embedded into the given window, and the\n caller is expected to assume responsibility for the window as\n well as application lifecycle. If the window handle is null,\n a new window is created and both the window and application\n lifecycle are managed by the webview instance.\n @remark Win32: The function also accepts a pointer to @c HWND (Win32) in the\n window parameter for backward compatibility.\n @remark Win32/WebView2: @c CoInitializeEx should be called with\n @c COINIT_APARTMENTTHREADED before attempting to call this function\n with an existing window. Omitting this step may cause WebView2\n initialization to fail.\n @return @c NULL on failure. Creation can fail for various reasons such\n as when required runtime dependencies are missing or when window\n creation fails.\n @retval WEBVIEW_ERROR_MISSING_DEPENDENCY\n May be returned if WebView2 is unavailable on Windows."]
70 pub fn webview_create(
71 debug: ::std::os::raw::c_int,
72 window: *mut ::std::os::raw::c_void,
73 ) -> webview_t;
74}
75unsafe extern "C" {
76 #[doc = " Destroys a webview instance and closes the native window.\n\n @param w The webview instance."]
77 pub fn webview_destroy(w: webview_t) -> webview_error_t;
78}
79unsafe extern "C" {
80 #[doc = " Runs the main loop until it's terminated.\n\n @param w The webview instance."]
81 pub fn webview_run(w: webview_t) -> webview_error_t;
82}
83unsafe extern "C" {
84 #[doc = " Stops the main loop. It is safe to call this function from another\n background thread.\n\n @param w The webview instance."]
85 pub fn webview_terminate(w: webview_t) -> webview_error_t;
86}
87unsafe extern "C" {
88 #[doc = " Schedules a function to be invoked on the thread with the run/event loop.\n\n Since library functions generally do not have thread safety guarantees,\n this function can be used to schedule code to execute on the main/GUI\n thread and thereby make that execution safe in multi-threaded applications.\n\n @param w The webview instance.\n @param fn The function to be invoked.\n @param arg An optional argument passed along to the callback function."]
89 pub fn webview_dispatch(
90 w: webview_t,
91 fn_: ::std::option::Option<
92 unsafe extern "C" fn(w: webview_t, arg: *mut ::std::os::raw::c_void),
93 >,
94 arg: *mut ::std::os::raw::c_void,
95 ) -> webview_error_t;
96}
97unsafe extern "C" {
98 #[doc = " Returns the native handle of the window associated with the webview instance.\n The handle can be a @c GtkWindow pointer (GTK), @c NSWindow pointer (Cocoa)\n or @c HWND (Win32).\n\n @param w The webview instance.\n @return The handle of the native window."]
99 pub fn webview_get_window(w: webview_t) -> *mut ::std::os::raw::c_void;
100}
101unsafe extern "C" {
102 #[doc = " Get a native handle of choice.\n\n @param w The webview instance.\n @param kind The kind of handle to retrieve.\n @return The native handle or @c NULL.\n @since 0.11"]
103 pub fn webview_get_native_handle(
104 w: webview_t,
105 kind: webview_native_handle_kind_t,
106 ) -> *mut ::std::os::raw::c_void;
107}
108unsafe extern "C" {
109 #[doc = " Updates the title of the native window.\n\n @param w The webview instance.\n @param title The new title."]
110 pub fn webview_set_title(w: webview_t, title: *const ::std::os::raw::c_char)
111 -> webview_error_t;
112}
113unsafe extern "C" {
114 #[doc = " Updates the size of the native window.\n\n Remarks:\n - Subsequent calls to this function may behave inconsistently across\n different versions of GTK and windowing systems (X11/Wayland).\n - Using WEBVIEW_HINT_MAX for setting the maximum window size is not\n supported with GTK 4 because X11-specific functions such as\n gtk_window_set_geometry_hints were removed. This option has no effect\n when using GTK 4.\n\n @param w The webview instance.\n @param width New width.\n @param height New height.\n @param hints Size hints."]
115 pub fn webview_set_size(
116 w: webview_t,
117 width: ::std::os::raw::c_int,
118 height: ::std::os::raw::c_int,
119 hints: webview_hint_t,
120 ) -> webview_error_t;
121}
122unsafe extern "C" {
123 #[doc = " Navigates webview to the given URL. URL may be a properly encoded data URI.\n\n Example:\n @code{.c}\n webview_navigate(w, \"https://github.com/webview/webview\");\n webview_navigate(w, \"data:text/html,%3Ch1%3EHello%3C%2Fh1%3E\");\n webview_navigate(w, \"data:text/html;base64,PGgxPkhlbGxvPC9oMT4=\");\n @endcode\n\n @param w The webview instance.\n @param url URL."]
124 pub fn webview_navigate(w: webview_t, url: *const ::std::os::raw::c_char) -> webview_error_t;
125}
126unsafe extern "C" {
127 #[doc = " Load HTML content into the webview.\n\n Example:\n @code{.c}\n webview_set_html(w, \"<h1>Hello</h1>\");\n @endcode\n\n @param w The webview instance.\n @param html HTML content."]
128 pub fn webview_set_html(w: webview_t, html: *const ::std::os::raw::c_char) -> webview_error_t;
129}
130unsafe extern "C" {
131 #[doc = " Injects JavaScript code to be executed immediately upon loading a page.\n The code will be executed before @c window.onload.\n\n @param w The webview instance.\n @param js JS content."]
132 pub fn webview_init(w: webview_t, js: *const ::std::os::raw::c_char) -> webview_error_t;
133}
134unsafe extern "C" {
135 #[doc = " Evaluates arbitrary JavaScript code.\n\n Use bindings if you need to communicate the result of the evaluation.\n\n @param w The webview instance.\n @param js JS content."]
136 pub fn webview_eval(w: webview_t, js: *const ::std::os::raw::c_char) -> webview_error_t;
137}
138unsafe extern "C" {
139 #[doc = " Binds a function pointer to a new global JavaScript function.\n\n Internally, JS glue code is injected to create the JS function by the\n given name. The callback function is passed a request identifier,\n a request string and a user-provided argument. The request string is\n a JSON array of the arguments passed to the JS function.\n\n @param w The webview instance.\n @param name Name of the JS function.\n @param fn Callback function.\n @param arg User argument.\n @retval WEBVIEW_ERROR_DUPLICATE\n A binding already exists with the specified name."]
140 pub fn webview_bind(
141 w: webview_t,
142 name: *const ::std::os::raw::c_char,
143 fn_: ::std::option::Option<
144 unsafe extern "C" fn(
145 id: *const ::std::os::raw::c_char,
146 req: *const ::std::os::raw::c_char,
147 arg: *mut ::std::os::raw::c_void,
148 ),
149 >,
150 arg: *mut ::std::os::raw::c_void,
151 ) -> webview_error_t;
152}
153unsafe extern "C" {
154 #[doc = " Removes a binding created with webview_bind().\n\n @param w The webview instance.\n @param name Name of the binding.\n @retval WEBVIEW_ERROR_NOT_FOUND No binding exists with the specified name."]
155 pub fn webview_unbind(w: webview_t, name: *const ::std::os::raw::c_char) -> webview_error_t;
156}
157unsafe extern "C" {
158 #[doc = " Responds to a binding call from the JS side.\n\n This function is safe to call from another thread.\n\n @param w The webview instance.\n @param id The identifier of the binding call. Pass along the value received\n in the binding handler (see webview_bind()).\n @param status A status of zero tells the JS side that the binding call was\n successful; any other value indicates an error.\n @param result The result of the binding call to be returned to the JS side.\n This must either be a valid JSON value or an empty string for\n the primitive JS value @c undefined."]
159 pub fn webview_return(
160 w: webview_t,
161 id: *const ::std::os::raw::c_char,
162 status: ::std::os::raw::c_int,
163 result: *const ::std::os::raw::c_char,
164 ) -> webview_error_t;
165}
166unsafe extern "C" {
167 #[doc = " Get the library's version information.\n\n @since 0.10"]
168 pub fn webview_version() -> *const webview_version_info_t;
169}