Add function handlers for ObjectFactory.

svn path=/trunk/gtk-sharp/; revision=115220
This commit is contained in:
Mike Gorse 2008-10-08 15:06:49 +00:00
parent 2791971e57
commit 9dd35dd137
5 changed files with 188 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2008-10-08 Mike Gorse <mgorse@novell.com>
* Atk/Makefile.am, Atk/ObjectFactory.custom, Atk/glue/Makefile.am,
Atk/glue/object_factory.c: Add ObjectFactory.custom and
glue/object_factory.c.
2008-10-02 Mike Gorse <mgorse@novell.com>
* Atk/Makefile.am, Atk/Hyperlink.custom, Atk/glue/Makefile.am,

View file

@ -15,6 +15,7 @@ customs = \
Hyperlink.custom \
Misc.custom \
Object.custom \
ObjectFactory.custom \
TextAdapter.custom \
Util.custom

124
atk/ObjectFactory.custom Normal file
View file

@ -0,0 +1,124 @@
// ObjectFactory.custom - Atk ObjectFactory class customizations
//
// Author: Mike Gorse <mgorse@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.
[DllImport("atksharpglue-2")]
static extern void atksharp_object_factory_override_create_accessible (IntPtr type, CreateAccessibleDelegate cb);
[GLib.CDeclCallback]
delegate IntPtr CreateAccessibleDelegate (IntPtr raw);
static CreateAccessibleDelegate CreateAccessibleCallback;
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_object_ref (IntPtr handle);
static IntPtr CreateAccessible_cb (IntPtr raw)
{
try {
Atk.ObjectFactory obj = GLib.Object.GetObject (raw, false) as Atk.ObjectFactory;
Atk.Object ret = obj.OnCreateAccessible ();
if (ret != null)
g_object_ref (ret.Handle);
return ret == null ? IntPtr.Zero : ret.Handle;
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
return IntPtr.Zero;
}
static void OverrideCreateAccessible (GLib.GType gtype)
{
if (CreateAccessibleCallback == null)
CreateAccessibleCallback = new CreateAccessibleDelegate (CreateAccessible_cb);
atksharp_object_factory_override_create_accessible (gtype.Val, CreateAccessibleCallback);
}
[GLib.DefaultSignalHandler (Type=typeof(Atk.ObjectFactory), ConnectionMethod="OverrideCreateAccessible")]
protected virtual Atk.Object OnCreateAccessible ()
{
return null;
}
[DllImport("atksharpglue-2")]
static extern void atksharp_object_factory_override_invalidate (IntPtr type, InvalidateDelegate cb);
[GLib.CDeclCallback]
delegate void InvalidateDelegate (IntPtr raw);
static InvalidateDelegate InvalidateCallback;
static void Invalidate_cb (IntPtr raw)
{
try {
Atk.ObjectFactory obj = GLib.Object.GetObject (raw, false) as Atk.ObjectFactory;
obj.OnInvalidate ();
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
static void OverrideInvalidate (GLib.GType gtype)
{
if (InvalidateCallback == null)
InvalidateCallback = new InvalidateDelegate (Invalidate_cb);
atksharp_object_factory_override_invalidate (gtype.Val, InvalidateCallback);
}
[GLib.DefaultSignalHandler (Type=typeof(Atk.ObjectFactory), ConnectionMethod="OverrideInvalidate")]
protected virtual void OnInvalidate ()
{
}
[DllImport("atksharpglue-2")]
static extern void atksharp_object_factory_override_get_accessible_type (IntPtr type, GetAccessibleTypeDelegate cb);
[GLib.CDeclCallback]
delegate IntPtr GetAccessibleTypeDelegate (IntPtr raw);
static GetAccessibleTypeDelegate GetAccessibleTypeCallback;
static IntPtr GetAccessibleType_cb (IntPtr raw)
{
try {
Atk.ObjectFactory obj = GLib.Object.GetObject (raw, false) as Atk.ObjectFactory;
return obj.OnGetAccessibleType ().Val;
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
return IntPtr.Zero;
}
static void OverrideGetAccessibleType (GLib.GType gtype)
{
if (GetAccessibleTypeCallback == null)
GetAccessibleTypeCallback = new GetAccessibleTypeDelegate (GetAccessibleType_cb);
atksharp_object_factory_override_get_accessible_type (gtype.Val, GetAccessibleTypeCallback);
}
[GLib.DefaultSignalHandler (Type=typeof(Atk.ObjectFactory), ConnectionMethod="OverrideGetAccessibleType")]
protected virtual GLib.GType OnGetAccessibleType ()
{
return GLib.GType.Invalid;
}

View file

@ -6,6 +6,7 @@ libatksharpglue_2_la_SOURCES = \
hyperlink.c \
misc.c \
object.c \
object_factory.c \
util.c \
vmglueheaders.h

56
atk/glue/object_factory.c Normal file
View file

@ -0,0 +1,56 @@
/* object.c : Glue for overriding vms of AtkObject
*
* Author: Andres G. Aragoneses <aaragoneses@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_object_factory_override_create_accessible (GType gtype, gpointer cb);
void atksharp_object_factory_override_invalidate (GType gtype, gpointer cb);
void atksharp_object_factory_override_get_accessible_type (GType gtype, gpointer cb);
void
atksharp_object_factory_override_create_accessible (GType gtype, gpointer cb)
{
AtkObjectFactoryClass *klass = g_type_class_peek (gtype);
if (!klass)
klass = g_type_class_ref (gtype);
klass->create_accessible = cb;
}
void
atksharp_object_factory_override_invalidate (GType gtype, gpointer cb)
{
AtkObjectFactoryClass *klass = g_type_class_peek (gtype);
if (!klass)
klass = g_type_class_ref (gtype);
klass->invalidate = cb;
}
void
atksharp_object_factory_override_get_accessible_type (GType gtype, gpointer cb)
{
AtkObjectFactoryClass *klass = g_type_class_peek (gtype);
if (!klass)
klass = g_type_class_ref (gtype);
klass->get_accessible_type = cb;
}