static void process_child_properties (GType type, GObjectClass *oclass) { guint i, n_properties; GParamSpec **specs; specs = gtk_container_class_list_child_properties (oclass, &n_properties); if (!specs || n_properties == 0) { return; } /* skip types that have parents who have child properties, but * that don't actually have any themselves */ for (i = 0; i < n_properties; i++) { if (specs[i]->owner_type == type) { goto process_child_properties; } } goto free_specs; process_child_properties: g_print ("%sChildAttrs = ", g_type_name (type)); comma = FALSE; for (i = 0; i < n_properties; i++) { if (specs[i]->owner_type == type) { if (process_attribute (specs[i])) { comma = TRUE; } } } child_attrs = g_list_prepend (child_attrs, GSIZE_TO_POINTER (type)); free_specs: g_free (specs); }
void glade_gtk_container_replace_child (GladeWidgetAdaptor * adaptor, GtkWidget * container, GtkWidget * current, GtkWidget * new_widget) { GParamSpec **param_spec; GladePropertyClass *pclass; GValue *value; guint nproperties; guint i; g_return_if_fail (gtk_widget_get_parent (current) == container); param_spec = gtk_container_class_list_child_properties (G_OBJECT_GET_CLASS (container), &nproperties); value = g_malloc0 (sizeof (GValue) * nproperties); for (i = 0; i < nproperties; i++) { g_value_init (&value[i], param_spec[i]->value_type); gtk_container_child_get_property (GTK_CONTAINER (container), current, param_spec[i]->name, &value[i]); } gtk_container_remove (GTK_CONTAINER (container), current); gtk_container_add (GTK_CONTAINER (container), new_widget); for (i = 0; i < nproperties; i++) { /* If the added widget is a placeholder then we * want to keep all the "tranfer-on-paste" properties * as default so that it looks fresh (transfer-on-paste * properties dont effect the position/slot inside a * contianer) */ if (GLADE_IS_PLACEHOLDER (new_widget)) { pclass = glade_widget_adaptor_get_pack_property_class (adaptor, param_spec[i]->name); if (pclass && glade_property_class_transfer_on_paste (pclass)) continue; } gtk_container_child_set_property (GTK_CONTAINER (container), new_widget, param_spec[i]->name, &value[i]); } for (i = 0; i < nproperties; i++) g_value_unset (&value[i]); g_free (param_spec); g_free (value); }