diff options
author | Lluis Sanchez <slluis.devel@gmail.com> | 2014-02-12 22:02:04 +0400 |
---|---|---|
committer | Lluis Sanchez <slluis.devel@gmail.com> | 2014-02-12 22:02:04 +0400 |
commit | abe4fb73b1ca5f16c372ea669f6433ef9855821d (patch) | |
tree | 8610c65c9bbac738cdf08cc2ba427e020863a573 | |
parent | 5a2a4c1f35ab45b0f880e54139a142d3a862334f (diff) | |
parent | ed806630abafcfff787b6ccd76edfc92a27a659f (diff) |
Merge pull request #284 from bratsche/webviewgtkwin32
Webviewgtkwin32
-rw-r--r-- | TestApps/GtkOnMacTest/Program.cs | 1 | ||||
-rw-r--r-- | TestApps/GtkOnWindowsTest/GtkOnWindowsTest.csproj | 62 | ||||
-rw-r--r-- | TestApps/GtkOnWindowsTest/MainWindow.cs | 41 | ||||
-rw-r--r-- | TestApps/GtkOnWindowsTest/Program.cs | 41 | ||||
-rw-r--r-- | TestApps/GtkOnWindowsTest/gtk-gui/gui.stetic | 12 | ||||
-rw-r--r-- | TestApps/Samples/Samples/WebViewSample.cs | 2 | ||||
-rw-r--r-- | Xwt.Gtk.Windows/WebViewBackend.cs | 82 | ||||
-rw-r--r-- | Xwt.Gtk.Windows/WindowsPlatformBackend.cs | 1 | ||||
-rw-r--r-- | Xwt.Gtk.Windows/Xwt.Gtk.Windows.csproj | 3 | ||||
-rw-r--r-- | Xwt.sln | 41 |
10 files changed, 285 insertions, 1 deletions
diff --git a/TestApps/GtkOnMacTest/Program.cs b/TestApps/GtkOnMacTest/Program.cs index 888228d7..163110b5 100644 --- a/TestApps/GtkOnMacTest/Program.cs +++ b/TestApps/GtkOnMacTest/Program.cs @@ -23,6 +23,7 @@ // 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. + using System; using Samples; using Xwt; diff --git a/TestApps/GtkOnWindowsTest/GtkOnWindowsTest.csproj b/TestApps/GtkOnWindowsTest/GtkOnWindowsTest.csproj new file mode 100644 index 00000000..9b8ae327 --- /dev/null +++ b/TestApps/GtkOnWindowsTest/GtkOnWindowsTest.csproj @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>10.0.0</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{C1DF0C90-0C4C-4AB5-A45C-A1805587A844}</ProjectGuid> + <OutputType>WinExe</OutputType> + <RootNamespace>GtkOnWindowsTest</RootNamespace> + <AssemblyName>GtkOnWindowsTest</AssemblyName> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>x86</PlatformTarget> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <DebugType>full</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>x86</PlatformTarget> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="pango-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"> + <SpecificVersion>False</SpecificVersion> + </Reference> + <Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <ProjectReference Include="..\Samples\Samples.csproj"> + <Project>{88C04B85-B69B-47B4-AB9F-64F6DD4E0897}</Project> + <Name>Samples</Name> + </ProjectReference> + <ProjectReference Include="..\..\Xwt\Xwt.csproj"> + <Project>{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}</Project> + <Name>Xwt</Name> + </ProjectReference> + <ProjectReference Include="..\..\Xwt.Gtk\Xwt.Gtk.csproj"> + <Project>{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}</Project> + <Name>Xwt.Gtk</Name> + </ProjectReference> + <ProjectReference Include="..\..\Xwt.Gtk.Windows\Xwt.Gtk.Windows.csproj"> + <Project>{252117CA-0ABB-4F36-BFC8-DE23A8089BB9}</Project> + <Name>Xwt.Gtk.Windows</Name> + </ProjectReference> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/TestApps/GtkOnWindowsTest/MainWindow.cs b/TestApps/GtkOnWindowsTest/MainWindow.cs new file mode 100644 index 00000000..26c75ba0 --- /dev/null +++ b/TestApps/GtkOnWindowsTest/MainWindow.cs @@ -0,0 +1,41 @@ +// +// MainWindow.cs +// +// Author: +// cody <> +// +// Copyright (c) 2014 cody +// +// 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. +using System; +using Gtk; + +public partial class MainWindow: Gtk.Window +{ + public MainWindow () : base (Gtk.WindowType.Toplevel) + { + Build (); + } + + protected void OnDeleteEvent (object sender, DeleteEventArgs a) + { + Application.Quit (); + a.RetVal = true; + } +} diff --git a/TestApps/GtkOnWindowsTest/Program.cs b/TestApps/GtkOnWindowsTest/Program.cs new file mode 100644 index 00000000..4ee12206 --- /dev/null +++ b/TestApps/GtkOnWindowsTest/Program.cs @@ -0,0 +1,41 @@ +// +// Main.cs +// +// Author: +// Cody Russell <cody@xamarin.com> +// +// Copyright (c) 2011 Xamarin Inc. +// +// 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. + +using System; +using Samples; +using Xwt; + +namespace GtkTest +{ + class MainClass + { + [STAThread] + public static void Main (string[] args) + { + App.Run (ToolkitType.Gtk); + } + } +} diff --git a/TestApps/GtkOnWindowsTest/gtk-gui/gui.stetic b/TestApps/GtkOnWindowsTest/gtk-gui/gui.stetic new file mode 100644 index 00000000..8b3d9821 --- /dev/null +++ b/TestApps/GtkOnWindowsTest/gtk-gui/gui.stetic @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<stetic-interface> + <widget class="Gtk.Window" id="MainWindow" design-size="400 300"> + <property name="MemberName" /> + <property name="Title" translatable="yes">MainWindow</property> + <property name="WindowPosition">CenterOnParent</property> + <signal name="DeleteEvent" handler="OnDeleteEvent" /> + <child> + <placeholder /> + </child> + </widget> +</stetic-interface>
\ No newline at end of file diff --git a/TestApps/Samples/Samples/WebViewSample.cs b/TestApps/Samples/Samples/WebViewSample.cs index d6b09180..f35e7205 100644 --- a/TestApps/Samples/Samples/WebViewSample.cs +++ b/TestApps/Samples/Samples/WebViewSample.cs @@ -35,6 +35,8 @@ namespace Samples public WebViewSample () { var wb = new WebView ("http://www.xamarin.com"); + wb.WidthRequest = 600; + wb.HeightRequest = 900; PackStart (wb, true); } } diff --git a/Xwt.Gtk.Windows/WebViewBackend.cs b/Xwt.Gtk.Windows/WebViewBackend.cs new file mode 100644 index 00000000..ea0165b5 --- /dev/null +++ b/Xwt.Gtk.Windows/WebViewBackend.cs @@ -0,0 +1,82 @@ +// +// WebViewBackend.cs +// +// Author: +// Cody Russell <cody@xamarin.com> +// +// Copyright (c) 2014 Xamarin Inc. +// +// 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. + +using System; +using System.Threading; +using System.Runtime.InteropServices; +using SWF = System.Windows.Forms; +using Xwt.GtkBackend; +using Xwt.Backends; +using GTK = Gtk; + +namespace Xwt.Gtk.Windows +{ + public class WebViewBackend : WidgetBackend, IWebViewBackend + { + SWF.WebBrowser view; + string url; + GTK.Socket socket; + + [DllImportAttribute("user32.dll", EntryPoint = "SetParent")] + internal static extern System.IntPtr SetParent([InAttribute] System.IntPtr hwndChild, [InAttribute] System.IntPtr hwndNewParent); + + public override void Initialize () + { + base.Initialize (); + + socket = new GTK.Socket (); + Widget = socket; + + GLib.Timeout.Add (50, delegate { + // We need to wait until after this widget has been parented. + Widget.Realize (); + Widget.Show (); + + var size = new System.Drawing.Size (Widget.WidthRequest, Widget.HeightRequest); + + view = new SWF.WebBrowser (); + view.Size = size; + var browser_handle = view.Handle; + IntPtr window_handle = (IntPtr)socket.Id; + SetParent (browser_handle, window_handle); + if (url != null) + view.Navigate (url); + + return false; + }); + } + + public string Url { + get { return url; } + set { + url = value; + if (view != null) + view.Navigate (url); + } + } + } +} + diff --git a/Xwt.Gtk.Windows/WindowsPlatformBackend.cs b/Xwt.Gtk.Windows/WindowsPlatformBackend.cs index 454f0d9f..8112e1e6 100644 --- a/Xwt.Gtk.Windows/WindowsPlatformBackend.cs +++ b/Xwt.Gtk.Windows/WindowsPlatformBackend.cs @@ -35,6 +35,7 @@ namespace Xwt.Gtk.Windows { base.Initialize (toolit); toolit.RegisterBackend<DesktopBackend, GtkWindowsDesktopBackend> (); + toolit.RegisterBackend<IWebViewBackend, WebViewBackend> (); } } } diff --git a/Xwt.Gtk.Windows/Xwt.Gtk.Windows.csproj b/Xwt.Gtk.Windows/Xwt.Gtk.Windows.csproj index 36f4884c..15a9c4fa 100644 --- a/Xwt.Gtk.Windows/Xwt.Gtk.Windows.csproj +++ b/Xwt.Gtk.Windows/Xwt.Gtk.Windows.csproj @@ -36,6 +36,8 @@ <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f, processorArchitecture=MSIL" /> <Reference Include="System" /> <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> </ItemGroup> <ItemGroup> <Compile Include="Enums.cs" /> @@ -44,6 +46,7 @@ <Compile Include="Structs.cs" /> <Compile Include="Win32.cs" /> <Compile Include="WindowsPlatformBackend.cs" /> + <Compile Include="WebViewBackend.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> @@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkOnMacTest", "TestApps\Gt EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "TestApps\Samples\Samples.csproj", "{88C04B85-B69B-47B4-AB9F-64F6DD4E0897}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkOnWindowsTest", "TestApps\GtkOnWindowsTest\GtkOnWindowsTest.csproj", "{C1DF0C90-0C4C-4AB5-A45C-A1805587A844}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xwt.Gtk.Mac", "Xwt.Gtk.Mac\Xwt.Gtk.Mac.csproj", "{E95833C9-90AA-4366-9262-0A1BED148249}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xwt.Gtk.Windows", "Xwt.Gtk.Windows\Xwt.Gtk.Windows.csproj", "{252117CA-0ABB-4F36-BFC8-DE23A8089BB9}"
@@ -400,6 +402,42 @@ Global {C13CB518-B840-4FE7-AF3D-8C517A2FAD1F}.Win-Debug|Mixed Platforms.Build.0 = Debug|x86
{C13CB518-B840-4FE7-AF3D-8C517A2FAD1F}.Win-Debug|x86.ActiveCfg = Debug|x86
{C13CB518-B840-4FE7-AF3D-8C517A2FAD1F}.Win-Debug|x86.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|Any CPU.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|Any CPU.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|Mixed Platforms.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|Mixed Platforms.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|x86.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.AppStore|x86.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|Any CPU.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|x86.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Debug|x86.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|Any CPU.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|Any CPU.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|Mixed Platforms.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|x86.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Linux-Debug|x86.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|Any CPU.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|Any CPU.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|Mixed Platforms.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|x86.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Mac-Debug|x86.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|Any CPU.ActiveCfg = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|Any CPU.Build.0 = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|Mixed Platforms.Build.0 = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|x86.ActiveCfg = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Release|x86.Build.0 = Release|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|Any CPU.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|Any CPU.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|Mixed Platforms.Build.0 = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|x86.ActiveCfg = Debug|x86
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844}.Win-Debug|x86.Build.0 = Debug|x86
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{C3887A93-B2BD-4097-8E2F-3A063EFF32FD}.AppStore|Mixed Platforms.ActiveCfg = Release|Any CPU
@@ -532,9 +570,10 @@ Global {14CF6E75-0D08-4BBD-B0F5-742196E5656D} = {83D74DDF-581E-4E2A-AE02-F4047A5B96C7}
{5CFB1ABA-0CD0-45B9-ABC5-8A32096C0687} = {83D74DDF-581E-4E2A-AE02-F4047A5B96C7}
{88C04B85-B69B-47B4-AB9F-64F6DD4E0897} = {83D74DDF-581E-4E2A-AE02-F4047A5B96C7}
+ {C1DF0C90-0C4C-4AB5-A45C-A1805587A844} = {83D74DDF-581E-4E2A-AE02-F4047A5B96C7}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = TestApps\GtkOnMacTest\GtkOnMacTest.csproj
+ StartupItem = TestApps\GtkOnWindowsTest\GtkOnWindowsTest.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
|