From 9dd35dd137092105f912a2c2837df946885042ce Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Wed, 8 Oct 2008 15:06:49 +0000 Subject: [PATCH] Add function handlers for ObjectFactory. svn path=/trunk/gtk-sharp/; revision=115220 --- ChangeLog | 6 ++ atk/Makefile.am | 1 + atk/ObjectFactory.custom | 124 ++++++++++++++++++++++++++++++++++++++ atk/glue/Makefile.am | 1 + atk/glue/object_factory.c | 56 +++++++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 atk/ObjectFactory.custom create mode 100644 atk/glue/object_factory.c diff --git a/ChangeLog b/ChangeLog index 05f53b86e..7b11a38b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-10-08 Mike Gorse + + * 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 * Atk/Makefile.am, Atk/Hyperlink.custom, Atk/glue/Makefile.am, diff --git a/atk/Makefile.am b/atk/Makefile.am index 9f7abe8a8..fd3ebdb76 100644 --- a/atk/Makefile.am +++ b/atk/Makefile.am @@ -15,6 +15,7 @@ customs = \ Hyperlink.custom \ Misc.custom \ Object.custom \ + ObjectFactory.custom \ TextAdapter.custom \ Util.custom diff --git a/atk/ObjectFactory.custom b/atk/ObjectFactory.custom new file mode 100644 index 000000000..be091b209 --- /dev/null +++ b/atk/ObjectFactory.custom @@ -0,0 +1,124 @@ +// ObjectFactory.custom - Atk ObjectFactory class customizations +// +// Author: Mike Gorse +// +// 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; + } diff --git a/atk/glue/Makefile.am b/atk/glue/Makefile.am index ea23a39f8..2bab59600 100644 --- a/atk/glue/Makefile.am +++ b/atk/glue/Makefile.am @@ -6,6 +6,7 @@ libatksharpglue_2_la_SOURCES = \ hyperlink.c \ misc.c \ object.c \ + object_factory.c \ util.c \ vmglueheaders.h diff --git a/atk/glue/object_factory.c b/atk/glue/object_factory.c new file mode 100644 index 000000000..ac6b05db6 --- /dev/null +++ b/atk/glue/object_factory.c @@ -0,0 +1,56 @@ +/* object.c : Glue for overriding vms of AtkObject + * + * Author: Andres G. Aragoneses + * + * 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 + + +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; +}