mono-webbrowser is a support module containing browser backends
for Mono.WebBrowser. It currently includes a WebKit backend and will in the future also include the existing Gecko backend (the Mono.Mozilla namespace that currently resides on Mono.WebBrowser). This code can't be in Mono.WebBrowser directly because the webkit backend uses webkit-sharp and gtk, and 1) those libraries are not yet available when Mono.WebBrowser is getting built and 2) this avoids adding hard dependencies on winforms. svn path=/trunk/mono-webbrowser/; revision=118255
This commit is contained in:
Коммит
29f1120541
|
@ -0,0 +1 @@
|
|||
Andreia Gaita <shana@jitted.com>
|
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2008 Novell, Inc. All rights reserved.
|
||||
|
||||
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.
|
|
@ -0,0 +1,10 @@
|
|||
2008-11-08 Andreia Gaita <shana@jitted.com>
|
||||
|
||||
* mono-webbrowser is a support module containing browser
|
||||
backends for Mono.WebBrowser. It currently includes a WebKit backend and
|
||||
will in the future also include the existing Gecko backend (the
|
||||
Mono.Mozilla namespace that currently resides on Mono.WebBrowser). This
|
||||
code can't be in Mono.WebBrowser directly because the webkit backend
|
||||
uses webkit-sharp and gtk, and 1) those libraries are not yet available
|
||||
when Mono.WebBrowser is getting built and 2) this avoids adding hard
|
||||
dependencies on winforms.
|
|
@ -0,0 +1,19 @@
|
|||
SUBDIRS =
|
||||
|
||||
if BUILD_WEBKIT
|
||||
SUBDIRS += mono-webkit
|
||||
endif
|
||||
|
||||
if BUILD_TESTS
|
||||
SUBDIRS += tests
|
||||
endif
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in \
|
||||
aclocal.m4 \
|
||||
configure \
|
||||
config.* \
|
||||
INSTALL \
|
||||
install-sh \
|
||||
missing
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
This package contains a set of browser backends to support Mono.WebBrowser. They are privately GAC'd assemblies
|
||||
used by Mono.WebBrowser directly, and are not meant to be linked to directly (hence no .pc files)
|
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash
|
||||
|
||||
PROJECT=mono-webrowser
|
||||
|
||||
function error () {
|
||||
echo "Error: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function check_autotool_version () {
|
||||
which $1 &>/dev/null || {
|
||||
error "$1 is not installed, and is required to configure $PACKAGE"
|
||||
}
|
||||
|
||||
version=$($1 --version | head -n 1 | cut -f4 -d' ')
|
||||
major=$(echo $version | cut -f1 -d.)
|
||||
minor=$(echo $version | cut -f2 -d.)
|
||||
major_check=$(echo $2 | cut -f1 -d.)
|
||||
minor_check=$(echo $2 | cut -f2 -d.)
|
||||
|
||||
if [ $major -lt $major_check ]; then
|
||||
do_bail=yes
|
||||
elif [[ $minor -lt $minor_check && $major = $major_check ]]; then
|
||||
do_bail=yes
|
||||
fi
|
||||
|
||||
if [ x"$do_bail" = x"yes" ]; then
|
||||
error "$1 version $2 or better is required to configure $PROJECT"
|
||||
fi
|
||||
}
|
||||
|
||||
function run () {
|
||||
echo "Running $@ ..."
|
||||
$@ 2>.autogen.log || {
|
||||
cat .autogen.log 1>&2
|
||||
rm .autogen.log
|
||||
error "Could not run $1, which is required to configure $PROJECT"
|
||||
}
|
||||
rm .autogen.log
|
||||
}
|
||||
|
||||
srcdir=$(dirname $0)
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
(test -f $srcdir/configure.ac) || {
|
||||
error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory"
|
||||
}
|
||||
|
||||
check_autotool_version aclocal 1.9
|
||||
check_autotool_version automake 1.9
|
||||
check_autotool_version autoconf 2.13
|
||||
|
||||
run aclocal -I .
|
||||
run autoconf
|
||||
run automake -a --gnu
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
echo "WARNING: I am going to run configure without any arguments."
|
||||
fi
|
||||
|
||||
run ./configure --enable-maintainer-mode $@
|
|
@ -0,0 +1,119 @@
|
|||
AC_INIT([mono-webbrowser], [0.1.0])
|
||||
AC_PREREQ(2.50)
|
||||
AC_CONFIG_AUX_DIR(.)
|
||||
AM_INIT_AUTOMAKE([1.9 tar-ustar])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS="--disable-docs"
|
||||
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
|
||||
|
||||
API_VERSION="0.5.0.0"
|
||||
POLICY_VERSIONS="1.0 2.0"
|
||||
ASSEMBLY_COMPANY="Novell, Inc."
|
||||
ASSEMBLY_COPYRIGHT="2008 Novell, Inc."
|
||||
ASSEMBLY_PRODUCT="Mono.WebBrowser"
|
||||
MONO_PACKAGE="2.0"
|
||||
|
||||
AC_SUBST(API_VERSION)
|
||||
AC_SUBST(POLICY_VERSIONS)
|
||||
AC_SUBST(ASSEMBLY_COMPANY)
|
||||
AC_SUBST(ASSEMBLY_COPYRIGHT)
|
||||
AC_SUBST(ASSEMBLY_PRODUCT)
|
||||
AC_SUBST(MONO_PACKAGE)
|
||||
|
||||
AC_PATH_PROG(GACUTIL, gacutil, no)
|
||||
if test "x$GACUTIL" = "xno"; then
|
||||
AC_MSG_ERROR([You need to install gacutil])
|
||||
fi
|
||||
GACUTIL_FLAGS=
|
||||
#'-package $(MONO_PACKAGE) -root $(DESTDIR)$(prefix)/lib'
|
||||
GACUTIL_POLICY_FLAGS='-root $(DESTDIR)$(prefix)/lib'
|
||||
AC_SUBST(GACUTIL_FLAGS)
|
||||
AC_SUBST(GACUTIL_POLICY_FLAGS)
|
||||
|
||||
SHAMROCK_CHECK_MONO_MODULE(1.1.10)
|
||||
SHAMROCK_FIND_MONO_2_0_COMPILER
|
||||
SHAMROCK_FIND_MONO_RUNTIME
|
||||
SHAMROCK_CHECK_MONODOC
|
||||
|
||||
|
||||
AC_ARG_ENABLE([webkit],
|
||||
AC_HELP_STRING([--enable-webkit], [Build WebKit backend (default=yes)]),
|
||||
[
|
||||
case "${enableval}" in
|
||||
yes) webkit=yes ;;
|
||||
no) webkit=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-webkit) ;;
|
||||
esac
|
||||
],
|
||||
[webkit=yes]
|
||||
)
|
||||
|
||||
if test ! -d "$srcdir/mono-webkit" ; then
|
||||
if test x"$webkit" = x"yes"; then
|
||||
webkit=no
|
||||
AC_MSG_NOTICE(WebKit backend not available to build)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$webkit = x"yes"; then
|
||||
AC_MSG_NOTICE(Configuring the WebKit backend)
|
||||
WEBKIT_NAME="mono-webkit"
|
||||
WEBKIT_PRODUCT="mono-webkit"
|
||||
WEBKIT_DESCRIPTION="Managed Wrapper for the webkit engine"
|
||||
|
||||
AC_SUBST(WEBKIT_NAME)
|
||||
AC_SUBST(WEBKIT_PRODUCT)
|
||||
AC_SUBST(WEBKIT_DESCRIPTION)
|
||||
|
||||
|
||||
SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES(System Mono.WebBrowser)
|
||||
|
||||
WEBKIT_REFERENCES="-r:System -r:Mono.WebBrowser"
|
||||
AC_SUBST(WEBKIT_REFERENCES)
|
||||
|
||||
PKG_CHECK_MODULES(GTKSHARP, gtk-sharp-2.0 glib-sharp-2.0 glade-sharp-2.0)
|
||||
AC_SUBST(GTKSHARP_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(WEBKITSHARP, webkit-sharp-1.0)
|
||||
AC_SUBST(WEBKITSHARP_LIBS)
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
mono-webkit/Makefile
|
||||
mono-webkit/AssemblyInfo.cs
|
||||
])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_WEBKIT, test x$webkit = xyes)
|
||||
|
||||
AC_ARG_ENABLE([tests],
|
||||
AC_HELP_STRING([--enable-tests], [Build tests (default=yes)]),
|
||||
[
|
||||
case "${enableval}" in
|
||||
yes) tests=yes ;;
|
||||
no) tests=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
|
||||
esac
|
||||
],
|
||||
[tests=yes]
|
||||
)
|
||||
|
||||
if test [ x$tests = x"yes" ]; then
|
||||
AC_CONFIG_FILES([
|
||||
tests/Makefile
|
||||
tests/simple/Makefile
|
||||
])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_TESTS, test x$tests = xyes)
|
||||
|
||||
SHAMROCK_EXPAND_LIBDIR
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
])
|
||||
|
||||
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,11 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("@WEBKIT_NAME@")]
|
||||
[assembly: AssemblyDescription("@WEBKIT_DESCRIPTION@")]
|
||||
[assembly: AssemblyCompany("@ASSEMBLY_COMPANY@")]
|
||||
[assembly: AssemblyCopyright("@ASSEMBLY_COPYRIGHT@")]
|
||||
[assembly: AssemblyProduct("@WEBKIT_PRODUCT@")]
|
||||
[assembly: AssemblyVersion("@API_VERSION@")]
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("@srcdir@/@WEBKIT_NAME@.snk")]
|
|
@ -0,0 +1,3 @@
|
|||
2008-11-08 Andreia Gaita <shana@jitted.com>
|
||||
|
||||
* mono-webkit: mono-webkit is the WebKit backend for Mono.WebBrowser.
|
|
@ -0,0 +1,291 @@
|
|||
// 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.
|
||||
//
|
||||
// Copyright (c) 2008 Novell, Inc.
|
||||
//
|
||||
// Authors:
|
||||
// Andreia Gaita (shana@jitted.com)
|
||||
//
|
||||
|
||||
//#define DEBUG
|
||||
//#define TRACE
|
||||
|
||||
using System;
|
||||
#if NET_2_0
|
||||
using System.Collections.Generic;
|
||||
#else
|
||||
using System.Collections;
|
||||
#endif
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Mono.WebKit
|
||||
{
|
||||
internal class DebugHelper
|
||||
{
|
||||
static DebugHelper () {
|
||||
Debug.AutoFlush = true;
|
||||
}
|
||||
|
||||
struct Data {
|
||||
public MethodBase method;
|
||||
public object[] args;
|
||||
public Data (MethodBase m, object[] a) {
|
||||
this.method = m;
|
||||
this.args = a;
|
||||
}
|
||||
}
|
||||
#if NET_2_0
|
||||
static Stack<Data> methods = new Stack<Data>();
|
||||
#else
|
||||
class DataStack : System.Collections.Stack {
|
||||
public new Data Peek () {
|
||||
return (Data) base.Peek ();
|
||||
}
|
||||
public new Data Pop () {
|
||||
return (Data) base.Pop ();
|
||||
}
|
||||
public DataStack (int initialCapacity) : base (initialCapacity) {}
|
||||
public DataStack () : base () {}
|
||||
public DataStack (ICollection icol) : base (icol) {}
|
||||
}
|
||||
static DataStack methods = new DataStack();
|
||||
#endif
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void DumpCallers () {
|
||||
StackTrace trace = new StackTrace(true);
|
||||
int count = trace.FrameCount;
|
||||
Debug.Indent ();
|
||||
for (int i = 1; i < count; i++) {
|
||||
StackFrame parentFrame = trace.GetFrame(i);
|
||||
MethodBase parentMethod = parentFrame.GetMethod();
|
||||
string file = parentFrame.GetFileName();
|
||||
if (file != null && file.Length > 1)
|
||||
file = file.Substring (file.LastIndexOf (Path.DirectorySeparatorChar) + 1);
|
||||
Debug.WriteLine(parentMethod.DeclaringType.Name + "." + parentMethod.Name +
|
||||
" at " + file + ":" + parentFrame.GetFileLineNumber()
|
||||
);
|
||||
}
|
||||
|
||||
Debug.Unindent ();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void DumpCallers (int count) {
|
||||
StackTrace trace = new StackTrace(true);
|
||||
int c = (count > trace.FrameCount ? trace.FrameCount : count);
|
||||
Debug.Indent ();
|
||||
for (int i = 1; i < c; i++) {
|
||||
StackFrame parentFrame = trace.GetFrame(i);
|
||||
MethodBase parentMethod = parentFrame.GetMethod();
|
||||
string file = parentFrame.GetFileName();
|
||||
if (file != null && file.Length > 1)
|
||||
file = file.Substring (file.LastIndexOf (Path.DirectorySeparatorChar) + 1);
|
||||
Debug.WriteLine(parentMethod.DeclaringType.Name + "." + parentMethod.Name +
|
||||
" at " + file + ":" + parentFrame.GetFileLineNumber()
|
||||
);
|
||||
}
|
||||
|
||||
Debug.Unindent ();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Enter ()
|
||||
{
|
||||
StackTrace trace = new StackTrace();
|
||||
methods.Push (new Data (trace.GetFrame(1).GetMethod(), null));
|
||||
Debug.WriteLine ("Entering " + Current);
|
||||
Debug.Indent ();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Enter (object[] args)
|
||||
{
|
||||
StackTrace trace = new StackTrace();
|
||||
methods.Push (new Data (trace.GetFrame(1).GetMethod(), args));
|
||||
Debug.WriteLine ("Entering " + Current);
|
||||
Debug.Indent ();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Leave ()
|
||||
{
|
||||
if (methods.Count > 0) {
|
||||
|
||||
Debug.Unindent ();
|
||||
Debug.WriteLine ("Leaving " + Current);
|
||||
methods.Pop ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static string Current
|
||||
{
|
||||
get {
|
||||
if (methods.Count == 0)
|
||||
return "";
|
||||
|
||||
Data data = methods.Peek ();
|
||||
return data.method.DeclaringType.Name + "." + data.method.Name;
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Print ()
|
||||
{
|
||||
Debug.WriteLine (Current);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Print (int index)
|
||||
{
|
||||
if (methods.Count == 0 || methods.Count <= index || index < 0)
|
||||
return;
|
||||
|
||||
#if NET_2_0
|
||||
Stack<Data> temp = new Stack<Data>(index-1);
|
||||
#else
|
||||
DataStack temp = new DataStack(index-1);
|
||||
#endif
|
||||
for (int i = 0; i < index; i++)
|
||||
temp.Push (methods.Pop ());
|
||||
|
||||
Data data = methods.Peek ();
|
||||
for (int i = 0; i < temp.Count; i++)
|
||||
methods.Push (temp.Pop());
|
||||
temp = null;
|
||||
|
||||
Debug.WriteLine (data.method.DeclaringType.Name + "." + data.method.Name);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Print (string methodName, string parameterName)
|
||||
{
|
||||
if (methods.Count == 0)
|
||||
return;
|
||||
|
||||
#if NET_2_0
|
||||
Stack<Data> temp = new Stack<Data>();
|
||||
#else
|
||||
DataStack temp = new DataStack();
|
||||
#endif
|
||||
Data data = methods.Peek ();
|
||||
bool foundit = false;
|
||||
for (int i = 0; i < methods.Count; i++)
|
||||
{
|
||||
data = methods.Peek ();
|
||||
if (data.method.Name.Equals (methodName)) {
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
temp.Push (methods.Pop ());
|
||||
}
|
||||
|
||||
for (int i = 0; i < temp.Count; i++)
|
||||
methods.Push (temp.Pop());
|
||||
temp = null;
|
||||
|
||||
if (!foundit)
|
||||
return;
|
||||
|
||||
Debug.WriteLine (data.method.DeclaringType.Name + "." + data.method.Name);
|
||||
ParameterInfo[] pi = data.method.GetParameters ();
|
||||
|
||||
for (int i = 0; i < pi.Length; i++) {
|
||||
if (pi[i].Name == parameterName) {
|
||||
Debug.Indent ();
|
||||
Debug.Write (parameterName + "=");
|
||||
if (pi[i].ParameterType == typeof(IntPtr))
|
||||
Debug.WriteLine (String.Format ("0x{0:x}", ((IntPtr)data.args[i]).ToInt32()));
|
||||
else
|
||||
Debug.WriteLine (data.args[i]);
|
||||
Debug.Unindent ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Print (string parameterName)
|
||||
{
|
||||
if (methods.Count == 0)
|
||||
return;
|
||||
Data data = methods.Peek ();
|
||||
|
||||
ParameterInfo[] pi = data.method.GetParameters ();
|
||||
|
||||
for (int i = 0; i < pi.Length; i++) {
|
||||
if (pi[i].Name == parameterName) {
|
||||
Debug.Indent ();
|
||||
Debug.Write (parameterName + "=");
|
||||
if (pi[i].ParameterType == typeof(IntPtr))
|
||||
Debug.WriteLine (String.Format ("0x{0:x}", data.args[i]));
|
||||
else
|
||||
Debug.WriteLine (data.args[i]);
|
||||
Debug.Unindent ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void WriteLine (object arg)
|
||||
{
|
||||
Debug.WriteLine (arg);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void WriteLine (string format, params object[] arg)
|
||||
{
|
||||
Debug.WriteLine (String.Format (format, arg));
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void WriteLine (string message)
|
||||
{
|
||||
Debug.WriteLine (message);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Indent ()
|
||||
{
|
||||
Debug.Indent ();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Unindent ()
|
||||
{
|
||||
Debug.Unindent ();
|
||||
}
|
||||
|
||||
[Conditional("TRACE")]
|
||||
internal static void TraceWriteLine (string format, params object[] arg)
|
||||
{
|
||||
Debug.WriteLine (String.Format (format, arg));
|
||||
}
|
||||
|
||||
[Conditional("TRACE")]
|
||||
internal static void TraceWriteLine (string message)
|
||||
{
|
||||
Debug.WriteLine (message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
// 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.
|
||||
//
|
||||
// Copyright (c) 2008 Novell, Inc.
|
||||
//
|
||||
// Authors:
|
||||
// Andreia Gaita (shana@jitted.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using Gdk;
|
||||
using Gtk;
|
||||
|
||||
|
||||
namespace Mono.WebKit
|
||||
{
|
||||
internal class EmbedWidget : Gtk.Window
|
||||
{
|
||||
static GLib.GType gtype;
|
||||
IntPtr handle;
|
||||
Widget webview;
|
||||
ScrolledWindow window;
|
||||
|
||||
public EmbedWidget (IntPtr handle, Adjustment h, Adjustment v) : base (Gtk.WindowType.Toplevel)
|
||||
{
|
||||
this.handle = handle;
|
||||
window = new Gtk.ScrolledWindow (h, v);
|
||||
}
|
||||
|
||||
public void Init ()
|
||||
{
|
||||
this.ParentWindow = Gdk.Window.ForeignNewForDisplay (Gdk.Display.Default, (uint)handle.ToInt32 ());
|
||||
Gdk.Color col = new Gdk.Color();
|
||||
Gdk.Color.Parse("White", ref col);
|
||||
this.ModifyBg (Gtk.StateType.Normal, col);
|
||||
|
||||
// this.ButtonPressEvent += delegate (object sender, ButtonPressEventArgs e) {
|
||||
// DebugHelper.WriteLine ("ButtonPress");
|
||||
// };
|
||||
//
|
||||
// this.FocusInEvent += delegate (object sender, FocusInEventArgs e) {
|
||||
// DebugHelper.WriteLine ("FocusInEvent");
|
||||
// };
|
||||
//
|
||||
|
||||
// ((Widget)this).WidgetEvent += delegate (object sender, WidgetEventArgs e) {
|
||||
// DebugHelper.WriteLine ("WidgetEvent " + e.Event.Type);
|
||||
// while (Gtk.Application.EventsPending ())
|
||||
// Gtk.Application.RunIteration ();
|
||||
// };
|
||||
}
|
||||
|
||||
protected override void OnRealized ()
|
||||
{
|
||||
DebugHelper.WriteLine ("OnRealized");
|
||||
|
||||
SetFlag (WidgetFlags.Realized);
|
||||
Gdk.WindowAttr attributes = new WindowAttr();
|
||||
|
||||
attributes.WindowType = Gdk.WindowType.Toplevel;
|
||||
attributes.X = this.Allocation.X;
|
||||
attributes.Y = this.Allocation.Y;
|
||||
attributes.Width = this.Allocation.Width;
|
||||
attributes.Height = this.Allocation.Height;
|
||||
attributes.Wclass = WindowClass.InputOutput;
|
||||
attributes.Visual = this.Visual;
|
||||
attributes.Colormap = this.Colormap;
|
||||
attributes.EventMask = (int)this.Events;
|
||||
|
||||
attributes.EventMask |= (int)(Gdk.EventMask.AllEventsMask);
|
||||
|
||||
this.GdkWindow = new Gdk.Window(this.ParentWindow, attributes,
|
||||
(Gdk.WindowAttributesType.X |
|
||||
Gdk.WindowAttributesType.Y |
|
||||
Gdk.WindowAttributesType.Visual |
|
||||
Gdk.WindowAttributesType.Colormap));
|
||||
this.GdkWindow.UserData = this.Handle;
|
||||
this.Style.Attach (this.GdkWindow);
|
||||
this.Style.SetBackground (this.GdkWindow, StateType.Normal);
|
||||
|
||||
ParentWindow.Events = (Gdk.EventMask) (GdkEventMask.StructureNotifyMask | GdkEventMask.SubstructureNotifyMask);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnMapped ()
|
||||
{
|
||||
DebugHelper.WriteLine ("OnMapped");
|
||||
base.OnMapped ();
|
||||
GdkWindow.Show ();
|
||||
}
|
||||
|
||||
protected override void OnUnmapped ()
|
||||
{
|
||||
DebugHelper.WriteLine ("OnUnmapped");
|
||||
base.OnUnmapped ();
|
||||
GdkWindow.Hide ();
|
||||
}
|
||||
|
||||
protected override void OnUnrealized ()
|
||||
{
|
||||
DebugHelper.WriteLine ("OnUnrealized");
|
||||
base.OnUnrealized ();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnSizeAllocated (Rectangle allocation)
|
||||
{
|
||||
DebugHelper.DumpCallers ();
|
||||
DebugHelper.WriteLine ("OnSizeAllocated");
|
||||
|
||||
if (webview != null && (WidgetFlags & WidgetFlags.Realized) != 0) {
|
||||
|
||||
GdkWindow.MoveResize (allocation);
|
||||
webview.SizeAllocate (allocation);
|
||||
}
|
||||
base.OnSizeAllocated (allocation);
|
||||
}
|
||||
|
||||
protected override void OnAdded (Widget webview)
|
||||
{
|
||||
this.webview = webview;
|
||||
this.window.Add (webview);
|
||||
base.OnAdded (window);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static new GLib.GType Type {
|
||||
get {
|
||||
if (gtype == GLib.GType.Invalid)
|
||||
gtype = RegisterGType (typeof (Widget));
|
||||
return gtype;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
noinst_DATA=$(WEBKIT_NAME).dll
|
||||
|
||||
DIST_SOURCES = \
|
||||
DebugHelper.cs \
|
||||
EmbedWidget.cs \
|
||||
WebBrowser.cs \
|
||||
XEvent.cs
|
||||
|
||||
mono_webkit_sources_in=AssemblyInfo.cs.in
|
||||
mono_webkit_generated_sources=$(mono_webkit_sources_in:.in=)
|
||||
mono_webkit_build_sources = $(addprefix $(srcdir)/, $(DIST_SOURCES))
|
||||
mono_webkit_build_sources += $(mono_webkit_generated_sources)
|
||||
|
||||
mono-webkit.dll: $(mono_webkit_build_sources)
|
||||
$(MCS) -debug -define:DEBUG -target:library -out:$@ $(WEBKIT_REFERENCES) $(GTKSHARP_LIBS) $(WEBKITSHARP_LIBS) $(mono_webkit_build_sources)
|
||||
|
||||
EXTRA_DIST = mono-webkit.snk
|
||||
|
||||
CLEANFILES = *.dll *.mdb
|
||||
|
||||
DISTCLEANFILES = *.pidb $mono_webkit_sources_in
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
noinst_DATA = $(WEBKIT_NAME).dll
|
||||
|
||||
install-data-local:
|
||||
echo "$(GACUTIL) /i $(WEBKIT_NAME).dll /f $(GACUTIL_FLAGS)"; \
|
||||
$(GACUTIL) /i $(WEBKIT_NAME).dll /f $(GACUTIL_FLAGS) || exit 1;
|
||||
|
||||
uninstall-local:
|
||||
echo "$(GACUTIL) /u $(WEBKIT_NAME) $(GACUTIL_FLAGS)"; \
|
||||
$(GACUTIL) /u $(WEBKIT_NAME) $(GACUTIL_FLAGS) || exit 1;
|
|
@ -0,0 +1,514 @@
|
|||
// 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.
|
||||
//
|
||||
// Copyright (c) 2008 Novell, Inc.
|
||||
//
|
||||
// Authors:
|
||||
// Andreia Gaita (shana@jitted.com)
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Mono.WebBrowser;
|
||||
using Mono.WebBrowser.DOM;
|
||||
using webkit=WebKit;
|
||||
|
||||
namespace Mono.WebKit
|
||||
{
|
||||
internal class WebBrowser : IDisposable, IWebBrowser, INavigation
|
||||
{
|
||||
private IntPtr handle;
|
||||
private int width, height;
|
||||
|
||||
internal webkit.WebView webview;
|
||||
internal EmbedWidget widget;
|
||||
private bool disposed = false;
|
||||
private bool initialized = false;
|
||||
private static bool started = false;
|
||||
private static object initLock = new object ();
|
||||
private static int widgetCount = 0;
|
||||
private static object widgetLock = new object ();
|
||||
|
||||
public WebBrowser()
|
||||
{
|
||||
}
|
||||
|
||||
~WebBrowser () {
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
private void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposed) {
|
||||
if (disposing) {
|
||||
lock (widgetLock) {
|
||||
widgetCount--;
|
||||
if (widgetCount == 0) {
|
||||
Gdk.Threads.Enter ();
|
||||
Gtk.Application.Quit ();
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
}
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWebBrowser
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a browser instance.
|
||||
/// </summary>
|
||||
/// <param name="handle">
|
||||
/// A <see cref="IntPtr"/> to the native window handle of the widget
|
||||
/// where the browser engine will draw
|
||||
/// </param>
|
||||
/// <param name="width">
|
||||
/// A <see cref="System.Int32"/>. Initial width
|
||||
/// </param>
|
||||
/// <param name="height">
|
||||
/// A <see cref="System.Int32"/>. Initial height
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A <see cref="System.Boolean"/>
|
||||
/// </returns>
|
||||
public bool Load (IntPtr handle, int width, int height)
|
||||
{
|
||||
this.handle = handle;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
System.Threading.ThreadStart start = delegate () {
|
||||
lock (widgetLock) {
|
||||
if (!GLib.Thread.Supported)
|
||||
GLib.Thread.Init ();
|
||||
Gdk.Threads.Init ();
|
||||
Gtk.Application.Init ();
|
||||
started = true;
|
||||
}
|
||||
Gtk.Application.Run ();
|
||||
};
|
||||
|
||||
lock (initLock) {
|
||||
if (!started) {
|
||||
System.Threading.Thread t = new System.Threading.Thread (start);
|
||||
t.Start ();
|
||||
}
|
||||
}
|
||||
|
||||
while (!initialized) {
|
||||
lock (widgetLock) {
|
||||
if (!started)
|
||||
continue;
|
||||
Gdk.Threads.Enter ();
|
||||
InitializeWindow (null, null);
|
||||
Gdk.Threads.Leave ();
|
||||
widgetCount++;
|
||||
}
|
||||
}
|
||||
// Gdk.Window.DebugUpdates = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InitializeWindow (object _sender, EventArgs ev) {
|
||||
Gtk.Adjustment h = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
|
||||
Gtk.Adjustment v = new Gtk.Adjustment(0, 0, 0, 0, 0, 0);
|
||||
v.Changed += delegate (object sender, EventArgs e) {
|
||||
DebugHelper.WriteLine ("vertical scroll Changed " + v.Value);
|
||||
};
|
||||
v.ValueChanged += delegate (object sender, EventArgs e) {
|
||||
DebugHelper.WriteLine ("vertical scroll ValueChanged " + v.Value);
|
||||
};
|
||||
|
||||
widget = new EmbedWidget(handle, h, v);
|
||||
widget.Unrealized += delegate {
|
||||
Dispose (true);
|
||||
};
|
||||
|
||||
widget.Init ();
|
||||
webview = new webkit.WebView();
|
||||
|
||||
webview.LoadCommitted += delegate (object o, webkit.LoadCommittedArgs args) {
|
||||
};
|
||||
webview.LoadProgressChanged += delegate (object o, webkit.LoadProgressChangedArgs args) {
|
||||
};
|
||||
|
||||
webview.SetScrollAdjustments (h, v);
|
||||
widget.Add (webview);
|
||||
widget.ShowAll ();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
public void Shutdown ()
|
||||
{
|
||||
}
|
||||
public void FocusIn (FocusOption focus)
|
||||
{
|
||||
}
|
||||
public void FocusOut ()
|
||||
{
|
||||
}
|
||||
public void Activate ()
|
||||
{
|
||||
}
|
||||
public void Deactivate ()
|
||||
{
|
||||
}
|
||||
public void Resize (int width, int height)
|
||||
{
|
||||
DebugHelper.WriteLine ("Resizing to " + widget.Allocation.X + " " + widget.Allocation.Y + " " + width + " " + height);
|
||||
|
||||
Gdk.Threads.Enter ();
|
||||
widget.SizeAllocate (new Gdk.Rectangle (widget.Allocation.X, widget.Allocation.Y, width, height));
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
public void Render (byte[] data)
|
||||
{
|
||||
}
|
||||
public void Render (string html)
|
||||
{
|
||||
}
|
||||
public void Render (string html, string uri, string contentType)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Initialized {
|
||||
get { return initialized; }
|
||||
}
|
||||
|
||||
public IWindow Window {
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public IDocument Document {
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public INavigation Navigation {
|
||||
get {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Offline {
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
|
||||
#region Events
|
||||
public event NodeEventHandler KeyDown;
|
||||
public event NodeEventHandler KeyPress;
|
||||
public event NodeEventHandler KeyUp;
|
||||
public event NodeEventHandler MouseClick;
|
||||
public event NodeEventHandler MouseDoubleClick;
|
||||
public event NodeEventHandler MouseDown;
|
||||
public event NodeEventHandler MouseEnter;
|
||||
public event NodeEventHandler MouseLeave;
|
||||
public event NodeEventHandler MouseMove;
|
||||
public event NodeEventHandler MouseUp;
|
||||
public event EventHandler Focus;
|
||||
public event EventHandler Blur;
|
||||
public event CreateNewWindowEventHandler CreateNewWindow;
|
||||
public event AlertEventHandler Alert;
|
||||
public event EventHandler Loaded;
|
||||
public event EventHandler Unloaded;
|
||||
public event StatusChangedEventHandler StatusChanged;
|
||||
public event LoadStartedEventHandler LoadStarted;
|
||||
public event LoadCommitedEventHandler LoadCommited;
|
||||
public event Mono.WebBrowser.ProgressChangedEventHandler ProgressChanged;
|
||||
public event LoadFinishedEventHandler LoadFinished;
|
||||
public event SecurityChangedEventHandler SecurityChanged;
|
||||
public event ContextMenuEventHandler ContextMenuShown;
|
||||
|
||||
void OnKeyDown () {
|
||||
if (KeyDown != null) {
|
||||
KeyDown (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyPress () {
|
||||
if (KeyPress != null) {
|
||||
KeyPress (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnKeyUp () {
|
||||
if (KeyUp != null) {
|
||||
KeyUp (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseClick () {
|
||||
if (MouseClick != null) {
|
||||
MouseClick (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseDoubleClick () {
|
||||
if (MouseDoubleClick != null) {
|
||||
MouseDoubleClick (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseDown () {
|
||||
if (MouseDown != null) {
|
||||
MouseDown (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseEnter () {
|
||||
if (MouseEnter != null) {
|
||||
MouseEnter (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseLeave () {
|
||||
if (MouseLeave != null) {
|
||||
MouseLeave (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseMove () {
|
||||
if (MouseMove != null) {
|
||||
MouseMove (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnMouseUp () {
|
||||
if (MouseUp != null) {
|
||||
MouseUp (this, new NodeEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnFocus () {
|
||||
if (Focus != null) {
|
||||
Focus (this, new EventArgs ());
|
||||
}
|
||||
}
|
||||
void OnBlur () {
|
||||
if (Blur != null) {
|
||||
Blur (this, new EventArgs ());
|
||||
}
|
||||
}
|
||||
void OnCreateNewWindow () {
|
||||
if (CreateNewWindow != null) {
|
||||
CreateNewWindow (this, new CreateNewWindowEventArgs (false));
|
||||
}
|
||||
}
|
||||
void OnAlert () {
|
||||
if (Alert != null) {
|
||||
Alert (this, new AlertEventArgs ());
|
||||
}
|
||||
}
|
||||
void OnLoaded () {
|
||||
if (Loaded != null) {
|
||||
Loaded (this, new EventArgs ());
|
||||
}
|
||||
}
|
||||
void OnUnloaded () {
|
||||
if (Unloaded != null) {
|
||||
Unloaded (this, new EventArgs ());
|
||||
}
|
||||
}
|
||||
void OnStatusChanged (string message, int status) {
|
||||
if (StatusChanged != null) {
|
||||
StatusChanged (this, new StatusChangedEventArgs (message, status));
|
||||
}
|
||||
}
|
||||
void OnLoadStarted (string uri, string frameName) {
|
||||
if (LoadStarted != null) {
|
||||
LoadStarted (this, new LoadStartedEventArgs (uri, frameName));
|
||||
}
|
||||
}
|
||||
void OnLoadCommited (string uri) {
|
||||
if (LoadCommited != null) {
|
||||
LoadCommited (this, new LoadCommitedEventArgs (uri));
|
||||
}
|
||||
}
|
||||
void OnProgressChanged (int progress, int maxProgress) {
|
||||
if (ProgressChanged != null) {
|
||||
ProgressChanged (this, new Mono.WebBrowser.ProgressChangedEventArgs (progress, maxProgress));
|
||||
}
|
||||
}
|
||||
void OnLoadFinished () {
|
||||
if (LoadFinished != null) {
|
||||
LoadFinished (this, new LoadFinishedEventArgs (null));
|
||||
}
|
||||
}
|
||||
void OnSecurityChanged (SecurityLevel state) {
|
||||
if (SecurityChanged != null) {
|
||||
SecurityChanged (this, new SecurityChangedEventArgs (state));
|
||||
}
|
||||
}
|
||||
void OnContextMenuShown () {
|
||||
if (ContextMenuShown != null) {
|
||||
ContextMenuShown (this, new ContextMenuEventArgs (0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region INavigation
|
||||
public bool CanGoBack {
|
||||
get { return webview.CanGoBack ();}
|
||||
}
|
||||
|
||||
public bool CanGoForward {
|
||||
get { return webview.CanGoForward ();}
|
||||
}
|
||||
|
||||
public bool Back () {
|
||||
if (!CanGoBack) return false;
|
||||
Gdk.Threads.Enter ();
|
||||
webview.GoBack ();
|
||||
Gdk.Threads.Leave ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Forward () {
|
||||
if (!CanGoForward) return false;
|
||||
Gdk.Threads.Enter ();
|
||||
webview.GoForward ();
|
||||
Gdk.Threads.Leave ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Home () {
|
||||
}
|
||||
|
||||
public void Reload () {
|
||||
DebugHelper.DumpCallers ();
|
||||
DebugHelper.WriteLine ("Reloading...");
|
||||
|
||||
Gdk.Threads.Enter ();
|
||||
webview.Reload ();
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
// TODO: see if it's possible to reload from cache
|
||||
public void Reload (ReloadOption option) {
|
||||
DebugHelper.DumpCallers ();
|
||||
DebugHelper.WriteLine ("Reloading...");
|
||||
|
||||
Gdk.Threads.Enter ();
|
||||
webview.Reload ();
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
public void Stop () {
|
||||
Gdk.Threads.Enter ();
|
||||
webview.StopLoading ();
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigate to the page in the history, by index.
|
||||
/// </summary>
|
||||
/// <param name="index">
|
||||
/// A <see cref="System.Int32"/> representing an absolute index in the
|
||||
/// history (that is, > -1 and < history length
|
||||
/// </param>
|
||||
public void Go (int index) {
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
|
||||
webkit.WebBackForwardList history = webview.BackForwardList;
|
||||
int len = history.ForwardLength + history.BackLength + 1;
|
||||
if (index > len) {
|
||||
return;
|
||||
}
|
||||
webkit.WebHistoryItem item = history.GetNthItem (index);
|
||||
Gdk.Threads.Enter ();
|
||||
webview.GoToBackForwardItem (item);
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="index">
|
||||
/// A <see cref="System.Int32"/> representing an index in the
|
||||
/// history, that can be relative or absolute depending on the relative argument
|
||||
/// </param>
|
||||
/// <param name="relative">
|
||||
/// A <see cref="System.Boolean"/> indicating whether the index is relative to
|
||||
/// the current place in history or not (i.e., if relative = true, index can be
|
||||
/// positive or negative, and index=-1 means load the previous page in the history.
|
||||
/// if relative = false, index must be > -1, and index = 0 means load the first
|
||||
/// page of the history.
|
||||
/// </param>
|
||||
public void Go (int index, bool relative) {
|
||||
if (!relative)
|
||||
Go (index);
|
||||
else {
|
||||
if (!webview.CanGoBackOrForward (index)) {
|
||||
return;
|
||||
}
|
||||
Gdk.Threads.Enter ();
|
||||
webview.GoBackOrForward (index);
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Navigate to an Url. Uses default loading flags, so the page might come
|
||||
/// from cache
|
||||
/// </summary>
|
||||
/// <param name="url">
|
||||
/// A <see cref="System.String"/> representing an Url
|
||||
/// </param>
|
||||
public void Go (string url) {
|
||||
Gdk.Threads.Enter ();
|
||||
webview.Open (url);
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url">
|
||||
/// A <see cref="System.String"/> representing an Url.
|
||||
/// </param>
|
||||
/// <param name="flags">
|
||||
/// A <see cref="LoadFlags"/> that control if the page comes from cache or not.
|
||||
/// </param>
|
||||
public void Go (string url, LoadFlags flags) {
|
||||
Gdk.Threads.Enter ();
|
||||
webview.Open (url);
|
||||
Gdk.Threads.Leave ();
|
||||
}
|
||||
|
||||
public int HistoryCount {
|
||||
get {
|
||||
webkit.WebBackForwardList history = webview.BackForwardList;
|
||||
return history.ForwardLength + history.BackLength + 1;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,858 @@
|
|||
// 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.
|
||||
//
|
||||
// Copyright (c) 2008 Novell, Inc.
|
||||
//
|
||||
// Authors:
|
||||
// Andreia Gaita (shana@jitted.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mono.WebKit
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XAnyEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XKeyEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr root;
|
||||
internal IntPtr subwindow;
|
||||
internal IntPtr time;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int x_root;
|
||||
internal int y_root;
|
||||
internal int state;
|
||||
internal int keycode;
|
||||
internal bool same_screen;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XButtonEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr root;
|
||||
internal IntPtr subwindow;
|
||||
internal IntPtr time;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int x_root;
|
||||
internal int y_root;
|
||||
internal int state;
|
||||
internal int button;
|
||||
internal bool same_screen;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XMotionEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr root;
|
||||
internal IntPtr subwindow;
|
||||
internal IntPtr time;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int x_root;
|
||||
internal int y_root;
|
||||
internal int state;
|
||||
internal byte is_hint;
|
||||
internal bool same_screen;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XCrossingEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr root;
|
||||
internal IntPtr subwindow;
|
||||
internal IntPtr time;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int x_root;
|
||||
internal int y_root;
|
||||
internal NotifyMode mode;
|
||||
internal NotifyDetail detail;
|
||||
internal bool same_screen;
|
||||
internal bool focus;
|
||||
internal int state;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XFocusChangeEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal int mode;
|
||||
internal NotifyDetail detail;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XKeymapEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal byte key_vector0;
|
||||
internal byte key_vector1;
|
||||
internal byte key_vector2;
|
||||
internal byte key_vector3;
|
||||
internal byte key_vector4;
|
||||
internal byte key_vector5;
|
||||
internal byte key_vector6;
|
||||
internal byte key_vector7;
|
||||
internal byte key_vector8;
|
||||
internal byte key_vector9;
|
||||
internal byte key_vector10;
|
||||
internal byte key_vector11;
|
||||
internal byte key_vector12;
|
||||
internal byte key_vector13;
|
||||
internal byte key_vector14;
|
||||
internal byte key_vector15;
|
||||
internal byte key_vector16;
|
||||
internal byte key_vector17;
|
||||
internal byte key_vector18;
|
||||
internal byte key_vector19;
|
||||
internal byte key_vector20;
|
||||
internal byte key_vector21;
|
||||
internal byte key_vector22;
|
||||
internal byte key_vector23;
|
||||
internal byte key_vector24;
|
||||
internal byte key_vector25;
|
||||
internal byte key_vector26;
|
||||
internal byte key_vector27;
|
||||
internal byte key_vector28;
|
||||
internal byte key_vector29;
|
||||
internal byte key_vector30;
|
||||
internal byte key_vector31;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XExposeEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int width;
|
||||
internal int height;
|
||||
internal int count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XGraphicsExposeEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr drawable;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int width;
|
||||
internal int height;
|
||||
internal int count;
|
||||
internal int major_code;
|
||||
internal int minor_code;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XNoExposeEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr drawable;
|
||||
internal int major_code;
|
||||
internal int minor_code;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XVisibilityEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal int state;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XCreateWindowEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr parent;
|
||||
internal IntPtr window;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int width;
|
||||
internal int height;
|
||||
internal int border_width;
|
||||
internal bool override_redirect;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XDestroyWindowEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XUnmapEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal bool from_configure;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XMapEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal bool override_redirect;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XMapRequestEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr parent;
|
||||
internal IntPtr window;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XReparentEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal IntPtr parent;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal bool override_redirect;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XConfigureEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int width;
|
||||
internal int height;
|
||||
internal int border_width;
|
||||
internal IntPtr above;
|
||||
internal bool override_redirect;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XGravityEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal int x;
|
||||
internal int y;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XResizeRequestEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal int width;
|
||||
internal int height;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XConfigureRequestEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr parent;
|
||||
internal IntPtr window;
|
||||
internal int x;
|
||||
internal int y;
|
||||
internal int width;
|
||||
internal int height;
|
||||
internal int border_width;
|
||||
internal IntPtr above;
|
||||
internal int detail;
|
||||
internal IntPtr value_mask;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XCirculateEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr xevent;
|
||||
internal IntPtr window;
|
||||
internal int place;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XCirculateRequestEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr parent;
|
||||
internal IntPtr window;
|
||||
internal int place;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XPropertyEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr atom;
|
||||
internal IntPtr time;
|
||||
internal int state;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XSelectionClearEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr selection;
|
||||
internal IntPtr time;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XSelectionRequestEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr owner;
|
||||
internal IntPtr requestor;
|
||||
internal IntPtr selection;
|
||||
internal IntPtr target;
|
||||
internal IntPtr property;
|
||||
internal IntPtr time;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XSelectionEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr requestor;
|
||||
internal IntPtr selection;
|
||||
internal IntPtr target;
|
||||
internal IntPtr property;
|
||||
internal IntPtr time;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XColormapEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr colormap;
|
||||
internal bool c_new;
|
||||
internal int state;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XClientMessageEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr message_type;
|
||||
internal int format;
|
||||
internal IntPtr ptr1;
|
||||
internal IntPtr ptr2;
|
||||
internal IntPtr ptr3;
|
||||
internal IntPtr ptr4;
|
||||
internal IntPtr ptr5;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XMappingEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal int request;
|
||||
internal int first_keycode;
|
||||
internal int count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XErrorEvent {
|
||||
internal XEventName type;
|
||||
internal IntPtr display;
|
||||
internal IntPtr resourceid;
|
||||
internal IntPtr serial;
|
||||
internal byte error_code;
|
||||
internal XRequest request_code;
|
||||
internal byte minor_code;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XEventPad {
|
||||
internal IntPtr pad0;
|
||||
internal IntPtr pad1;
|
||||
internal IntPtr pad2;
|
||||
internal IntPtr pad3;
|
||||
internal IntPtr pad4;
|
||||
internal IntPtr pad5;
|
||||
internal IntPtr pad6;
|
||||
internal IntPtr pad7;
|
||||
internal IntPtr pad8;
|
||||
internal IntPtr pad9;
|
||||
internal IntPtr pad10;
|
||||
internal IntPtr pad11;
|
||||
internal IntPtr pad12;
|
||||
internal IntPtr pad13;
|
||||
internal IntPtr pad14;
|
||||
internal IntPtr pad15;
|
||||
internal IntPtr pad16;
|
||||
internal IntPtr pad17;
|
||||
internal IntPtr pad18;
|
||||
internal IntPtr pad19;
|
||||
internal IntPtr pad20;
|
||||
internal IntPtr pad21;
|
||||
internal IntPtr pad22;
|
||||
internal IntPtr pad23;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct XEvent {
|
||||
[ FieldOffset(0) ] internal XEventName type;
|
||||
[ FieldOffset(0) ] internal XAnyEvent AnyEvent;
|
||||
[ FieldOffset(0) ] internal XKeyEvent KeyEvent;
|
||||
[ FieldOffset(0) ] internal XButtonEvent ButtonEvent;
|
||||
[ FieldOffset(0) ] internal XMotionEvent MotionEvent;
|
||||
[ FieldOffset(0) ] internal XCrossingEvent CrossingEvent;
|
||||
[ FieldOffset(0) ] internal XFocusChangeEvent FocusChangeEvent;
|
||||
[ FieldOffset(0) ] internal XExposeEvent ExposeEvent;
|
||||
[ FieldOffset(0) ] internal XGraphicsExposeEvent GraphicsExposeEvent;
|
||||
[ FieldOffset(0) ] internal XNoExposeEvent NoExposeEvent;
|
||||
[ FieldOffset(0) ] internal XVisibilityEvent VisibilityEvent;
|
||||
[ FieldOffset(0) ] internal XCreateWindowEvent CreateWindowEvent;
|
||||
[ FieldOffset(0) ] internal XDestroyWindowEvent DestroyWindowEvent;
|
||||
[ FieldOffset(0) ] internal XUnmapEvent UnmapEvent;
|
||||
[ FieldOffset(0) ] internal XMapEvent MapEvent;
|
||||
[ FieldOffset(0) ] internal XMapRequestEvent MapRequestEvent;
|
||||
[ FieldOffset(0) ] internal XReparentEvent ReparentEvent;
|
||||
[ FieldOffset(0) ] internal XConfigureEvent ConfigureEvent;
|
||||
[ FieldOffset(0) ] internal XGravityEvent GravityEvent;
|
||||
[ FieldOffset(0) ] internal XResizeRequestEvent ResizeRequestEvent;
|
||||
[ FieldOffset(0) ] internal XConfigureRequestEvent ConfigureRequestEvent;
|
||||
[ FieldOffset(0) ] internal XCirculateEvent CirculateEvent;
|
||||
[ FieldOffset(0) ] internal XCirculateRequestEvent CirculateRequestEvent;
|
||||
[ FieldOffset(0) ] internal XPropertyEvent PropertyEvent;
|
||||
[ FieldOffset(0) ] internal XSelectionClearEvent SelectionClearEvent;
|
||||
[ FieldOffset(0) ] internal XSelectionRequestEvent SelectionRequestEvent;
|
||||
[ FieldOffset(0) ] internal XSelectionEvent SelectionEvent;
|
||||
[ FieldOffset(0) ] internal XColormapEvent ColormapEvent;
|
||||
[ FieldOffset(0) ] internal XClientMessageEvent ClientMessageEvent;
|
||||
[ FieldOffset(0) ] internal XMappingEvent MappingEvent;
|
||||
[ FieldOffset(0) ] internal XErrorEvent ErrorEvent;
|
||||
[ FieldOffset(0) ] internal XKeymapEvent KeymapEvent;
|
||||
|
||||
//[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=24)]
|
||||
//[ FieldOffset(0) ] internal int[] pad;
|
||||
[ FieldOffset(0) ] internal XEventPad Pad;
|
||||
public override string ToString() {
|
||||
switch (type)
|
||||
{
|
||||
case XEventName.ButtonPress:
|
||||
case XEventName.ButtonRelease:
|
||||
return ToString (ButtonEvent);
|
||||
case XEventName.CirculateNotify:
|
||||
case XEventName.CirculateRequest:
|
||||
return ToString (CirculateEvent);
|
||||
case XEventName.ClientMessage:
|
||||
return ToString (ClientMessageEvent);
|
||||
case XEventName.ColormapNotify:
|
||||
return ToString (ColormapEvent);
|
||||
case XEventName.ConfigureNotify:
|
||||
return ToString (ConfigureEvent);
|
||||
case XEventName.ConfigureRequest:
|
||||
return ToString (ConfigureRequestEvent);
|
||||
case XEventName.CreateNotify:
|
||||
return ToString (CreateWindowEvent);
|
||||
case XEventName.DestroyNotify:
|
||||
return ToString (DestroyWindowEvent);
|
||||
case XEventName.Expose:
|
||||
return ToString (ExposeEvent);
|
||||
case XEventName.FocusIn:
|
||||
case XEventName.FocusOut:
|
||||
return ToString (FocusChangeEvent);
|
||||
case XEventName.GraphicsExpose:
|
||||
return ToString (GraphicsExposeEvent);
|
||||
case XEventName.GravityNotify:
|
||||
return ToString (GravityEvent);
|
||||
case XEventName.KeymapNotify:
|
||||
return ToString (KeymapEvent);
|
||||
case XEventName.MapNotify:
|
||||
return ToString (MapEvent);
|
||||
case XEventName.MappingNotify:
|
||||
return ToString (MappingEvent);
|
||||
case XEventName.MapRequest:
|
||||
return ToString (MapRequestEvent);
|
||||
case XEventName.MotionNotify:
|
||||
return ToString (MotionEvent);
|
||||
case XEventName.NoExpose:
|
||||
return ToString (NoExposeEvent);
|
||||
case XEventName.PropertyNotify:
|
||||
return ToString (PropertyEvent);
|
||||
case XEventName.ReparentNotify:
|
||||
return ToString (ReparentEvent);
|
||||
case XEventName.ResizeRequest:
|
||||
return ToString (ResizeRequestEvent);
|
||||
case XEventName.SelectionClear:
|
||||
return ToString (SelectionClearEvent);
|
||||
case XEventName.SelectionNotify:
|
||||
return ToString (SelectionEvent);
|
||||
case XEventName.SelectionRequest:
|
||||
return ToString (SelectionRequestEvent);
|
||||
case XEventName.UnmapNotify:
|
||||
return ToString (UnmapEvent);
|
||||
case XEventName.VisibilityNotify:
|
||||
return ToString (VisibilityEvent);
|
||||
case XEventName.EnterNotify:
|
||||
case XEventName.LeaveNotify:
|
||||
return ToString (CrossingEvent);
|
||||
default:
|
||||
return type.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToString (object ev)
|
||||
{
|
||||
string result = string.Empty;
|
||||
Type type = ev.GetType ();
|
||||
System.Reflection.FieldInfo [] fields = type.GetFields (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance);
|
||||
for (int i = 0; i < fields.Length; i++) {
|
||||
if (result != string.Empty) {
|
||||
result += ", ";
|
||||
}
|
||||
object value = fields [i].GetValue (ev);
|
||||
if (fields[i].FieldType == typeof(IntPtr))
|
||||
result += String.Format (fields [i].Name + "= 0x{0:x}", (value == null ? 0 : ((IntPtr)value).ToInt32()));
|
||||
else
|
||||
result += fields [i].Name + "=" + (value == null ? "<null>" : value.ToString ());
|
||||
}
|
||||
return type.Name + " (" + result + ")";
|
||||
}
|
||||
}
|
||||
|
||||
internal enum XEventName {
|
||||
KeyPress = 2,
|
||||
KeyRelease = 3,
|
||||
ButtonPress = 4,
|
||||
ButtonRelease = 5,
|
||||
MotionNotify = 6,
|
||||
EnterNotify = 7,
|
||||
LeaveNotify = 8,
|
||||
FocusIn = 9,
|
||||
FocusOut = 10,
|
||||
KeymapNotify = 11,
|
||||
Expose = 12,
|
||||
GraphicsExpose = 13,
|
||||
NoExpose = 14,
|
||||
VisibilityNotify = 15,
|
||||
CreateNotify = 16,
|
||||
DestroyNotify = 17,
|
||||
UnmapNotify = 18,
|
||||
MapNotify = 19,
|
||||
MapRequest = 20,
|
||||
ReparentNotify = 21,
|
||||
ConfigureNotify = 22,
|
||||
ConfigureRequest = 23,
|
||||
GravityNotify = 24,
|
||||
ResizeRequest = 25,
|
||||
CirculateNotify = 26,
|
||||
CirculateRequest = 27,
|
||||
PropertyNotify = 28,
|
||||
SelectionClear = 29,
|
||||
SelectionRequest = 30,
|
||||
SelectionNotify = 31,
|
||||
ColormapNotify = 32,
|
||||
ClientMessage = 33,
|
||||
MappingNotify = 34,
|
||||
|
||||
LASTEvent
|
||||
}
|
||||
|
||||
internal enum NotifyMode {
|
||||
NotifyNormal = 0,
|
||||
NotifyGrab = 1,
|
||||
NotifyUngrab = 2
|
||||
}
|
||||
|
||||
internal enum NotifyDetail {
|
||||
NotifyAncestor = 0,
|
||||
NotifyVirtual = 1,
|
||||
NotifyInferior = 2,
|
||||
NotifyNonlinear = 3,
|
||||
NotifyNonlinearVirtual = 4,
|
||||
NotifyPointer = 5,
|
||||
NotifyPointerRoot = 6,
|
||||
NotifyDetailNone = 7
|
||||
}
|
||||
|
||||
internal enum XRequest : byte {
|
||||
X_CreateWindow = 1,
|
||||
X_ChangeWindowAttributes = 2,
|
||||
X_GetWindowAttributes = 3,
|
||||
X_DestroyWindow = 4,
|
||||
X_DestroySubwindows = 5,
|
||||
X_ChangeSaveSet = 6,
|
||||
X_ReparentWindow = 7,
|
||||
X_MapWindow = 8,
|
||||
X_MapSubwindows = 9,
|
||||
X_UnmapWindow = 10,
|
||||
X_UnmapSubwindows = 11,
|
||||
X_ConfigureWindow = 12,
|
||||
X_CirculateWindow = 13,
|
||||
X_GetGeometry = 14,
|
||||
X_QueryTree = 15,
|
||||
X_InternAtom = 16,
|
||||
X_GetAtomName = 17,
|
||||
X_ChangeProperty = 18,
|
||||
X_DeleteProperty = 19,
|
||||
X_GetProperty = 20,
|
||||
X_ListProperties = 21,
|
||||
X_SetSelectionOwner = 22,
|
||||
X_GetSelectionOwner = 23,
|
||||
X_ConvertSelection = 24,
|
||||
X_SendEvent = 25,
|
||||
X_GrabPointer = 26,
|
||||
X_UngrabPointer = 27,
|
||||
X_GrabButton = 28,
|
||||
X_UngrabButton = 29,
|
||||
X_ChangeActivePointerGrab = 30,
|
||||
X_GrabKeyboard = 31,
|
||||
X_UngrabKeyboard = 32,
|
||||
X_GrabKey = 33,
|
||||
X_UngrabKey = 34,
|
||||
X_AllowEvents = 35,
|
||||
X_GrabServer = 36,
|
||||
X_UngrabServer = 37,
|
||||
X_QueryPointer = 38,
|
||||
X_GetMotionEvents = 39,
|
||||
X_TranslateCoords = 40,
|
||||
X_WarpPointer = 41,
|
||||
X_SetInputFocus = 42,
|
||||
X_GetInputFocus = 43,
|
||||
X_QueryKeymap = 44,
|
||||
X_OpenFont = 45,
|
||||
X_CloseFont = 46,
|
||||
X_QueryFont = 47,
|
||||
X_QueryTextExtents = 48,
|
||||
X_ListFonts = 49,
|
||||
X_ListFontsWithInfo = 50,
|
||||
X_SetFontPath = 51,
|
||||
X_GetFontPath = 52,
|
||||
X_CreatePixmap = 53,
|
||||
X_FreePixmap = 54,
|
||||
X_CreateGC = 55,
|
||||
X_ChangeGC = 56,
|
||||
X_CopyGC = 57,
|
||||
X_SetDashes = 58,
|
||||
X_SetClipRectangles = 59,
|
||||
X_FreeGC = 60,
|
||||
X_ClearArea = 61,
|
||||
X_CopyArea = 62,
|
||||
X_CopyPlane = 63,
|
||||
X_PolyPoint = 64,
|
||||
X_PolyLine = 65,
|
||||
X_PolySegment = 66,
|
||||
X_PolyRectangle = 67,
|
||||
X_PolyArc = 68,
|
||||
X_FillPoly = 69,
|
||||
X_PolyFillRectangle = 70,
|
||||
X_PolyFillArc = 71,
|
||||
X_PutImage = 72,
|
||||
X_GetImage = 73,
|
||||
X_PolyText8 = 74,
|
||||
X_PolyText16 = 75,
|
||||
X_ImageText8 = 76,
|
||||
X_ImageText16 = 77,
|
||||
X_CreateColormap = 78,
|
||||
X_FreeColormap = 79,
|
||||
X_CopyColormapAndFree = 80,
|
||||
X_InstallColormap = 81,
|
||||
X_UninstallColormap = 82,
|
||||
X_ListInstalledColormaps = 83,
|
||||
X_AllocColor = 84,
|
||||
X_AllocNamedColor = 85,
|
||||
X_AllocColorCells = 86,
|
||||
X_AllocColorPlanes = 87,
|
||||
X_FreeColors = 88,
|
||||
X_StoreColors = 89,
|
||||
X_StoreNamedColor = 90,
|
||||
X_QueryColors = 91,
|
||||
X_LookupColor = 92,
|
||||
X_CreateCursor = 93,
|
||||
X_CreateGlyphCursor = 94,
|
||||
X_FreeCursor = 95,
|
||||
X_RecolorCursor = 96,
|
||||
X_QueryBestSize = 97,
|
||||
X_QueryExtension = 98,
|
||||
X_ListExtensions = 99,
|
||||
X_ChangeKeyboardMapping = 100,
|
||||
X_GetKeyboardMapping = 101,
|
||||
X_ChangeKeyboardControl = 102,
|
||||
X_GetKeyboardControl = 103,
|
||||
X_Bell = 104,
|
||||
X_ChangePointerControl = 105,
|
||||
X_GetPointerControl = 106,
|
||||
X_SetScreenSaver = 107,
|
||||
X_GetScreenSaver = 108,
|
||||
X_ChangeHosts = 109,
|
||||
X_ListHosts = 110,
|
||||
X_SetAccessControl = 111,
|
||||
X_SetCloseDownMode = 112,
|
||||
X_KillClient = 113,
|
||||
X_RotateProperties = 114,
|
||||
X_ForceScreenSaver = 115,
|
||||
X_SetPointerMapping = 116,
|
||||
X_GetPointerMapping = 117,
|
||||
X_SetModifierMapping = 118,
|
||||
X_GetModifierMapping = 119,
|
||||
X_NoOperation = 127
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum EventMask {
|
||||
NoEventMask = 0,
|
||||
KeyPressMask = 1<<0,
|
||||
KeyReleaseMask = 1<<1,
|
||||
ButtonPressMask = 1<<2,
|
||||
ButtonReleaseMask = 1<<3,
|
||||
EnterWindowMask = 1<<4,
|
||||
LeaveWindowMask = 1<<5,
|
||||
PointerMotionMask = 1<<6,
|
||||
PointerMotionHintMask = 1<<7,
|
||||
Button1MotionMask = 1<<8,
|
||||
Button2MotionMask = 1<<9,
|
||||
Button3MotionMask = 1<<10,
|
||||
Button4MotionMask = 1<<11,
|
||||
Button5MotionMask = 1<<12,
|
||||
ButtonMotionMask = 1<<13,
|
||||
KeymapStateMask = 1<<14,
|
||||
ExposureMask = 1<<15,
|
||||
VisibilityChangeMask = 1<<16,
|
||||
StructureNotifyMask = 1<<17,
|
||||
ResizeRedirectMask = 1<<18,
|
||||
SubstructureNotifyMask = 1<<19,
|
||||
SubstructureRedirectMask= 1<<20,
|
||||
FocusChangeMask = 1<<21,
|
||||
PropertyChangeMask = 1<<22,
|
||||
ColormapChangeMask = 1<<23,
|
||||
OwnerGrabButtonMask = 1<<24
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum GdkEventMask {
|
||||
ExposureMask = EventMask.ExposureMask,
|
||||
PointerMotionMask = EventMask.PointerMotionMask,
|
||||
PointerMotionHintMask = EventMask.PointerMotionHintMask,
|
||||
ButtonMotionMask = EventMask.ButtonMotionMask,
|
||||
Button1MotionMask = EventMask.Button1MotionMask,
|
||||
Button2MotionMask = EventMask.Button2MotionMask,
|
||||
Button3MotionMask = EventMask.Button3MotionMask,
|
||||
ButtonPressMask = EventMask.ButtonPressMask,
|
||||
ButtonReleaseMask = EventMask.ButtonReleaseMask,
|
||||
KeyPressMask = EventMask.KeyPressMask,
|
||||
KeyReleaseMask = EventMask.KeyReleaseMask,
|
||||
EnterWindowMask = EventMask.EnterWindowMask,
|
||||
LeaveWindowMask = EventMask.LeaveWindowMask,
|
||||
FocusChangeMask = EventMask.FocusChangeMask,
|
||||
StructureNotifyMask = EventMask.StructureNotifyMask,
|
||||
PropertyChangeMask = EventMask.PropertyChangeMask,
|
||||
VisibilityChangeMask = EventMask.VisibilityChangeMask,
|
||||
PROXIMITY_IN = 0,
|
||||
PROXIMTY_OUT = 0,
|
||||
SubstructureNotifyMask = EventMask.SubstructureNotifyMask,
|
||||
ButtonPressMask2 = EventMask.ButtonPressMask
|
||||
}
|
||||
}
|
Двоичный файл не отображается.
|
@ -0,0 +1,102 @@
|
|||
AC_DEFUN([SHAMROCK_EXPAND_LIBDIR],
|
||||
[
|
||||
expanded_libdir=`(
|
||||
case $prefix in
|
||||
NONE) prefix=$ac_default_prefix ;;
|
||||
*) ;;
|
||||
esac
|
||||
case $exec_prefix in
|
||||
NONE) exec_prefix=$prefix ;;
|
||||
*) ;;
|
||||
esac
|
||||
eval echo $libdir
|
||||
)`
|
||||
AC_SUBST(expanded_libdir)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_FIND_PROGRAM],
|
||||
[
|
||||
AC_PATH_PROG($1, $2, $3)
|
||||
AC_SUBST($1)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_FIND_PROGRAM_OR_BAIL],
|
||||
[
|
||||
SHAMROCK_FIND_PROGRAM($1, $2, no)
|
||||
if test "x$1" = "xno"; then
|
||||
AC_MSG_ERROR([You need to install '$2'])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_FIND_MONO_1_0_COMPILER],
|
||||
[
|
||||
SHAMROCK_FIND_PROGRAM_OR_BAIL(MCS, mcs)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_FIND_MONO_2_0_COMPILER],
|
||||
[
|
||||
SHAMROCK_FIND_PROGRAM_OR_BAIL(MCS, gmcs)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_FIND_MONO_RUNTIME],
|
||||
[
|
||||
SHAMROCK_FIND_PROGRAM_OR_BAIL(MONO, mono)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_CHECK_MONO_MODULE],
|
||||
[
|
||||
PKG_CHECK_MODULES(MONO_MODULE, mono >= $1)
|
||||
])
|
||||
|
||||
AC_DEFUN([_SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES],
|
||||
[
|
||||
for asm in $(echo "$*" | cut -d, -f2- | sed 's/\,/ /g')
|
||||
do
|
||||
AC_MSG_CHECKING([for Mono $1 GAC for $asm.dll])
|
||||
if test \
|
||||
-e "$($PKG_CONFIG --variable=libdir mono)/mono/$1/$asm.dll" -o \
|
||||
-e "$($PKG_CONFIG --variable=prefix mono)/lib/mono/$1/$asm.dll"; \
|
||||
then \
|
||||
AC_MSG_RESULT([found])
|
||||
else
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([missing reqired Mono $1 assembly: $asm.dll])
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_CHECK_MONO_1_0_GAC_ASSEMBLIES],
|
||||
[
|
||||
_SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES(1.0, $*)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES],
|
||||
[
|
||||
_SHAMROCK_CHECK_MONO_GAC_ASSEMBLIES(2.0, $*)
|
||||
])
|
||||
|
||||
AC_DEFUN([SHAMROCK_CHECK_MONODOC],
|
||||
[
|
||||
AC_ARG_ENABLE(docs, AC_HELP_STRING([--disable-docs],
|
||||
[Do not build documentation]), , enable_docs=yes)
|
||||
|
||||
if test "x$enable_docs" = "xyes"; then
|
||||
AC_PATH_PROG(MONODOCER, monodocer, no)
|
||||
if test "x$MONODOCER" = "xno"; then
|
||||
AC_MSG_ERROR([You need to install monodoc, or pass --disable-docs to configure to skip documentation installation])
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(MDASSEMBLER, mdassembler, no)
|
||||
if test "x$MDASSEMBLER" = "xno"; then
|
||||
AC_MSG_ERROR([You need to install mdassembler, or pass --disable-docs to configure to skip documentation installation])
|
||||
fi
|
||||
|
||||
DOCDIR=`$PKG_CONFIG monodoc --variable=sourcesdir`
|
||||
AC_SUBST(DOCDIR)
|
||||
AM_CONDITIONAL(BUILD_DOCS, true)
|
||||
else
|
||||
AC_MSG_NOTICE([not building API documentation])
|
||||
AM_CONDITIONAL(BUILD_DOCS, false)
|
||||
fi
|
||||
])
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SUBDIRS = simple
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
|
@ -0,0 +1,17 @@
|
|||
noinst_DATA = browser.exe
|
||||
|
||||
DIST_SOURCES = browser.cs
|
||||
|
||||
simple_sources_in=
|
||||
simple_generated_sources=$(simple_sources_in:.in=)
|
||||
simple_build_sources = $(addprefix $(srcdir)/, $(DIST_SOURCES))
|
||||
simple_build_sources += $(simple_generated_sources)
|
||||
|
||||
browser.exe: $(simple_build_sources)
|
||||
$(MCS) -debug -target:winexe -out:$@ -pkg:dotnet $(simple_build_sources)
|
||||
|
||||
CLEANFILES = *.exe *.mdb
|
||||
|
||||
DISTCLEANFILES = *.pidb $simple_sources_in
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace tests.simple {
|
||||
|
||||
public class browser : Form {
|
||||
public static void Main () {
|
||||
Application.Run (new browser ());
|
||||
}
|
||||
|
||||
WebBrowser webbrowser;
|
||||
public browser () {
|
||||
webbrowser = new WebBrowser ();
|
||||
webbrowser.Dock = DockStyle.Fill;
|
||||
|
||||
this.Controls.Add (webbrowser);
|
||||
webbrowser.Navigate ("http://www.google.com");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Загрузка…
Ссылка в новой задаче