using GLib;
using KioskApp.Portal.Platforms.Attributes;
using KioskApp.Portal.Widgets;
using WebKit;

namespace KioskApp.Portal.Platforms.Linux.Widgets;

[SupportedOS(SupportedOS.Linux)]
public class WebView : BaseWebView
{
    private WebKit.WebView _webView;

    public override void Resize(int width, int height)
    {
    }

    public override void Navigate(string url)
    {
        _webView.LoadUri(url);
    }

    public override void Dispose()
    {
        _webView.Destroy();
    }

    public override void OnInitialized()
    {
        _webView = new WebKit.WebView();
        var window = GetParentWindow();
        var gtkWindow = window.GetNativeWindow<Gtk.Window>();
        gtkWindow.Add(_webView);

        // (Delegate) value, typeof (CreateArgs)
        _webView.Create += WebViewOnCreate;
    }


    private void WebViewOnCreate(object o, CreateArgs args)
    {
        var req = args.NavigationAction.Request;
        var x = 0;
    }
}