From 6d40ae24374e65b84cb0b27e8dedb39a6d674a95 Mon Sep 17 00:00:00 2001 From: lytico Date: Mon, 19 Jul 2021 18:11:36 +0200 Subject: [PATCH] Samples.csproj: add WebkitGtkSharp - sample --- Source/Samples/Samples.csproj | 1 + .../Sections/Widgets/WebviewSection.cs | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Source/Samples/Sections/Widgets/WebviewSection.cs diff --git a/Source/Samples/Samples.csproj b/Source/Samples/Samples.csproj index a9a1f5291..2e2a7cfe0 100644 --- a/Source/Samples/Samples.csproj +++ b/Source/Samples/Samples.csproj @@ -28,5 +28,6 @@ + diff --git a/Source/Samples/Sections/Widgets/WebviewSection.cs b/Source/Samples/Sections/Widgets/WebviewSection.cs new file mode 100644 index 000000000..22b0e57c2 --- /dev/null +++ b/Source/Samples/Sections/Widgets/WebviewSection.cs @@ -0,0 +1,61 @@ +// This is free and unencumbered software released into the public domain. +// Happy coding!!! - GtkSharp Team + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using Atk; +using Gdk; +using Gtk; +using WebKit; + +namespace Samples +{ + + [Section(ContentType = typeof(WebView), Category = Category.Widgets)] + class WebviewSection : ListSection + { + + public WebviewSection() + { + AddItem(ShowHtml()); + AddItem(ShowUri()); + + } + + public (string, Widget) ShowHtml() + { + var webView = new WebView { + HeightRequest = 100, + Hexpand = true + }; + + webView.LoadString( + $"This is a {nameof(WebView)} showing html text", + "text/html", "UTF-8", null + ); + + return ($"{nameof(WebView)} show html text:", webView); + } + + public (string, Widget) ShowUri() + { + var webView = new WebView {ViewMode = WebViewViewMode.Floating}; + + var scroll = new ScrolledWindow { + Child = webView, + Vexpand = true, + Hexpand = true, + PropagateNaturalHeight = true, + PropagateNaturalWidth = true + }; + + webView.LoadUri("https://github.com/GtkSharp/GtkSharp#readme"); + + return ($"{nameof(WebView)} show uri:", scroll); + } + + } + +} \ No newline at end of file