tauri.c 1003 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if defined(WEBVIEW_GTK)
  2. #include "tauri-gtk-webview.h"
  3. #elif defined(WEBVIEW_WINAPI)
  4. #define CINTERFACE
  5. #include "tauri-windows-webview.h"
  6. #elif defined(WEBVIEW_COCOA)
  7. #include "tauri-cocoa-webview.h"
  8. #else
  9. #error "Define one of: WEBVIEW_GTK, WEBVIEW_COCOA or WEBVIEW_WINAPI"
  10. #endif
  11. #define WEBVIEW_IMPLEMENTATION
  12. #include "tauri.h"
  13. void wrapper_webview_free(struct webview* w) {
  14. free(w);
  15. }
  16. struct webview* wrapper_webview_new(const char* title, const char* url, int width, int height, int resizable, int debug, webview_external_invoke_cb_t external_invoke_cb, void* userdata) {
  17. struct webview* w = (struct webview*)calloc(1, sizeof(*w));
  18. w->width = width;
  19. w->height = height;
  20. w->title = title;
  21. w->url = url;
  22. w->resizable = resizable;
  23. w->debug = debug;
  24. w->external_invoke_cb = external_invoke_cb;
  25. w->userdata = userdata;
  26. if (webview_init(w) != 0) {
  27. wrapper_webview_free(w);
  28. return NULL;
  29. }
  30. return w;
  31. }
  32. void* wrapper_webview_get_userdata(struct webview* w) {
  33. return w->userdata;
  34. }