diff --git a/ChangeLog b/ChangeLog index 6c19c3b7b..efff921a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-03-28 Andres G. Aragoneses + + * atk/Object.custom: custom properties for overriding class methods. + * atk/Makefile.am: include Object.custom. + * atk/glue/object.c: glue to override class methods. + * atk/glue/Makefile.am: include object.c. + 2008-03-27 Andres G. Aragoneses * glib/Program.cs: Add new static class for utility property, moving diff --git a/atk/Makefile.am b/atk/Makefile.am index 895057dff..1dc507b9c 100644 --- a/atk/Makefile.am +++ b/atk/Makefile.am @@ -8,6 +8,7 @@ references = ../glib/glib-sharp.dll sources = customs = \ + Object.custom \ Util.custom add_dist = makefile.win32 diff --git a/atk/Object.custom b/atk/Object.custom new file mode 100644 index 000000000..52f001705 --- /dev/null +++ b/atk/Object.custom @@ -0,0 +1,88 @@ +// Object.custom - Atk Object class customizations +// +// Author: Andres G. Aragoneses +// +// 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 int atksharp_object_override_get_n_children (IntPtr type, NChildrenDelegate cb); + + [GLib.CDeclCallback] + delegate int NChildrenDelegate (IntPtr raw); + + static NChildrenDelegate NChildrenCallback; + + static int NChildren_cb (IntPtr raw) + { + try { + Atk.Object obj = GLib.Object.GetObject (raw, false) as Atk.Object; + return obj.OnGetNChildren(); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + + return 0; + } + + static void OverrideNChildren (GLib.GType gtype) + { + if (NChildrenCallback == null) + NChildrenCallback = new NChildrenDelegate (NChildren_cb); + atksharp_object_override_get_n_children (gtype.Val, NChildrenCallback); + } + + [GLib.DefaultSignalHandler (Type=typeof(Atk.Object), ConnectionMethod="OverrideNChildren")] + protected virtual int OnGetNChildren() { + return 0; + } + + [DllImport("atksharpglue-2")] + static extern IntPtr atksharp_object_override_ref_child (IntPtr type, RefChildDelegate cb); + + [GLib.CDeclCallback] + delegate IntPtr RefChildDelegate (IntPtr raw, int i); + + static RefChildDelegate RefChildCallback; + + static IntPtr RefChild_cb (IntPtr raw, int i) + { + try { + Atk.Object obj = GLib.Object.GetObject (raw, false) as Atk.Object; + return obj.RefChild(i).Handle; + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + + return GLib.GType.Invalid.Val; + } + + + static void OverrideRefChild (GLib.GType gtype) + { + if (RefChildCallback == null) + RefChildCallback = new RefChildDelegate (RefChild_cb); + atksharp_object_override_ref_child (gtype.Val, RefChildCallback); + } + + [GLib.DefaultSignalHandler (Type=typeof(Atk.Object), ConnectionMethod="OverrideRefChild")] + public virtual Atk.Object RefChild(int i) { + return null; + } + diff --git a/atk/glue/Makefile.am b/atk/glue/Makefile.am index adbfc9c25..1c3961724 100644 --- a/atk/glue/Makefile.am +++ b/atk/glue/Makefile.am @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libatksharpglue-2.la libatksharpglue_2_la_LDFLAGS = -module -avoid-version -no-undefined libatksharpglue_2_la_SOURCES = \ + object.c \ util.c \ vmglueheaders.h diff --git a/atk/glue/object.c b/atk/glue/object.c new file mode 100644 index 000000000..bac265f04 --- /dev/null +++ b/atk/glue/object.c @@ -0,0 +1,45 @@ +/* util.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 + + +gint atksharp_object_override_get_n_children (GType gtype, gpointer cb); + +gint +atksharp_object_override_get_n_children (GType gtype, gpointer cb) +{ + AtkObjectClass *klass = g_type_class_peek (gtype); + if (!klass) + klass = g_type_class_ref (gtype); + ((AtkObjectClass *) klass)->get_n_children = cb; +} + +AtkObject* atksharp_object_override_ref_child (GType gtype, gpointer cb); + +AtkObject* +atksharp_object_override_ref_child (GType gtype, gpointer cb) +{ + AtkObjectClass *klass = g_type_class_peek (gtype); + if (!klass) + klass = g_type_class_ref (gtype); + ((AtkObjectClass *) klass)->ref_child = cb; +}