Skip to content

Commit

Permalink
Add WebKit2
Browse files Browse the repository at this point in the history
  • Loading branch information
badcel committed Jan 19, 2023
1 parent 108c79e commit 9a8c741
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 30 deletions.
24 changes: 16 additions & 8 deletions docs/docs/libraries.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Libraries

Currently there are multiple libraries planned to be integrated deeply into linux: [Gtk], [WebkitGTK], [libshumate] [libadwaita], [GIO], [gstreamer].
Currently there are multiple libraries available to get started with C# development for Linux: [Gtk], [WebkitGTK], [libshumate] [libadwaita], [GIO], [gstreamer].

## GTK
[Gtk] is the toolkit which is used to display windows and widgets on the screen. The widgets can be added directly in code or described through an xml file.
Expand All @@ -9,26 +9,34 @@ Supported widgets are for example: Windows, dialogs, labels, images, spinner, pr

![A picture of an example gtk application][GtkApp]

Visit the [GTK samples](https://github.com/gircore/gir.core/tree/main/src/Samples/Gtk-4.0) to get an overview.

## libadwaita
[libadwaita] extends GTK with new widgets to comply to the GNOME human interface guidelines. Additionally it supports mobile devices meaning full blown applications automatically adopt their UI to different view modes, if the available space changes.

Visit the [libadwaita samples](https://github.com/gircore/gir.core/tree/main/src/Samples/Adw-1/) to get an overview.

## GIO
[GIO] is a library to allow easy access to input / output operations. Currently there is initial support for [DBus] operations. DBus is a standardized IPC-Framework which all major linux desktops use for interprocess communication.

## Gstreamer
[Gstreamer] is a multimedia library to play back various media format via a flexible pipelining system. The code to playback a movie is in the [samples](https://github.com/gircore/gir.core/blob/develop/Samples/GStreamer/Play.cs).
Visit the [GIO samples](https://github.com/gircore/gir.core/tree/main/src/Samples/Gio-2.0/) to get an overview.

## GStreamer
[GStreamer] is a multimedia library to play back various media format via a flexible pipelining system.
![A picture of the Tears of Steel project played via gstreamer][GstSintel]
(Homepage of the free movie: https://mango.blender.org/)

## WebkitGTK (planned)
[WebkitGTK] is a browser component for GTK and can be used to embed the webkit webengine into an application as a widget. There is support for the web inspector and several settings to tweak the webview to your needs.
Visit the [GStreamer samples](https://github.com/gircore/gir.core/tree/main/src/Samples/Gst-1.0/) to get an overview.

## WebKitGTK
[WebKitGTK] is a browser component for GTK and can be used to embed the webkit webengine into an application as a widget. There is support for the web inspector and several settings to tweak the webview to your needs. WebKitGTK only supports Linux.

The bindings make it easy to:
* Embed javascript into a webpage
* Call a javascript function
* Callback from the webpage into the C# code.

![A picture of an example gtk application with visible webpage][GtkAppBrowser]
Visit the [WebKit samples](https://github.com/gircore/gir.core/tree/main/src/Samples/WebKit2-5.0/) to get an overview.

## libshumate (planned)
[libshumate] is map component for GTK and can be used to embed maps into an application widget. By default it uses openstreetmap.
Expand All @@ -37,12 +45,12 @@ The bindings make it easy to:
[GIO]: https://developer.gnome.org/gio/stable/
[libadwaita]: https://gitlab.gnome.org/GNOME/libadwaita
[libshumate]: https://gitlab.gnome.org/GNOME/libshumate/
[WebkitGTK]: https://webkitgtk.org/
[WebKitGTK]: https://webkitgtk.org/
[Gtk]: https://gtk.org
[Gimp]: https://gimp.org
[Gnome]: https://gnome.org
[Xfce]: https://xfce.org
[Gstreamer]: https://gstreamer.freedesktop.org/
[GStreamer]: https://gstreamer.freedesktop.org/

[GtkApp]: img/GtkApp.png "Example GtkApp"
[GstSintel]: img/GstSintel.png "Gstreamer playing back Tears of Steel (https://mango.blender.org/)"
20 changes: 11 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This project aims to provide a complete set of APIs for writing rich cross-platf
* **Extensibility:** Allows 3rd party developers to write bindings for other GObject-based libraries, achieving full interoperability between them.

## Status
We are currently in a period of heavy iteration over the core internals of the project. The code is under heavy development and not ready for production. There are some pre release nuget packages available for testing purposes. Feel free to visit the [nuget organization][GirCoreNuget] to get an overview.
The code is under development and not ready for production use. There are nuget packages available. The API is subject to change as long as version 1.0 is not released. Feel free to visit the [nuget organization][GirCoreNuget] to get an overview.

## Supported Libraries

Expand All @@ -30,8 +30,8 @@ We are currently in a period of heavy iteration over the core internals of the p
| [Gio-2.0][GioNuget] | Library for high level application functionality | Partial |
| [GdkPixbuf-2.0][GdkPixbufNuget] | Image loading in various formats | Partial |
| libshumate | Library to display maps | Planned |
| WebKitGTK | Browser Engine | [Planned](https://github.com/gircore/gir.core/issues/568) |
| JavaScriptCore | JavaScript engine for WebKit | Planned |
| [WebKit2-5.0][WebKit2Nuget] | Browser engine (Linux only) | Partial |
| [JavaScriptCore-5.0][JavaScriptCoreNuget] | JavaScript engine for WebKit (Linux only) | Partial |


## Get Involved
Expand Down Expand Up @@ -72,21 +72,23 @@ The code in the library folder is not complete because most of the code is gener
[GIO]: https://developer.gnome.org/gio/stable/
[GObject]: https://developer.gnome.org/gobject/stable/
[GTK]: https://gtk.org/
[libhandy]: https://source.puri.sm/Librem5/libhandy
[libhandy]: https://source.puri.sm/Librem5/libhandy/
[WebKitGTK]: https://webkitgtk.org/
[JavaScriptCore]: https://webkitgtk.org/reference/jsc-glib/stable/index.html
[dbus]: https://www.freedesktop.org/wiki/Software/dbus/
[libchamplain]: https://wiki.gnome.org/Projects/libchamplain
[GtkSharp]: https://github.com/GtkSharp/GtkSharp
[GdkPixbuf]: https://gitlab.gnome.org/GNOME/gdk-pixbuf
[GirCoreNuget]: https://www.nuget.org/profiles/GirCore
[libchamplain]: https://wiki.gnome.org/Projects/libchamplain/
[GtkSharp]: https://github.com/GtkSharp/GtkSharp/
[GdkPixbuf]: https://gitlab.gnome.org/GNOME/gdk-pixbuf/
[GirCoreNuget]: https://www.nuget.org/profiles/GirCore/
[Gtk4Nuget]: https://www.nuget.org/packages/GirCore.Gtk-4.0/
[GstNuget]: https://www.nuget.org/packages/GirCore.Gst-1.0/
[CairoNuget]: https://www.nuget.org/packages/GirCore.Cairo-1.0/
[PangoNuget]: https://www.nuget.org/packages/GirCore.Pango-1.0/
[GioNuget]: https://www.nuget.org/packages/GirCore.Gio-2.0/
[GdkPixbufNuget]: https://www.nuget.org/packages/GirCore.GdkPixbuf-2.0/
[LibadwaitaNuget]: https://www.nuget.org/packages/GirCore.Adw-1
[LibadwaitaNuget]: https://www.nuget.org/packages/GirCore.Adw-1/
[WebKit2Nuget]: https://www.nuget.org/packages/GirCore.WebKit2-5.0/
[JavaScriptCoreNuget]: https://www.nuget.org/packages/GirCore.JavaScriptCore-5.0/

## Licensing terms
Gir.Core is licensed under the terms of the MIT-License. Please see the [license file](license.txt) for further information.
Expand Down
30 changes: 17 additions & 13 deletions src/GenerateLibs.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ open SimpleExec

let girFiles =
[|
"GLib-2.0.gir"
"GObject-2.0.gir"
"Gio-2.0.gir"
"Adw-1.gir"
"cairo-1.0.gir"
"Pango-1.0.gir"
"HarfBuzz-0.0.gir"
"freetype2-2.0.gir"
"Gdk-4.0.gir"
"GdkPixbuf-2.0.gir"
"Gio-2.0.gir"
"GLib-2.0.gir"
"GObject-2.0.gir"
"Graphene-1.0.gir"
"Gsk-4.0.gir"
"Gst-1.0.gir"
"GstBase-1.0.gir"
"GstVideo-1.0.gir"
"GstAudio-1.0.gir"
"GstBase-1.0.gir"
"GstPbutils-1.0.gir"
"PangoCairo-1.0.gir"
"Gdk-4.0.gir"
"Graphene-1.0.gir"
"Gsk-4.0.gir"
"GstVideo-1.0.gir"
"Gtk-4.0.gir"
"Adw-1.gir"
"freetype2-2.0.gir"
"HarfBuzz-0.0.gir"
"JavaScriptCore-5.0.gir"
"Pango-1.0.gir"
"PangoCairo-1.0.gir"
"Soup-3.0.gir"
"WebKit2-5.0.gir"
"WebKit2WebExtension-5.0.gir"
|]
|> String.concat " "

Expand Down
93 changes: 93 additions & 0 deletions src/GirCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Window", "Samples\Adw-1\Win
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "freetype2-2.0", "Libs\freetype2-2.0\freetype2-2.0.csproj", "{29C4FE32-0609-45EE-9C16-E4E50CA66B81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebKit2-5.0", "Libs\WebKit2-5.0\WebKit2-5.0.csproj", "{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptCore-5.0", "Libs\JavaScriptCore-5.0\JavaScriptCore-5.0.csproj", "{BD15BF89-69FB-494F-890C-7FB9767C4E4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebKit2WebExtension-5.0", "Libs\WebKit2WebExtension-5.0\WebKit2WebExtension-5.0.csproj", "{FA8F1775-0D58-4727-A168-6111773A43A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Soup-3.0", "Libs\Soup-3.0\Soup-3.0.csproj", "{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebKit2-5.0", "WebKit2-5.0", "{825BF602-98A7-45E7-A2C9-9E68160B7DF3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavascriptCall", "Samples\WebKit2-5.0\JavascriptCall\JavascriptCall.csproj", "{9670582B-4E32-48AA-B62B-DA659E6AB4A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavascriptCallback", "Samples\WebKit2-5.0\JavascriptCallback\JavascriptCallback.csproj", "{1AF16CCD-2220-4F60-A68F-622F186BEA8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -694,6 +708,78 @@ Global
{29C4FE32-0609-45EE-9C16-E4E50CA66B81}.Release|x64.Build.0 = Release|Any CPU
{29C4FE32-0609-45EE-9C16-E4E50CA66B81}.Release|x86.ActiveCfg = Release|Any CPU
{29C4FE32-0609-45EE-9C16-E4E50CA66B81}.Release|x86.Build.0 = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|x64.ActiveCfg = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|x64.Build.0 = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|x86.ActiveCfg = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Debug|x86.Build.0 = Debug|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|Any CPU.Build.0 = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|x64.ActiveCfg = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|x64.Build.0 = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|x86.ActiveCfg = Release|Any CPU
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3}.Release|x86.Build.0 = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|x64.ActiveCfg = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|x64.Build.0 = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|x86.ActiveCfg = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Debug|x86.Build.0 = Debug|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|Any CPU.Build.0 = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|x64.ActiveCfg = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|x64.Build.0 = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|x86.ActiveCfg = Release|Any CPU
{BD15BF89-69FB-494F-890C-7FB9767C4E4B}.Release|x86.Build.0 = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|x64.ActiveCfg = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|x64.Build.0 = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|x86.ActiveCfg = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Debug|x86.Build.0 = Debug|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|Any CPU.Build.0 = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|x64.ActiveCfg = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|x64.Build.0 = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|x86.ActiveCfg = Release|Any CPU
{FA8F1775-0D58-4727-A168-6111773A43A3}.Release|x86.Build.0 = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|x64.ActiveCfg = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|x64.Build.0 = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|x86.ActiveCfg = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Debug|x86.Build.0 = Debug|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|Any CPU.Build.0 = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|x64.ActiveCfg = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|x64.Build.0 = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|x86.ActiveCfg = Release|Any CPU
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E}.Release|x86.Build.0 = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|x64.ActiveCfg = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|x64.Build.0 = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Debug|x86.Build.0 = Debug|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|Any CPU.Build.0 = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|x64.ActiveCfg = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|x64.Build.0 = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|x86.ActiveCfg = Release|Any CPU
{9670582B-4E32-48AA-B62B-DA659E6AB4A1}.Release|x86.Build.0 = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|x64.ActiveCfg = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|x64.Build.0 = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|x86.ActiveCfg = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Debug|x86.Build.0 = Debug|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|Any CPU.Build.0 = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|x64.ActiveCfg = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|x64.Build.0 = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|x86.ActiveCfg = Release|Any CPU
{1AF16CCD-2220-4F60-A68F-622F186BEA8F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BF7F9B0B-CB43-4161-BFAD-C6EE479FC86B} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
Expand Down Expand Up @@ -749,5 +835,12 @@ Global
{98F22FA8-3E06-47D0-9516-64BDF61407D6} = {1F2E4087-585C-4B48-8E3D-700D949A15DB}
{3647E5F6-E194-4CAD-B387-948CD90FD5DC} = {98F22FA8-3E06-47D0-9516-64BDF61407D6}
{29C4FE32-0609-45EE-9C16-E4E50CA66B81} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
{E9CC2642-BCA7-4BF6-9AE4-3B03C3A56FB3} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
{BD15BF89-69FB-494F-890C-7FB9767C4E4B} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
{FA8F1775-0D58-4727-A168-6111773A43A3} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
{A464F066-1DA1-4A3C-B79E-2AA4B116D49E} = {386AE10F-B7AC-4C97-AC5C-202D3662A868}
{825BF602-98A7-45E7-A2C9-9E68160B7DF3} = {1F2E4087-585C-4B48-8E3D-700D949A15DB}
{9670582B-4E32-48AA-B62B-DA659E6AB4A1} = {825BF602-98A7-45E7-A2C9-9E68160B7DF3}
{1AF16CCD-2220-4F60-A68F-622F186BEA8F} = {825BF602-98A7-45E7-A2C9-9E68160B7DF3}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions src/Libs/JavaScriptCore-5.0/JavaScriptCore-5.0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\GObject-2.0\GObject-2.0.csproj" />
</ItemGroup>

<PropertyGroup>
<PackageId>GirCore.JavaScriptCore-5.0</PackageId>
<RootNamespace>JavaScriptCore</RootNamespace>
<Description>C# bindings for JavaScriptCore.</Description>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions src/Libs/JavaScriptCore-5.0/Public/Module.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace JavaScriptCore;

public class Module
{
private static bool IsInitialized;

public static void Initialize()
{
if (IsInitialized)
return;

GObject.Module.Initialize();

Internal.ImportResolver.RegisterAsDllImportResolver();
Internal.TypeRegistration.RegisterTypes();

IsInitialized = true;
}
}
19 changes: 19 additions & 0 deletions src/Libs/Soup-3.0/Public/Module.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Soup;

public class Module
{
private static bool IsInitialized;

public static void Initialize()
{
if (IsInitialized)
return;

Gio.Module.Initialize();

Internal.ImportResolver.RegisterAsDllImportResolver();
Internal.TypeRegistration.RegisterTypes();

IsInitialized = true;
}
}
11 changes: 11 additions & 0 deletions src/Libs/Soup-3.0/Soup-3.0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Gio-2.0\Gio-2.0.csproj" />
</ItemGroup>

<PropertyGroup>
<PackageId>GirCore.Soup-3.0</PackageId>
<RootNamespace>Soup</RootNamespace>
<Description>C# bindings for Soup.</Description>
</PropertyGroup>
</Project>
21 changes: 21 additions & 0 deletions src/Libs/WebKit2-5.0/Public/Module.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace WebKit2;

public class Module
{
private static bool IsInitialized;

public static void Initialize()
{
if (IsInitialized)
return;

Gtk.Module.Initialize();
JavaScriptCore.Module.Initialize();
Soup.Module.Initialize();

Internal.ImportResolver.RegisterAsDllImportResolver();
Internal.TypeRegistration.RegisterTypes();

IsInitialized = true;
}
}
27 changes: 27 additions & 0 deletions src/Libs/WebKit2-5.0/Public/UserContentManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace WebKit2;

public partial class UserContentManager
{
//TODO: Is this method obsolete and the users can write it themself?
//As JavaScriptResult is a record this method must be kept as long as public API for records is not generated
public bool RegisterScriptMessageHandler(string name, Action<JavaScriptCore.Value> callback)
{
void OnMessageReceived(UserContentManager obj, ScriptMessageReceivedSignalArgs args)
{
var jsValue = Internal.JavascriptResult.GetJsValue(args.JsResult.Handle);
var value = GObject.Internal.ObjectWrapper.WrapHandle<JavaScriptCore.Value>(jsValue, false);

callback(value);
}

ScriptMessageReceivedSignal.Connect(this, OnMessageReceived, false, name);

if (RegisterScriptMessageHandler(name))
return true;

ScriptMessageReceivedSignal.Disconnect(this, OnMessageReceived);
return false;
}
}
Loading

0 comments on commit 9a8c741

Please sign in to comment.