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 <gtk/gtk.h>
23 #include <string.h>
24 
25 void gtksharp_container_base_forall (GtkContainer *container, gboolean include_internals, GtkCallback cb, gpointer data);
26 
27 void
gtksharp_container_base_forall(GtkContainer * container,gboolean include_internals,GtkCallback cb,gpointer data)28 gtksharp_container_base_forall (GtkContainer *container, gboolean include_internals, GtkCallback cb, gpointer data)
29 {
30 	// Find and call the first base callback that's not the GTK# callback. The GTK# callback calls down the whole
31 	// managed override chain, so calling it on a subclass-of-a-managed-container-subclass causes a stack overflow.
32 	GtkContainerClass *parent = (GtkContainerClass *) G_OBJECT_GET_CLASS (container);
33 	while ((parent = g_type_class_peek_parent (parent))) {
34 		if (strncmp (G_OBJECT_CLASS_NAME (parent), "__gtksharp_", 11) != 0) {
35 			if (parent->forall) {
36 				(*parent->forall) (container, include_internals, cb, data);
37 			}
38 			return;
39 		}
40 	}
41 }
42 
43 void gtksharp_container_override_forall (GType gtype, gpointer cb);
44 
45 void
gtksharp_container_override_forall(GType gtype,gpointer cb)46 gtksharp_container_override_forall (GType gtype, gpointer cb)
47 {
48 	GtkContainerClass *klass = g_type_class_peek (gtype);
49 	if (!klass)
50 		klass = g_type_class_ref (gtype);
51 	((GtkContainerClass *) klass)->forall = cb;
52 }
53 
54 void gtksharp_container_invoke_gtk_callback (GtkCallback cb, GtkWidget *widget, gpointer data);
55 
56 void
gtksharp_container_invoke_gtk_callback(GtkCallback cb,GtkWidget * widget,gpointer data)57 gtksharp_container_invoke_gtk_callback (GtkCallback cb, GtkWidget *widget, gpointer data)
58 {
59 	cb (widget, data);
60 }
61 
62 void gtksharp_container_child_get_property (GtkContainer *container, GtkWidget *child,
63 					    const gchar* property, GValue *value);
64 
65 void
gtksharp_container_child_get_property(GtkContainer * container,GtkWidget * child,const gchar * property,GValue * value)66 gtksharp_container_child_get_property (GtkContainer *container, GtkWidget *child,
67 				       const gchar* property, GValue *value)
68 {
69 	GParamSpec *spec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (container), property);
70 	g_value_init (value, spec->value_type);
71 	gtk_container_child_get_property (container, child, property, value);
72 }
73 
74