From cbf6068edfb3246973053658cfa475d7a0ff2df8 Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Fri, 12 Sep 2008 19:47:38 +0000 Subject: [PATCH] Support GetIndexInParent. svn path=/trunk/gtk-sharp/; revision=112901 --- ChangeLog | 4 ++++ atk/Object.custom | 32 ++++++++++++++++++++++++++++++++ atk/glue/object.c | 11 +++++++++++ 3 files changed, 47 insertions(+) diff --git a/ChangeLog b/ChangeLog index f96934a0f..8eda79b58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-09-12 Mike Gorse + + * atk/Object.custom, atk/glue/object.c: Support GetIndexInParent. + 2008-09-09 Mike Kestner * generator/ReturnValue.cs: warning cleanup. diff --git a/atk/Object.custom b/atk/Object.custom index 67447c1ba..6e3fbcc6f 100644 --- a/atk/Object.custom +++ b/atk/Object.custom @@ -150,4 +150,36 @@ return GLib.Object.GetObject (raw, true) as StateSet; } + [DllImport("atksharpglue-2")] + static extern void atksharp_object_override_get_index_in_parent (IntPtr type, IndexInParentDelegate cb); + [GLib.CDeclCallback] + delegate int IndexInParentDelegate (IntPtr raw); + + static IndexInParentDelegate IndexInParentCallback; + + static int IndexInParent_cb (IntPtr raw) + { + try { + Atk.Object obj = GLib.Object.GetObject (raw, false) as Atk.Object; + return obj.OnGetIndexInParent (); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + + return -1; + } + + static void OverrideIndexInParent (GLib.GType gtype) + { + if (IndexInParentCallback == null) + IndexInParentCallback = new IndexInParentDelegate (IndexInParent_cb); + atksharp_object_override_get_index_in_parent (gtype.Val, IndexInParentCallback); + } + + [GLib.DefaultSignalHandler (Type=typeof(Atk.Object), ConnectionMethod="OverrideIndexInParent")] + protected virtual int OnGetIndexInParent() { + return -1; + } + + diff --git a/atk/glue/object.c b/atk/glue/object.c index febb37368..03002da1b 100644 --- a/atk/glue/object.c +++ b/atk/glue/object.c @@ -30,6 +30,7 @@ void atksharp_object_override_ref_state_set (GType gtype, gpointer cb); AtkStateSet* atksharp_object_base_ref_state_set (AtkObject *base); +void atksharp_object_override_get_index_in_parent (GType gtype, gpointer cb); void atksharp_object_override_get_n_children (GType gtype, gpointer cb) @@ -67,3 +68,13 @@ atksharp_object_base_ref_state_set (AtkObject *atk_obj) return (*parent->ref_state_set) (atk_obj); return NULL; } + +void +atksharp_object_override_get_index_in_parent (GType gtype, gpointer cb) +{ + AtkObjectClass *klass = g_type_class_peek (gtype); + if (!klass) + klass = g_type_class_ref (gtype); + ((AtkObjectClass *) klass)->get_index_in_parent = cb; +} +