static void
mate_panel_applet_frame_matecomponent_finalize (GObject *object)
{
	MatePanelAppletFrameMateComponent *frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (object);

	if (frame->priv->control) {
		/* do this before unref'ing every matecomponent stuff since it looks
		 * like we can receive some events when unref'ing them */
		MateCORBA_small_unlisten_for_broken (frame->priv->control,
						 G_CALLBACK (mate_panel_applet_frame_matecomponent_applet_broken));
		matecomponent_object_release_unref (frame->priv->control, NULL);
		frame->priv->control = CORBA_OBJECT_NIL;
	}

	if (frame->priv->property_bag)
		matecomponent_object_release_unref (
			frame->priv->property_bag, NULL);

	if (frame->priv->applet_shell)
		matecomponent_object_release_unref (
			frame->priv->applet_shell, NULL);

	if (frame->priv->ui_component)
		matecomponent_object_unref (
			MATECOMPONENT_OBJECT (frame->priv->ui_component));

	G_OBJECT_CLASS (mate_panel_applet_frame_matecomponent_parent_class)->finalize (object);
}
static void
matecomponent_control_unset_control_frame (MateComponentControl     *control,
				    CORBA_Environment *opt_ev)
{
	CORBA_Environment *ev, tmp_ev;

	if (!opt_ev) {
		CORBA_exception_init (&tmp_ev);
		ev = &tmp_ev;
	} else
		ev = opt_ev;

	if (control->priv->no_frame_timeout_id != 0) {
		g_source_remove (control->priv->no_frame_timeout_id);
		control->priv->no_frame_timeout_id = 0;
	}

	if (control->priv->frame != CORBA_OBJECT_NIL) {
		MateComponent_ControlFrame frame = control->priv->frame;

		control->priv->frame = CORBA_OBJECT_NIL;

		MateCORBA_small_unlisten_for_broken (
			frame, G_CALLBACK (control_frame_connection_died_cb));

		if (control->priv->active)
			MateComponent_ControlFrame_notifyActivated (
				frame, FALSE, ev);

		CORBA_Object_release (frame, ev);
	}

	if (!opt_ev)
		CORBA_exception_free (&tmp_ev);
}
static void
xfapplet_unload_applet (XfAppletPlugin *xap)
{
	if (xap->prop_bag) {
		matecomponent_object_release_unref (xap->prop_bag, NULL);
		xap->prop_bag = CORBA_OBJECT_NIL;
	}

	if (xap->uic) {
		matecomponent_object_unref (MATECOMPONENT_OBJECT (xap->uic));
		xap->uic = NULL;
	}
	
	if (xap->object) {
		MateCORBA_small_unlisten_for_broken (xap->object, G_CALLBACK (xfapplet_connection_broken));
		CORBA_Object_release (xap->object, NULL);
		xap->object = CORBA_OBJECT_NIL;
	}
}