void
calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal)
{
	FocusData *focus;
	BonoboUIComponent *uic;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	e_menu_activate((EMenu *)gnome_calendar_get_calendar_menu (gcal), uic, 0);
	e_menu_activate((EMenu *)gnome_calendar_get_taskpad_menu (gcal), uic, 0);

	gnome_calendar_set_ui_component (gcal, NULL);

	focus = g_object_get_data (G_OBJECT (control), "focus_data");
	g_return_if_fail (focus != NULL);

	g_object_set_data (G_OBJECT (control), "focus_data", NULL);
	g_free (focus);

	gnome_calendar_discard_view_menus (gcal);

	g_signal_handlers_disconnect_matched (gcal, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, control);

	bonobo_ui_component_rm (uic, "/", NULL);
 	bonobo_ui_component_unset_container (uic, NULL);
}
static void
view_control_activate_cb (BonoboControl *control, gboolean activate, EMFolderView *view)
{
	BonoboUIComponent *uic;
	static int recover = 0;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	if (activate) {
		Bonobo_UIContainer container;

		container = bonobo_control_get_remote_ui_container (control, NULL);
		bonobo_ui_component_set_container (uic, container, NULL);
		bonobo_object_release_unref (container, NULL);

		g_return_if_fail (container == bonobo_ui_component_get_container(uic));
		g_return_if_fail (container != CORBA_OBJECT_NIL);

		em_folder_view_activate (view, uic, activate);
		e_user_creatable_items_handler_activate(g_object_get_data((GObject *)view, "e-creatable-items-handler"), uic);
	} else {
		em_folder_view_activate (view, uic, activate);
		bonobo_ui_component_unset_container (uic, NULL);
	}

	/* This is a weird place to put it, but createControls does it too early.
	   I also think we should wait to do it until we actually visit the mailer.
	   The delay is arbitrary - without it it shows up before the main window */
	if (!recover) {
		recover = 1;
		g_timeout_add(1000, check_autosave, NULL);
	}
}
static void
impl_Bonobo_UIComponent_unsetContainer (PortableServer_Servant servant,
					CORBA_Environment     *ev)
{
	BonoboUIComponent *component = bonobo_ui_from_servant (servant);

	bonobo_ui_component_unset_container (component, ev);
}
/*
 * When this view is deactivated, we must remove our menu items.
 */
static void
view_remove_menus (view_data_t *view_data)
{
	BonoboView *view = view_data->view;
	BonoboUIComponent *uic;

	uic = bonobo_view_get_ui_component (view);

	bonobo_ui_component_unset_container (uic);
}
/**
 * bonobo_ui_component_set_container:
 * @component: the component
 * @container: a remote container object.
 * 
 * This associates this @component with a remote @container
 * object.
 **/
void
bonobo_ui_component_set_container (BonoboUIComponent *component,
				   Bonobo_UIContainer container,
				   CORBA_Environment *opt_ev)
{
	Bonobo_UIContainer ref_cont;

	g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));

	bonobo_object_ref (BONOBO_OBJECT (component));

	if (container != CORBA_OBJECT_NIL) {
		Bonobo_UIComponent corba_component;
		CORBA_Environment *ev, temp_ev;
		char              *name;
		
		if (!opt_ev) {
			CORBA_exception_init (&temp_ev);
			ev = &temp_ev;
		} else
			ev = opt_ev;

		ref_cont = CORBA_Object_duplicate (container, ev);

		corba_component = BONOBO_OBJREF (component);

		name = component->priv->name ? component->priv->name : "";

		Bonobo_UIContainer_registerComponent (
			ref_cont, name, corba_component, ev);

		if (!opt_ev && BONOBO_EX (ev)) {
			char *err;
			g_warning ("Serious exception registering component '%s'",
				   (err = bonobo_exception_get_text (ev)));
			g_free (err);
		}
		
		if (!opt_ev)
			CORBA_exception_free (&temp_ev);
	} else
		ref_cont = CORBA_OBJECT_NIL;

	bonobo_ui_component_unset_container (component, NULL);

	component->priv->container = ref_cont;

	bonobo_object_unref (BONOBO_OBJECT (component));
}
static void
peacock_file_control_activate_cb (BonoboControl *control, gboolean state,
				  gpointer user_data)
{
	BonoboUIComponent *uic;

	uic = bonobo_control_get_ui_component (control);
	if (state) { /* Activate */
		bonobo_ui_util_set_ui (uic, UIXMLDIR,
				       "peacock-file-ui.xml",
				       "peacock-2", NULL);
	} else {
		bonobo_ui_component_unset_container (uic, NULL);
	}
}
static void
control_deactivate (BonoboControl *control,
		    BonoboUIComponent *ui_component,
		    EYank *yank)
{
	gchar *filename;

  filename = g_concat_dir_and_file (yank->priv->uri + 7, YANK_FILENAME);
   	note_save(filename, GTK_CTREE(yank->priv->sp.note_tree));   
/*   edit_tree_node_clear(yank->priv->sp.edit_tree, NULL);   */
	sp = &(yank->priv->sp);
	yank->priv->sp.modified = FALSE;
	printf("control_desactivate : sp %x\n", sp);
  clear_tree_from_node(GTK_CTREE(yank->priv->sp.note_tree), NULL);
	g_free(filename);

/* 	bonobo_ui_component_rm (ui_component, "/", NULL); */
	bonobo_ui_component_unset_container (ui_component);


}