static void
destroy_test (Test *test, DestroyType type)
{
    switch (type) {
    case DESTROY_CONTAINED: {
        /* Highly non-useful, should never happen */
        MateComponentControlFrame *frame;

        gtk_widget_destroy (test->control_widget);

        g_assert (test->control_widget == NULL);

        frame = matecomponent_widget_get_control_frame (
                    MATECOMPONENT_WIDGET (test->matecomponent_widget));
        g_assert (MATECOMPONENT_IS_CONTROL_FRAME (frame));
        break;
    }

    case DESTROY_SOCKET:
        g_warning ("unimpl");
    /* drop through */

    case DESTROY_CONTROL:
        matecomponent_object_unref (test->control);
        g_assert (test->plug == NULL);
        g_assert (test->control_widget == NULL);
    /* drop through */

    case DESTROY_TOPLEVEL:
        gtk_widget_destroy (test->matecomponent_widget);
        g_assert (test->matecomponent_widget == NULL);
        g_assert (test->socket == NULL);
        g_assert (test->frame == NULL);
        g_assert (test->plug == NULL);
        g_assert (test->control == NULL);
        break;
    default:
        g_assert_not_reached ();
        break;
    }

    g_assert (test->control_widget == NULL);

    switch (type) {
    case DESTROY_CONTAINED:
        gtk_widget_destroy (test->matecomponent_widget);
        break;
    default:
        break;
    }

    g_assert (test->matecomponent_widget == NULL);
}
static void
create_frame (Test *test, gboolean fake_remote)
{
    MateComponent_Control control;

    control = MATECOMPONENT_OBJREF (test->control);
    /*	if (fake_remote)
    	control = MateCORBA_objref_get_proxy (control);*/

    test->matecomponent_widget = matecomponent_widget_new_control_from_objref (
                                     control, CORBA_OBJECT_NIL);
    matecomponent_object_unref (MATECOMPONENT_OBJECT (test->control));
    gtk_widget_show (test->matecomponent_widget);
    test->frame = matecomponent_widget_get_control_frame (
                      MATECOMPONENT_WIDGET (test->matecomponent_widget));
    test->socket = matecomponent_control_frame_get_socket (test->frame);

    g_object_add_weak_pointer (G_OBJECT (test->frame),
                               (gpointer *) &test->frame);
    g_object_add_weak_pointer (G_OBJECT (test->socket),
                               (gpointer *) &test->socket);
    g_object_add_weak_pointer (G_OBJECT (test->matecomponent_widget),
                               (gpointer *) &test->matecomponent_widget);
}
Ejemplo n.º 3
0
static void
xfapplet_applet_activated (MateComponent_Unknown object, CORBA_Environment *ev, gpointer data)
{
	GtkWidget		*bw, *child = NULL;
	CORBA_Object		 control;
	CORBA_Environment	 corba_ev;
	MateComponentControlFrame	*frame;
	MateComponentUIComponent	*uic;
	MateComponent_PropertyBag	 prop_bag;
	XfAppletPlugin		*xap = (XfAppletPlugin*) data;
	gchar			*error;

	if (MATECOMPONENT_EX (ev) || object == CORBA_OBJECT_NIL) {
		error = matecomponent_exception_get_text (ev);
		CORBA_exception_free (ev);
		g_warning ("Failed to load applet '%s' (can't get CORBA object): %s\n", xap->iid, error);
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	
	control = CORBA_Object_duplicate (object, NULL);
	bw = matecomponent_widget_new_control_from_objref (object, CORBA_OBJECT_NIL);
	matecomponent_object_release_unref (object, NULL);
	if (!bw) {
		g_warning ("Failed to load applet '%s' (can't get matecomponent widget)\n", xap->iid);
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		return;
	}
	
	frame = matecomponent_widget_get_control_frame (MATECOMPONENT_WIDGET (bw));
	if (!frame) {
		g_warning ("Failed to load applet '%s' (can't get control frame)\n", xap->iid);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		return;
	}
	
	CORBA_exception_init (&corba_ev);
	prop_bag = matecomponent_control_frame_get_control_property_bag (frame, &corba_ev);
	if (prop_bag == NULL || MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't get property bag): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	
        uic = matecomponent_control_frame_get_popup_component (frame, &corba_ev);
	if (uic == NULL || MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't get popup component): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
		
	matecomponent_ui_component_freeze (uic, CORBA_OBJECT_NIL);
	xfce_textdomain ("xfce4-panel", LIBXFCE4PANEL_LOCALE_DIR, "UTF-8");
	matecomponent_ui_util_set_ui (uic, PKGDATADIR "/ui", "XFCE_Panel_Popup.xml", "xfce4-xfapplet-plugin", &corba_ev);
	if (MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't set ui): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
	xfapplet_setup_menu_items (xap->plugin, uic);
	matecomponent_ui_component_thaw (uic, CORBA_OBJECT_NIL);

	gtk_widget_show (bw);

	if (xap->configured)
		xfapplet_unload_applet (xap);

	xap->object = control;
	xap->uic = uic;
	xap->prop_bag = prop_bag;
	MateCORBA_small_listen_for_broken (object, G_CALLBACK (xfapplet_connection_broken), xap);

	child = xfapplet_get_plugin_child (xap->plugin);
	if (child)
		gtk_widget_destroy (child);

	gtk_container_add (GTK_CONTAINER(xap->plugin), bw);
	xap->configured = TRUE;

	if (!xfapplet_save_configuration (xap))
		g_warning ("Failed to save XfApplet configuration.\n");
}