2008-02-29 Mike Kestner <mkestner@novell.com>
* configure.in.in: atk checks and SUBSTs. * atk/Util.custom: custom properties for overriding class methods. * atk/glue/util.c: glue to override class methods. svn path=/trunk/gtk-sharp/; revision=96985
This commit is contained in:
parent
80d977610f
commit
cc746fa93e
5 changed files with 345 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
#SUBDIRS = . glue
|
||||
SUBDIRS = . glue
|
||||
|
||||
pkg = atk
|
||||
METADATA = Atk.metadata
|
||||
|
@ -7,7 +7,8 @@ references = ../glib/glib-sharp.dll
|
|||
|
||||
sources =
|
||||
|
||||
customs =
|
||||
customs = \
|
||||
Util.custom
|
||||
|
||||
add_dist = makefile.win32
|
||||
|
||||
|
|
240
atk/Util.custom
Normal file
240
atk/Util.custom
Normal file
|
@ -0,0 +1,240 @@
|
|||
// Util.custom - Atk Util class customizations
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@novell.com>
|
||||
//
|
||||
// Copyright (c) 2008 Novell, Inc.
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the Lesser GNU General
|
||||
// Public License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate void RemoveListenerNativeDelegate (uint listener_id);
|
||||
|
||||
static RemoveListenerDelegate remove_global_event_listener_handler;
|
||||
static RemoveListenerNativeDelegate remove_global_event_listener_callback;
|
||||
|
||||
static void RemoveGlobalEventListenerCallback (uint listener_id)
|
||||
{
|
||||
try {
|
||||
remove_global_event_listener_handler (listener_id);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_remove_global_event_listener (RemoveListenerNativeDelegate cb);
|
||||
|
||||
public delegate void RemoveListenerDelegate (uint listener_id);
|
||||
|
||||
public static RemoveListenerDelegate RemoveGlobalEventListenerHandler {
|
||||
set {
|
||||
remove_global_event_listener_handler = value;
|
||||
if (remove_global_event_listener_callback == null)
|
||||
remove_global_event_listener_callback = new RemoveListenerNativeDelegate (RemoveGlobalEventListenerCallback);
|
||||
atksharp_util_override_remove_global_event_listener (remove_global_event_listener_callback);
|
||||
}
|
||||
}
|
||||
|
||||
class KeySnoopFuncInvoker {
|
||||
|
||||
AtkSharp.KeySnoopFuncNative native_cb;
|
||||
IntPtr data;
|
||||
|
||||
internal KeySnoopFuncInvoker (AtkSharp.KeySnoopFuncNative native_cb, IntPtr data)
|
||||
{
|
||||
this.native_cb = native_cb;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
internal KeySnoopFunc Handler {
|
||||
get {
|
||||
return new KeySnoopFunc (InvokeNative);
|
||||
}
|
||||
}
|
||||
|
||||
int InvokeNative (KeyEventStruct evnt)
|
||||
{
|
||||
IntPtr native_evnt = GLib.Marshaller.StructureToPtrAlloc (evnt);
|
||||
int result = native_cb (native_evnt, data);
|
||||
evnt = KeyEventStruct.New (native_evnt);
|
||||
Marshal.FreeHGlobal (native_evnt);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate uint AddKeyEventListenerNativeDelegate (AtkSharp.KeySnoopFuncNative native_func, IntPtr data);
|
||||
|
||||
static AddKeyEventListenerDelegate add_key_event_listener_handler;
|
||||
static AddKeyEventListenerNativeDelegate add_key_event_listener_callback;
|
||||
|
||||
static uint AddKeyEventListenerCallback (AtkSharp.KeySnoopFuncNative func, IntPtr data)
|
||||
{
|
||||
try {
|
||||
return add_key_event_listener_handler (new KeySnoopFuncInvoker (func, data).Handler);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_add_key_event_listener (AddKeyEventListenerNativeDelegate cb);
|
||||
|
||||
public delegate uint AddKeyEventListenerDelegate (KeySnoopFunc listener);
|
||||
|
||||
public static AddKeyEventListenerDelegate AddKeyEventListenerHandler {
|
||||
set {
|
||||
add_key_event_listener_handler = value;
|
||||
if (add_key_event_listener_callback == null)
|
||||
add_key_event_listener_callback = new AddKeyEventListenerNativeDelegate (AddKeyEventListenerCallback);
|
||||
atksharp_util_override_add_key_event_listener (add_key_event_listener_callback);
|
||||
}
|
||||
}
|
||||
|
||||
static RemoveListenerDelegate remove_key_event_listener_handler;
|
||||
static RemoveListenerNativeDelegate remove_key_event_listener_callback;
|
||||
|
||||
static void RemoveKeyEventListenerCallback (uint listener_id)
|
||||
{
|
||||
try {
|
||||
remove_key_event_listener_handler (listener_id);
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_remove_key_event_listener (RemoveListenerNativeDelegate cb);
|
||||
|
||||
public static RemoveListenerDelegate RemoveKeyEventListenerHandler {
|
||||
set {
|
||||
remove_key_event_listener_handler = value;
|
||||
if (remove_key_event_listener_callback == null)
|
||||
remove_key_event_listener_callback = new RemoveListenerNativeDelegate (RemoveKeyEventListenerCallback);
|
||||
atksharp_util_override_remove_key_event_listener (remove_key_event_listener_callback);
|
||||
}
|
||||
}
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate IntPtr GetRootNativeDelegate ();
|
||||
|
||||
static GetRootDelegate get_root_handler;
|
||||
static GetRootNativeDelegate get_root_callback;
|
||||
|
||||
static IntPtr GetRootCallback ()
|
||||
{
|
||||
try {
|
||||
return get_root_handler ().Handle;
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_get_root (GetRootNativeDelegate cb);
|
||||
|
||||
public delegate Atk.Object GetRootDelegate ();
|
||||
|
||||
public static GetRootDelegate GetRootHandler {
|
||||
set {
|
||||
get_root_handler = value;
|
||||
if (get_root_callback == null)
|
||||
get_root_callback = new GetRootNativeDelegate (GetRootCallback);
|
||||
atksharp_util_override_get_root (get_root_callback);
|
||||
}
|
||||
}
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate IntPtr GetToolkitNameNativeDelegate ();
|
||||
|
||||
static GetToolkitNameDelegate get_toolkit_name_handler;
|
||||
static GetToolkitNameNativeDelegate get_toolkit_name_callback;
|
||||
static string toolkit_name;
|
||||
static IntPtr toolkit_name_native;
|
||||
|
||||
static IntPtr GetToolkitNameCallback ()
|
||||
{
|
||||
try {
|
||||
string name = get_toolkit_name_handler ();
|
||||
if (name != toolkit_name) {
|
||||
GLib.Marshaller.Free (toolkit_name_native);
|
||||
toolkit_name_native = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
toolkit_name = name;
|
||||
}
|
||||
return toolkit_name_native;
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_get_toolkit_name (GetToolkitNameNativeDelegate cb);
|
||||
|
||||
public delegate string GetToolkitNameDelegate ();
|
||||
|
||||
public static GetToolkitNameDelegate GetToolkitNameHandler {
|
||||
set {
|
||||
get_toolkit_name_handler = value;
|
||||
if (get_toolkit_name_callback == null)
|
||||
get_toolkit_name_callback = new GetToolkitNameNativeDelegate (GetToolkitNameCallback);
|
||||
atksharp_util_override_get_toolkit_name (get_toolkit_name_callback);
|
||||
}
|
||||
}
|
||||
|
||||
[GLib.CDeclCallback]
|
||||
delegate IntPtr GetToolkitVersionNativeDelegate ();
|
||||
|
||||
static GetToolkitVersionDelegate get_toolkit_version_handler;
|
||||
static GetToolkitVersionNativeDelegate get_toolkit_version_callback;
|
||||
static string toolkit_version;
|
||||
static IntPtr toolkit_version_native;
|
||||
|
||||
static IntPtr GetToolkitVersionCallback ()
|
||||
{
|
||||
try {
|
||||
string version = get_toolkit_version_handler ();
|
||||
if (version != toolkit_version) {
|
||||
GLib.Marshaller.Free (toolkit_version_native);
|
||||
toolkit_version_native = GLib.Marshaller.StringToPtrGStrdup (version);
|
||||
toolkit_version = version;
|
||||
}
|
||||
return toolkit_version_native;
|
||||
} catch (Exception e) {
|
||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
[DllImport("atksharpglue-2")]
|
||||
static extern void atksharp_util_override_get_toolkit_version (GetToolkitVersionNativeDelegate cb);
|
||||
|
||||
public delegate string GetToolkitVersionDelegate ();
|
||||
|
||||
public static GetToolkitVersionDelegate GetToolkitVersionHandler {
|
||||
set {
|
||||
get_toolkit_version_handler = value;
|
||||
if (get_toolkit_version_callback == null)
|
||||
get_toolkit_version_callback = new GetToolkitVersionNativeDelegate (GetToolkitVersionCallback);
|
||||
atksharp_util_override_get_toolkit_version (get_toolkit_version_callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,15 +3,15 @@ lib_LTLIBRARIES = libatksharpglue-2.la
|
|||
libatksharpglue_2_la_LDFLAGS = -module -avoid-version -no-undefined
|
||||
|
||||
libatksharpglue_2_la_SOURCES = \
|
||||
generated.c \
|
||||
util.c \
|
||||
vmglueheaders.h
|
||||
|
||||
# Adding a new glue file?
|
||||
# Please remember to update makefile.win32
|
||||
|
||||
libatksharpglue_2_la_LIBADD = $(BASE_DEPENDENCIES_LIBS)
|
||||
libatksharpglue_2_la_LIBADD = $(ATK_LIBS)
|
||||
|
||||
INCLUDES = $(BASE_DEPENDENCIES_CFLAGS) $(GTK_SHARP_VERSION_CFLAGS) -I$(top_srcdir)
|
||||
INCLUDES = $(ATK_CFLAGS) $(GTK_SHARP_VERSION_CFLAGS) -I$(top_srcdir)
|
||||
|
||||
libatksharpglue.dll: $(libatksharpglue_2_la_OBJECTS) libatksharpglue.rc libatksharpglue.def
|
||||
./build-dll libatksharpglue-2 $(VERSION)
|
||||
|
|
94
atk/glue/util.c
Normal file
94
atk/glue/util.c
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* util.c : Glue for overriding vms of AtkUtil
|
||||
*
|
||||
* Author: Mike Kestner <mkestner@novell.com>
|
||||
*
|
||||
* Copyright (c) 2008 Novell, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of version 2 of the Lesser GNU General
|
||||
* Public License as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <atk/atk.h>
|
||||
|
||||
void atksharp_util_override_add_global_event_listener (gpointer cb);
|
||||
void atksharp_util_override_remove_global_event_listener (gpointer cb);
|
||||
void atksharp_util_override_add_key_event_listener (gpointer cb);
|
||||
void atksharp_util_override_remove_key_event_listener (gpointer cb);
|
||||
void atksharp_util_override_get_root (gpointer cb);
|
||||
void atksharp_util_override_get_toolkit_name (gpointer cb);
|
||||
void atksharp_util_override_get_toolkit_version (gpointer cb);
|
||||
|
||||
void
|
||||
atksharp_util_override_add_global_event_listener (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->add_global_event_listener = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_remove_global_event_listener (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->remove_global_event_listener = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_add_key_event_listener (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->add_key_event_listener = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_remove_key_event_listener (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->remove_key_event_listener = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_get_root (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->get_root = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_get_toolkit_name (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->get_toolkit_name = cb;
|
||||
}
|
||||
|
||||
void
|
||||
atksharp_util_override_get_toolkit_version (gpointer cb)
|
||||
{
|
||||
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
|
||||
if (!klass)
|
||||
klass = g_type_class_ref (ATK_TYPE_UTIL);
|
||||
((AtkUtilClass *) klass)->get_toolkit_version = cb;
|
||||
}
|
||||
|
|
@ -182,6 +182,10 @@ PKG_CHECK_MODULES(PANGO, pango)
|
|||
AC_SUBST(PANGO_CFLAGS)
|
||||
AC_SUBST(PANGO_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(ATK, atk)
|
||||
AC_SUBST(ATK_CFLAGS)
|
||||
AC_SUBST(ATK_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION)
|
||||
AC_SUBST(GTK_CFLAGS)
|
||||
AC_SUBST(GTK_LIBS)
|
||||
|
@ -230,6 +234,7 @@ pango/pango-sharp.dll.config
|
|||
pango/glue/Makefile
|
||||
atk/Makefile
|
||||
atk/atk-sharp.dll.config
|
||||
atk/glue/Makefile
|
||||
gdk/Makefile
|
||||
gdk/gdk-sharp.dll.config
|
||||
gdk/glue/Makefile
|
||||
|
|
Loading…
Add table
Reference in a new issue