|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* MIT License
*
* Copyright (c) 2017 Serge Zaitsev
* Copyright (c) 2018 Thomas Chust
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WEBVIEW_H
#define WEBVIEW_H
#if defined(_WIN32)
#if defined(WEBVIEW_GTK) || defined(WEBVIEW_WINAPI)
#define WEBVIEW_API __declspec(dllexport)
#else
#define WEBVIEW_API __declspec(dllimport)
#endif
#else
#define WEBVIEW_API extern
#endif
#include <stddef.h>
typedef struct webview webview_t;
typedef void (*webview_invoke_fn)(webview_t *w, const char *arg);
typedef enum webview_dialog {
WEBVIEW_DIALOG_TYPE_OPEN = 0,
WEBVIEW_DIALOG_TYPE_SAVE = 1,
WEBVIEW_DIALOG_TYPE_ALERT = 2
} webview_dialog_t;
#define WEBVIEW_DIALOG_FLAG_FILE (0 << 0)
#define WEBVIEW_DIALOG_FLAG_DIRECTORY (1 << 0)
#define WEBVIEW_DIALOG_FLAG_INFO (1 << 1)
#define WEBVIEW_DIALOG_FLAG_WARNING (2 << 1)
#define WEBVIEW_DIALOG_FLAG_ERROR (3 << 1)
#define WEBVIEW_DIALOG_FLAG_ALERT_MASK (3 << 1)
typedef void (*webview_dispatch_fn)(webview_t *w, void *arg);
WEBVIEW_API webview_t *webview_new(const char *title, const char *url, int width, int height, int resizable, int debug);
WEBVIEW_API void webview_destroy(webview_t *w);
WEBVIEW_API int webview_loop(webview_t *w, int blocking);
WEBVIEW_API void webview_dispatch(webview_t *w, webview_dispatch_fn fn, void *arg);
WEBVIEW_API void webview_terminate(webview_t *w);
WEBVIEW_API void webview_set_title(webview_t *w, const char *title);
WEBVIEW_API void webview_set_external_invoke_cb(webview_t *w, webview_invoke_fn external_invoke_cb);
WEBVIEW_API void webview_set_fullscreen(webview_t *w, int fullscreen);
WEBVIEW_API int webview_eval(webview_t *w, const char *js);
WEBVIEW_API void webview_dialog(webview_t *w,
webview_dialog_t dlgtype, int flags,
const char *title, const char *arg,
char *result, size_t resultsz);
WEBVIEW_API void webview_print_log(const char *s);
#endif /* WEBVIEW_H */
|