1 /* container.c : Glue for GtkContainer
2  *
3  * Author:  Mike Kestner (mkestner@ximian.com)
4  *
5  * Copyright (C) 2004 Novell, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the Lesser GNU General
9  * Public License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #include <string.h>
23 #include <gtk/gtkcontainer.h>
24 
25 //if this can be invoked without an EntryPointNotFoundExfeption, the caller knows the container leak leak is fixed
26 void gtksharp_container_leak_fixed_marker (void);
27 
gtksharp_container_leak_fixed_marker(void)28 void gtksharp_container_leak_fixed_marker (void)
29 {
30 }
31 
32 void gtksharp_container_base_forall (GtkContainer *container, gboolean include_internals, GtkCallback cb, gpointer data);
33 
34 void
gtksharp_container_base_forall(GtkContainer * container,gboolean include_internals,GtkCallback cb,gpointer data)35 gtksharp_container_base_forall (GtkContainer *container, gboolean include_internals, GtkCallback cb, gpointer data)
36 {
37 	// Find and call the first base callback that's not the GTK# callback. The GTK# callback calls down the whole
38 	// managed override chain, so calling it on a subclass-of-a-managed-container-subclass causes a stack overflow.
39 	GtkContainerClass *parent = (GtkContainerClass *) G_OBJECT_GET_CLASS (container);
40 	while ((parent = g_type_class_peek_parent (parent))) {
41 		if (strncmp (G_OBJECT_CLASS_NAME (parent), "__gtksharp_", 11) != 0) {
42 			if (parent->forall) {
43 				(*parent->forall) (container, include_internals, cb, data);
44 			}
45 			return;
46 		}
47 	}
48 }
49 
50 void gtksharp_container_override_forall (GType gtype, gpointer cb);
51 
52 void
gtksharp_container_override_forall(GType gtype,gpointer cb)53 gtksharp_container_override_forall (GType gtype, gpointer cb)
54 {
55 	GtkContainerClass *klass = g_type_class_peek (gtype);
56 	if (!klass)
57 		klass = g_type_class_ref (gtype);
58 	((GtkContainerClass *) klass)->forall = cb;
59 }
60 
61 void gtksharp_container_invoke_gtk_callback (GtkCallback cb, GtkWidget *widget, gpointer data);
62 
63 void
gtksharp_container_invoke_gtk_callback(GtkCallback cb,GtkWidget * widget,gpointer data)64 gtksharp_container_invoke_gtk_callback (GtkCallback cb, GtkWidget *widget, gpointer data)
65 {
66 	cb (widget, data);
67 }
68 
69 void gtksharp_container_override_child_type (GType gtype, gpointer cb);
70 
71 void
gtksharp_container_override_child_type(GType gtype,gpointer cb)72 gtksharp_container_override_child_type (GType gtype, gpointer cb)
73 {
74 	GtkContainerClass *klass = g_type_class_peek (gtype);
75 	if (!klass)
76 		klass = g_type_class_ref (gtype);
77 	((GtkContainerClass *) klass)->child_type = cb;
78 }
79 
80 void gtksharp_container_child_get_property (GtkContainer *container, GtkWidget *child,
81 					    const gchar* property, GValue *value);
82 
83 void
gtksharp_container_child_get_property(GtkContainer * container,GtkWidget * child,const gchar * property,GValue * value)84 gtksharp_container_child_get_property (GtkContainer *container, GtkWidget *child,
85 				       const gchar* property, GValue *value)
86 {
87 	GParamSpec *spec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (container), property);
88 	g_value_init (value, spec->value_type);
89 	gtk_container_child_get_property (container, child, property, value);
90 }
91 
92