Пример #1
0
static void
run_tests (void)
{
	BonoboEventSource *es;
	CORBA_Environment ev;
	CORBA_any *value;
	char *mask;

	CORBA_exception_init (&ev);

	g_source_remove (idle_id);

	value = bonobo_arg_new (BONOBO_ARG_LONG);

	es = bonobo_event_source_new ();
	g_assert (es != NULL);
	
	mask = "a/test";
	bonobo_event_source_client_add_listener (BONOBO_OBJREF (es), event_cb, mask, &ev, mask);

	mask = "=a/test";
	bonobo_event_source_client_add_listener (BONOBO_OBJREF (es), event_cb, mask, &ev, mask);
	
	bonobo_event_source_notify_listeners (es, "a/test", value, &ev); 
	CHECK_RESULT (&ev, 2, 1);

	bonobo_event_source_notify_listeners (es, "a/test/xyz", value, &ev); 
	CHECK_RESULT (&ev, 3, 1);

	bonobo_event_source_notify_listeners (es, "a/tes", value, &ev); 
	CHECK_RESULT (&ev, 3, 1);

	bonobo_event_source_notify_listeners (es, "test", value, &ev); 
	CHECK_RESULT (&ev, 3, 1);

	bonobo_event_source_notify_listeners (es, "a/test", value, &ev); 
	CHECK_RESULT (&ev, 5, 2);
	
	bonobo_event_source_notify_listeners (es, "a/test:", value, &ev); 
	CHECK_RESULT (&ev, 6, 2);

	bonobo_event_source_notify_listeners (es, "a/test:xyz", value, &ev); 
	CHECK_RESULT (&ev, 7, 2);

	bonobo_event_source_notify_listeners (es, "a/", value, &ev); 
	CHECK_RESULT (&ev, 7, 2);

	bonobo_event_source_notify_listeners (es, "a/test1:xyz", value, &ev); 
	CHECK_RESULT (&ev, 8, 2);

	bonobo_object_unref (BONOBO_OBJECT (es));

	bonobo_main_quit ();
}
Пример #2
0
static void
impl_ComponentView_getControls(PortableServer_Servant servant,
		 Bonobo_Control *side_control,
		 Bonobo_Control *view_control,
		 Bonobo_Control *statusbar_control,
		 CORBA_Environment *ev)
{
	EComponentView *ecv = (EComponentView *)bonobo_object_from_servant(servant);

	*side_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->side_control), ev);
	*view_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->view_control), ev);
	*statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->statusbar_control), ev);
}
Пример #3
0
static GNOME_C_Camera
impl_connect (PortableServer_Servant servant, const CORBA_char *manufacturer,
	      const CORBA_char *model, const CORBA_char *port, 
	      CORBA_Environment *ev)
{
	KncCMngr *m = KNC_C_MNGR (bonobo_object (servant));
	KncCCamera *c;
	GPPort *p = NULL;
	GPPortInfo info;
	unsigned int i;

	gp_port_new (&p);
	for (i = 0; i < MAX (gp_port_info_list_count (m->priv->il), 0); i++) {
		gp_port_info_list_get_info (m->priv->il, i, &info);
		if (!strcmp (info.name, port)) {
			gp_port_set_info (p, info);
			c = knc_c_camera_new (manufacturer, model, p, ev);
			if (BONOBO_EX (ev)) return CORBA_OBJECT_NIL;
			return CORBA_Object_duplicate (BONOBO_OBJREF (c), ev);
		}
	}
	gp_port_free (p);
	
	CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_C_Error, NULL);
	return CORBA_OBJECT_NIL;
}
static void
set_data (BonoboWidget *control, const char *string)
{
	Bonobo_PersistStream persist;
	BonoboObject *bstream;

	CORBA_Environment ev;

	persist = (Bonobo_PersistStream) Bonobo_Unknown_queryInterface (
		       bonobo_widget_get_objref (control), 
		       "IDL:Bonobo/PersistStream:1.0", &ev);
			
	if (persist == CORBA_OBJECT_NIL) {
			g_object_ref_sink (G_OBJECT (control));
			return ;
	}

	bstream = bonobo_stream_mem_create (string, strlen (string), TRUE, FALSE);

	CORBA_exception_init (&ev);
	Bonobo_PersistStream_load (persist, BONOBO_OBJREF (bstream),
				   "text/calendar", &ev);
	bonobo_object_unref (BONOBO_OBJECT (bstream));
	Bonobo_Unknown_unref (persist, &ev);
	CORBA_Object_release (persist, &ev);
}
/**
 * bonobo_zoomable_frame_bind_to_zoomable:
 * @zoomable_frame: A BonoboZoomableFrame object.
 * @zoomable: The CORBA object for the BonoboZoomable embedded
 * in this BonoboZoomableFrame.
 *
 * Associates @zoomable with this @zoomable_frame.
 */
void
bonobo_zoomable_frame_bind_to_zoomable (BonoboZoomableFrame *zoomable_frame,
					Bonobo_Zoomable      zoomable,
					CORBA_Environment   *opt_ev)
{
	CORBA_Environment *ev, temp_ev;

	g_return_if_fail (zoomable != CORBA_OBJECT_NIL);
	g_return_if_fail (BONOBO_IS_ZOOMABLE_FRAME (zoomable_frame));

	if (zoomable_frame->priv->zoomable != CORBA_OBJECT_NIL)
		CORBA_Object_release (zoomable_frame->priv->zoomable, NULL);

	zoomable_frame->priv->zoomable = CORBA_Object_duplicate (zoomable, NULL);

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

	Bonobo_Zoomable_setFrame (zoomable, BONOBO_OBJREF (zoomable_frame), ev);

	if (BONOBO_EX (ev))
		bonobo_object_check_env (BONOBO_OBJECT (zoomable_frame), zoomable, ev);

	if (!opt_ev)
		CORBA_exception_free (&temp_ev);
}
Пример #6
0
/**
 * spi_accessible_new_return:
 * @o: an AtkObject or NULL
 * @release_ref: whether to unref this AtkObject before return
 * @ev: a CORBA environment
 * 
 * A helper function to instantiate a CORBA accessiblility
 * proxy from an AtkObject.
 * 
 * Return value: the proxy or CORBA_OBJECT_NIL
 **/
Accessibility_Accessible
spi_accessible_new_return (AtkObject         *o,
			   gboolean           release_ref,
			   CORBA_Environment *ev)
{
  SpiAccessible *accessible;
  Accessibility_Accessible retval;

  if (!o)
    {
      return CORBA_OBJECT_NIL;
    }
  else if (SPI_IS_REMOTE_OBJECT (o))
    {
      retval = spi_remote_object_get_accessible (SPI_REMOTE_OBJECT (o));
    }
  else
    {
      accessible = spi_accessible_construct (SPI_ACCESSIBLE_TYPE, o);
      retval = CORBA_Object_duplicate (BONOBO_OBJREF (accessible), ev); 
    }

  if (release_ref)
    {
      g_object_unref (G_OBJECT (o));
    }
  
  return retval;
}
Пример #7
0
static TestGnomeApp *
create_newwin(gboolean normal, gchar *appname, gchar *title)
{
        TestGnomeApp *app;

	app = g_new0 (TestGnomeApp, 1);
	app->app = bonobo_window_new (appname, title);
	if (!normal) {
		g_signal_connect(app->app, "delete_event",
				 G_CALLBACK(quit_test), app);
	};
	app->ui_container = bonobo_ui_engine_get_ui_container (
		bonobo_window_get_ui_engine (BONOBO_WINDOW (app->app)));

	app->ui_component = bonobo_ui_component_new (appname);
	bonobo_ui_component_set_container (app->ui_component,
					   BONOBO_OBJREF(app->ui_container),
					   NULL);

	/* This is a test program only run on the build system, so
	 * it's OK to use GNOMEUISRCDIR which is valid of course only
	 * on the build system.
	 */
	bonobo_ui_util_set_ui (app->ui_component, "",
			       GNOMEUISRCDIR "/testgnome.xml",
			       appname, NULL);

	bonobo_ui_component_add_verb_list_with_data (app->ui_component, verbs, app);
	
	return app;
}
Пример #8
0
/*
 * CORBA Accessibility::Accessible::getRelationSet method implementation
 */
static Accessibility_RelationSet *
impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
						CORBA_Environment     *ev)
{
  Accessibility_RelationSet *retval;
  gint n_relations = 0;
  gint i;
  AtkRelationSet *relation_set;
  AtkObject      *object = get_atkobject_from_servant (servant);

  bonobo_return_val_if_fail (object != NULL, NULL, ev);

  relation_set = atk_object_ref_relation_set (object);

  if (relation_set)
    n_relations = atk_relation_set_get_n_relations (relation_set);

  retval = CORBA_sequence_Accessibility_Relation__alloc ();
  retval->_length = retval->_maximum = n_relations;
  retval->_buffer = CORBA_sequence_Accessibility_Relation_allocbuf (n_relations);
  CORBA_sequence_set_release (retval, CORBA_TRUE);
	  
  for (i = 0; i < n_relations; ++i)
    {
      retval->_buffer[i] =
        CORBA_Object_duplicate (
          BONOBO_OBJREF (
            spi_relation_new (atk_relation_set_get_relation (relation_set, i))),
	  NULL);
    }
  
  return retval;
}
Пример #9
0
static void
create_bag (void)
{
	PropData   *pd = g_new0 (PropData, 1);
	BonoboArg  *def;
	char       *dstr;
	CORBA_char *ior;
	FILE       *iorfile;

	pd->i = 987654321;
	pd->l = 123456789;
	pd->b = TRUE;
	pd->f = 2.71828182845;
	pd->d = 3.14159265358;
	pd->s = "Hello world";

	/* Create the property bag. */
	pb = bonobo_property_bag_new (get_prop, set_prop, pd);

	dstr = "Testing 1 2 3";

	/* Add properties */
	bonobo_property_bag_add (pb, "int-test", PROP_INTEGER_TEST,
				 BONOBO_ARG_INT, NULL, dstr, 0);

	def = bonobo_arg_new (BONOBO_ARG_STRING);
	BONOBO_ARG_SET_STRING (def, "a default string");

	bonobo_property_bag_add (pb, "string-test", PROP_STRING_TEST,
				 BONOBO_ARG_STRING, def, dstr, 
				 Bonobo_PROPERTY_READABLE |
				 Bonobo_PROPERTY_WRITEABLE);

	bonobo_property_bag_add (pb, "long-test", PROP_LONG_TEST,
				 BONOBO_ARG_LONG, NULL, dstr, 0);

	bonobo_property_bag_add (pb, "boolean-test", PROP_BOOLEAN_TEST,
				 BONOBO_ARG_BOOLEAN, NULL, dstr, 0);

	def = bonobo_arg_new (BONOBO_ARG_FLOAT);
	BONOBO_ARG_SET_FLOAT (def, 0.13579);
	bonobo_property_bag_add (pb, "float-test", PROP_FLOAT_TEST,
				 BONOBO_ARG_FLOAT, def, dstr, 0);

	bonobo_property_bag_add (pb, "double-test", PROP_DOUBLE_TEST,
				 BONOBO_ARG_DOUBLE, NULL, dstr, 0);

	iorfile = fopen ("iorfile", "wb");

	/* Print out the IOR for this object. */
	ior = CORBA_ORB_object_to_string (orb, BONOBO_OBJREF (pb), &ev);

	/* So we can tee the output to compare */
	fwrite (ior, strlen (ior), 1, iorfile);
	fclose (iorfile);

	CORBA_free (ior);
}
Пример #10
0
static GNOME_C_File
impl_get_file (PortableServer_Servant servant, CORBA_unsigned_long id,
	       CORBA_Environment *ev)
{
	KncCDir *d = KNC_C_DIR (bonobo_object (servant));
	KncCFile *f = knc_c_file_new (d->priv->c, id, ev);
	if (BONOBO_EX (ev)) return CORBA_OBJECT_NIL;
	return CORBA_Object_duplicate (BONOBO_OBJREF (f), ev);
}
Пример #11
0
Bonobo_Listener
bonobo_event_source_client_add_listener_full (Bonobo_Unknown     object,
        GClosure          *event_callback,
        const char        *opt_mask,
        CORBA_Environment *opt_ev)
{
    BonoboListener    *listener = NULL;
    Bonobo_Listener    corba_listener = CORBA_OBJECT_NIL;
    Bonobo_Unknown     es;
    CORBA_Environment *ev, temp_ev;

    g_return_val_if_fail (event_callback != NULL, CORBA_OBJECT_NIL);

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

    es = Bonobo_Unknown_queryInterface (object,
                                        "IDL:Bonobo/EventSource:1.0", ev);

    if (BONOBO_EX (ev) || !es)
        goto add_listener_end;

    if (!(listener = bonobo_listener_new_closure (event_callback)))
        goto add_listener_end;

    corba_listener = BONOBO_OBJREF (listener);

    if (opt_mask)
        Bonobo_EventSource_addListenerWithMask (
            es, corba_listener, opt_mask, ev);
    else
        Bonobo_EventSource_addListener (
            es, corba_listener, ev);

    corba_listener = CORBA_Object_duplicate (corba_listener, ev);

    bonobo_object_unref (BONOBO_OBJECT (listener));

    bonobo_object_release_unref (es, ev);

add_listener_end:

    if (!opt_ev) {
        if (BONOBO_EX (ev)) {
            char *text = bonobo_exception_get_text (ev);
            g_warning ("add_listener failed '%s'", text);
            g_free (text);
        }
        CORBA_exception_free (ev);
    }

    return corba_listener;
}
Пример #12
0
static void
check_string (const char *prefix, const char *escaped, const char *unescaped)
{
	BonoboMoniker *moniker;
	const char    *const_str;
	char          *str;
	char          *s, *name;
	CORBA_Environment ev;
	CORBA_long        equal;

	moniker = bonobo_moniker_construct (
		g_object_new (bonobo_moniker_get_type (), NULL), prefix);
	
	name = g_strconcat (prefix, escaped, NULL);
	bonobo_moniker_set_name (moniker, name);

	const_str = bonobo_moniker_get_name (moniker);
	fprintf (stderr, "'%s' == '%s'\n", unescaped, const_str);
	g_assert (!strcmp (const_str, unescaped));

	CORBA_exception_init (&ev);
	equal = Bonobo_Moniker_equal (BONOBO_OBJREF (moniker), name, &ev);
	g_assert (!BONOBO_EX (&ev));
	g_assert (equal);
	CORBA_exception_free (&ev);

	s = g_strconcat (prefix, escaped, NULL);
	str = bonobo_moniker_get_name_escaped (moniker);
	fprintf (stderr, "'%s' == '%s'\n", str, s);
	g_assert (!strcmp (str, s));
	g_free (str);
	g_free (s);

	g_assert (bonobo_moniker_client_equal (
		BONOBO_OBJREF (moniker), name, NULL));

	bonobo_object_unref (BONOBO_OBJECT (moniker));

	g_free (name);
}
Пример #13
0
static Bonobo_UIContainer
widget_get_uic (GtkWidget *widget)
{
  GtkWidget *top;

  top = gtk_widget_get_toplevel (widget);

  if (!BONOBO_IS_WINDOW (top))
    return CORBA_OBJECT_NIL;

  /* FIXME: Should we unref this somewhere? */
  return (Bonobo_UIContainer) BONOBO_OBJREF (bonobo_window_get_ui_container (BONOBO_WINDOW (top)));
}
Пример #14
0
/**
 * 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));
}
Пример #15
0
Bonobo_Unknown
bonobo_moniker_cache_resolve (BonoboMoniker               *moniker,
                              const Bonobo_ResolveOptions *options,
                              const CORBA_char            *requested_interface,
                              CORBA_Environment           *ev)
{
    Bonobo_Moniker parent;
    BonoboStream *stream;
    Bonobo_Stream in_stream;

    if (!strcmp (requested_interface, "IDL:Bonobo/Stream:1.0")) {

        parent = bonobo_moniker_get_parent (moniker, ev);

        if (BONOBO_EX (ev) || parent == CORBA_OBJECT_NIL)
            return CORBA_OBJECT_NIL;

        in_stream = Bonobo_Moniker_resolve (parent, options,
                                            "IDL:Bonobo/Stream:1.0",
                                            ev);

        if (BONOBO_EX (ev) || in_stream == CORBA_OBJECT_NIL) {
            bonobo_object_release_unref (parent, NULL);
            return CORBA_OBJECT_NIL;
        }

        bonobo_object_release_unref (parent, ev);

        if (BONOBO_EX (ev))
            return CORBA_OBJECT_NIL;

        stream = bonobo_stream_cache_create (in_stream, ev);

        if (BONOBO_EX (ev) || stream == CORBA_OBJECT_NIL) {
            bonobo_object_release_unref (in_stream, NULL);
            return CORBA_OBJECT_NIL;
        }

        bonobo_object_release_unref (in_stream, ev);

        if (BONOBO_EX (ev))
            return CORBA_OBJECT_NIL;

        return CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev);
    }

    return CORBA_OBJECT_NIL; /* use the extender */
}
Пример #16
0
void
bonobo_ui_component_widget_set (BonoboUIComponent  *component,
				const char         *path,
				GtkWidget          *widget,
				CORBA_Environment  *opt_ev)
{
	gpointer in_proc_servant;
	BonoboObject *in_proc_container;
	CORBA_Environment *real_ev, tmp_ev;
	Bonobo_UIContainer container;

	g_return_if_fail (widget != CORBA_OBJECT_NIL);
	g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));
	container = component->priv->container;
	g_return_if_fail (container != CORBA_OBJECT_NIL);

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

	if ((in_proc_servant = ORBit_small_get_servant (container)) &&
	    (in_proc_container = bonobo_object (in_proc_servant)) &&
	    BONOBO_IS_UI_CONTAINER (in_proc_container)) {
		BonoboUIEngine *engine;

		engine = bonobo_ui_container_get_engine (
			BONOBO_UI_CONTAINER (in_proc_container));
		g_return_if_fail (engine != NULL);
		bonobo_ui_engine_widget_set (engine, path, widget);
	} else {
		BonoboControl *control = bonobo_control_new (widget);
		Bonobo_UIContainer_setObject (
			container, path, BONOBO_OBJREF (control), real_ev);
		bonobo_object_unref (control);
	}

	if (!opt_ev && BONOBO_EX (real_ev))
		g_warning ("Serious exception setting object '%s' '%s'",
			   path, bonobo_exception_get_text (real_ev));

	if (!opt_ev)
		CORBA_exception_free (&tmp_ev);
}
Пример #17
0
/**
 * bonobo_shlib_factory_std:
 * @component_id:
 * @poa:
 * @act_impl_ptr:
 * @factory_cb:
 * @user_data:
 * @ev:
 * 
 *    A Generic std shlib routine so we don't stick a load of code
 * inside a public macro.
 * 
 * Return value: 0 on success, 1 on failure.
 **/
Bonobo_Unknown
bonobo_shlib_factory_std (const char            *component_id,
			  PortableServer_POA     poa,
			  gpointer               act_impl_ptr,
			  BonoboFactoryCallback  factory_cb,
			  gpointer               user_data,
			  CORBA_Environment     *ev)
{
	BonoboShlibFactory *f;

	f = bonobo_shlib_factory_new (
		component_id, poa,
		act_impl_ptr,
		factory_cb, user_data);

        return CORBA_Object_duplicate (BONOBO_OBJREF (f), ev);
}
Пример #18
0
static gboolean
get_camera_idle (gpointer data)
{
	IdleData *d = data;
	GnoCamCamera *gc;
	CORBA_Environment ev;
	CORBA_any any;

	CORBA_exception_init (&ev);

	/* Get the camera */
	gc = gnocam_main_get_camera (d->gm, (const gchar *) d->model,
					    (const gchar *) d->port, &ev);
	if (BONOBO_EX (&ev)) {
		GNOME_GnoCam_ErrorCode e = GNOME_GnoCam_ERROR;
		any._type = TC_GNOME_GnoCam_ErrorCode;
		any._value = &e;
	} else {
		GNOME_Camera c = BONOBO_OBJREF (gc);
		any._type = TC_GNOME_Camera;
		any._value = &c;
	}

	/* Notify */
	g_message ("Notifying...");
	Bonobo_Listener_event (d->listener, "result", &any, &ev);
	g_message ("Notified.");

	/* Clean up */
	if (gc)
		bonobo_object_idle_unref (gc);
	bonobo_object_release_unref (d->listener, NULL);
	bonobo_object_unref (d->gm);
	if (d->model)
		CORBA_free (d->model);
	if (d->port)
		CORBA_free (d->port);
	g_free (d);
	CORBA_exception_free (&ev);
	
	return (FALSE);
};
Пример #19
0
/**
 * peacock_file_control_add_property_bag:
 * @control: 
 * @widget: 
 * 
 * Map the GObject's properties to a BonoboPropertyBag for our BonoboObject.
 **/
static void
peacock_file_control_add_property_bag (BonoboControl *control,
				       GtkWidget *widget)
{
	BonoboPropertyBag *pb;
	GParamSpec **pspecs;
	guint	     n_props;

	pb = bonobo_property_bag_new (peacock_file_control_get_prop,
				      peacock_file_control_set_prop,
				      (gpointer) control);
	bonobo_control_set_properties (control, BONOBO_OBJREF (pb), NULL);
	bonobo_object_unref (BONOBO_OBJECT (pb));

	pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (widget),
						 &n_props);
	bonobo_property_bag_map_params (pb, G_OBJECT (widget),
					(const GParamSpec **) pspecs, n_props);
	g_free (pspecs);

	return;
}
Пример #20
0
/*
 * CORBA Accessibility::Accessible::getState method implementation
 */
static Accessibility_StateSet
impl_accessibility_accessible_get_state (PortableServer_Servant servant,
					 CORBA_Environment     *ev)
{
  AtkObject *object = get_atkobject_from_servant (servant);
  AtkStateSet *atk_set;
  SpiStateSet *set;
  Accessibility_StateSet retval;

  bonobo_return_val_if_fail (object != NULL, NULL, ev);

  atk_set = atk_object_ref_state_set (object);
  
  set = spi_state_set_new (atk_set);
  retval = CORBA_Object_duplicate (
				  BONOBO_OBJREF(set),
				  NULL);

  g_object_unref (atk_set);

  return retval;
}
Пример #21
0
static void
notify_listeners (GList *listeners, SpiAccessible *source, Accessibility_Event *e)
{
  GList *l;
  CORBA_Environment ev;

  CORBA_exception_init (&ev);

  for (l = listeners; l; l = l->next)
    {
      Accessibility_EventListener listener = l->data;

      e->source = bonobo_object_dup_ref (BONOBO_OBJREF (source), &ev);

      Accessibility_EventListener_notifyEvent (listener, e, &ev);
      /*
       * when this (oneway) call completes, the CORBA refcount and
       * Bonobo_Unknown refcount will be decremented by the recipient
       */
      CORBA_exception_free (&ev);
    }
}
Пример #22
0
PeacockFileClient *
peacock_file_new (PeacockWindow *window)
{
	GtkWidget *control;
	BonoboUIContainer *uiContainer;
	PeacockFileClient *fileClient;
	CORBA_Environment ev;
	CORBA_Object interface;

	uiContainer = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
	control = bonobo_widget_new_control (PEACOCK_FILE_CONTROL_OAFIID,
					     BONOBO_OBJREF (uiContainer));
	peacock_util_activate_bonobo_control (BONOBO_WIDGET (control));
	gtk_widget_show (control);

	/* Get the PersistFile interface for loading/saving. */
	CORBA_exception_init (&ev);
	interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (control)), "IDL:Bonobo/PersistFile:1.0", &ev);
	CORBA_exception_free (&ev);

	if (interface == CORBA_OBJECT_NIL) {
		g_warning ("Oh No! Control doesn't support IDL:Bonobo/PersistFile:1.0!!!");
		return NULL;
	}

	/* Initialize the PeacockFileClient struct. */
	fileClient = peacock_file_client_new ();
	fileClient->control = control;
	fileClient->persistFile = interface;
	fileClient->tabWidget = peacock_file_client_create_tab_widget (fileClient, window);

	gtk_widget_ref (fileClient->control);
	gtk_widget_ref (fileClient->tabWidget);

	/* For setting the current_file in PeacockMDI. */
	g_object_set_data (G_OBJECT (fileClient->control), PEACOCK_FILE_CLIENT_TAG, fileClient);

	return fileClient;
}
Пример #23
0
static void
print_props (void)
{
	GList *props;
	GList *l;

	/* This is a private function; we're just using it for testing. */
	props = bonobo_property_bag_get_prop_list (pb);

	for (l = props; l != NULL; l = l->next) {
		BonoboArg *arg;
		BonoboProperty *prop = l->data;
		char           *s1, *s2;

		arg = bonobo_pbclient_get_value (BONOBO_OBJREF(pb), prop->name,
						NULL, NULL);

		s1  = simple_prop_to_string (arg);

		bonobo_arg_release (arg);

		s2  = simple_prop_to_string (prop->default_value);

		g_print ("Prop %12s [%2u] %s %s %s %s %s %s\n",
			 prop->name, prop->type->kind,
			 s1, s2,
			 prop->doctitle,
			 prop->flags & Bonobo_PROPERTY_READABLE        ? "Readable"         : "NotReadable",
			 prop->flags & Bonobo_PROPERTY_WRITEABLE       ? "Writeable"        : "NotWriteable",
			 prop->flags & Bonobo_PROPERTY_NO_LISTENING    ? "NoListening" : "Listeners-enabled");

		g_free (s1);
		g_free (s2);

	}

	g_list_free (props);
}
Пример #24
0
static SampleApp *
sample_app_new (SampleDoc *doc)
{
	SampleApp *app = g_new0 (SampleApp, 1);
	GtkWidget *view;

	/* Create a document */
	app->doc = sample_doc_new ();
	if (!app->doc) {
		g_free (app);
		return NULL;
	}

	/* Create toplevel window */
	app->win = bonobo_window_new ("sample-doc-container",
				      "Sample Document container");

	gtk_window_set_default_size (GTK_WINDOW (app->win), 400, 600);
	g_signal_connect_data (G_OBJECT (app->win), "delete_event",
			       G_CALLBACK (delete_cb), app, NULL, 0);

	/* Create and merge the UI elements. */
	sample_app_fill_menu (app);

	/* Create a doc view and stuff it into a box in the toplevel. */
	app->box = gtk_vbox_new (FALSE, 10);
	bonobo_window_set_contents (BONOBO_WINDOW (app->win), app->box);

	view = sample_doc_view_new (app->doc, BONOBO_OBJREF (
		bonobo_window_get_ui_container (BONOBO_WINDOW (app->win))));
	app->doc_views = g_list_prepend (app->doc_views, view);
	app->curr_view = view;

	gtk_widget_show_all (app->win);

	return app;
}
Пример #25
0
static Bonobo_Stream
impl_GNOME_Camera_capturePreview (PortableServer_Servant servant, 
				  CORBA_Environment *ev)
{
	BonoboStream *stream;
	CameraFile *file;
	GnoCamCamera *c;

	g_message ("impl_GNOME_Camera_capturePreview");

	c = GNOCAM_CAMERA (bonobo_object_from_servant (servant));
	CR (gp_file_new (&file), ev);
	CR (gp_camera_capture_preview (c->camera, file), ev);
	if (BONOBO_EX (ev)) {
		gp_file_unref (file);
		g_message ("Returning...");
		return (CORBA_OBJECT_NIL);
	}

	stream = bonobo_stream_mem_create (file->data, file->size, TRUE, FALSE);
	gp_file_unref (file);

	return (CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev));
}
Пример #26
0
static GNOME_Evolution_ComponentView
impl_createView (PortableServer_Servant servant,
		 GNOME_Evolution_ShellView parent,
		 CORBA_Environment *ev)
{
	MailComponent *mail_component = MAIL_COMPONENT (bonobo_object_from_servant (servant));
	MailComponentPrivate *priv = mail_component->priv;
	EComponentView *component_view;
	GtkWidget *tree_widget, *vbox, *info;
	GtkWidget *view_widget;
	GtkWidget *statusbar_widget;
	char *uri;

	mail_session_set_interactive(TRUE);
	mc_startup(mail_component);

	view_widget = em_folder_browser_new ();

	tree_widget = (GtkWidget *) em_folder_tree_new_with_model (priv->model);
	em_folder_tree_set_excluded ((EMFolderTree *) tree_widget, 0);
	em_folder_tree_enable_drag_and_drop ((EMFolderTree *) tree_widget);

	if ((uri = em_folder_tree_model_get_selected (priv->model))) {
		gboolean expanded;

		expanded = em_folder_tree_model_get_expanded_uri (priv->model, uri);
		em_folder_tree_set_selected ((EMFolderTree *) tree_widget, uri, FALSE);
		em_folder_view_set_folder_uri ((EMFolderView *) view_widget, uri);

		if (!expanded)
			em_folder_tree_model_set_expanded_uri (priv->model, uri, expanded);

		g_free (uri);
	}

	em_format_set_session ((EMFormat *) ((EMFolderView *) view_widget)->preview, session);

	g_signal_connect (view_widget, "on-url", G_CALLBACK (view_on_url), mail_component);
	em_folder_view_set_statusbar ((EMFolderView*)view_widget, FALSE);

	statusbar_widget = e_task_bar_new ();
	e_activity_handler_attach_task_bar (priv->activity_handler, E_TASK_BAR (statusbar_widget));

	gtk_widget_show (tree_widget);
	gtk_widget_show (view_widget);
	gtk_widget_show (statusbar_widget);

	vbox = gtk_vbox_new(FALSE, 0);
	info = e_info_label_new("stock_mail");
	e_info_label_set_info((EInfoLabel *)info, _("Mail"), "");
	gtk_box_pack_start((GtkBox *)vbox, info, FALSE, TRUE, 0);
	gtk_box_pack_start((GtkBox *)vbox, tree_widget, TRUE, TRUE, 0);

	gtk_widget_show(info);
	gtk_widget_show(vbox);

	component_view = e_component_view_new(parent, "mail", vbox, view_widget, statusbar_widget);

	g_object_set_data((GObject *)component_view, "info-label", info);

	g_object_set_data_full((GObject *)view_widget, "e-creatable-items-handler",
			       e_user_creatable_items_handler_new("mail", create_local_item_cb, tree_widget),
			       (GDestroyNotify)g_object_unref);


	g_signal_connect (component_view->view_control, "activate", G_CALLBACK (view_control_activate_cb), view_widget);
	g_signal_connect (tree_widget, "folder-selected", G_CALLBACK (folder_selected_cb), view_widget);

	g_signal_connect((EMFolderBrowser *)view_widget, "account_search_cleared", G_CALLBACK (enable_folder_tree), tree_widget);
	g_signal_connect(((EMFolderBrowser *)view_widget), "account_search_activated", G_CALLBACK (disable_folder_tree), tree_widget);
	g_signal_connect(view_widget, "changed", G_CALLBACK(view_changed_cb), component_view);
	g_signal_connect(view_widget, "loaded", G_CALLBACK(view_changed_cb), component_view);

	g_object_set_data((GObject*)info, "folderview", view_widget);
	g_object_set_data((GObject*)view_widget, "foldertree", tree_widget);

	priv->component_view = component_view;

	return BONOBO_OBJREF(component_view);
}
Пример #27
0
BonoboObject *
circle_control_new (CommonData *com)
{
        BonoboPropertyBag  *pb;
        BonoboControl      *control;
        GParamSpec        **pspecs;
        guint               n_pspecs;
        GtkWidget *button, *frame, *spin, *hbox, *spin_label;
        GtkObject *adj;
        GSList **list = &com->list;
        GSList *li;
        ObjectData *object = NULL;

        frame = gtk_frame_new("Circle");
        hbox = gtk_hbox_new(FALSE, 2);
        gtk_container_add(GTK_CONTAINER(frame), hbox);
        button = gtk_button_new();
        gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
        spin_label = gtk_label_new ("Speed:");
        gtk_box_pack_start (GTK_BOX (hbox), spin_label, FALSE, FALSE, 0);
        adj = gtk_adjustment_new(100.0, 0.0, 1000.0, 1.0, 10.0, 0.0);
        g_signal_connect(adj, "value_changed", G_CALLBACK(set_speed), com);
        spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
        gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0);

        gtk_widget_show_all(frame);
        control = bonobo_control_new (frame);

        pb = bonobo_property_bag_new (NULL, NULL, NULL);
        bonobo_control_set_properties (control, BONOBO_OBJREF (pb), NULL);
        bonobo_object_unref (BONOBO_OBJECT (pb));

        g_signal_connect(button, "clicked", G_CALLBACK(on_press), com);

        pspecs = g_object_class_list_properties (
                G_OBJECT_GET_CLASS (button), &n_pspecs);

        bonobo_property_bag_map_params (
                pb, G_OBJECT (button), (const GParamSpec **)pspecs, n_pspecs);

        g_free (pspecs);

        bonobo_control_life_instrument (control);

        li = g_slist_last(*list);
        if (li)
        {
               object = li->data;
        }
        if (!object || object->button)
        {
                object = g_new0(ObjectData, 1);
                *list = g_slist_append(*list, object);
        }

        object->button = button;
        object->adj = GTK_ADJUSTMENT(adj);

        update_button(object, com);
        set_speed(GTK_ADJUSTMENT(adj), com);

        return BONOBO_OBJECT (control);
}
Пример #28
0
int
main (int argc, char **argv)
{
	BonoboWindow *win;
	BonoboUIComponent *componenta;
	BonoboUIComponent *componentb;
	BonoboUIComponent *componentc;
	BonoboUIContainer *container;
	Bonobo_UIContainer corba_container;
	CORBA_Environment  real_ev, *ev;
	GnomeProgram *program;
	char *txt, *fname;
	int i;

	char simplea [] =
		"<menu>\n"
		"	<submenu name=\"File\" _label=\"_Ga'\">\n"
		"		<menuitem name=\"open\" pos=\"bottom\" _label=\"_Open\" verb=\"FileOpen\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Wibble\"/>\n"
		"		<control name=\"MyControl\"/>\n"
		"		<control name=\"MyControl2\"/>\n"
		"		<control name=\"ThisIsEmpty\"/>\n"
		"		<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseA\" _tip=\"hi\""
		"		pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"	</submenu>\n"
		"</menu>";
	char keysa [] =
		"<keybindings>\n"
		"   <accel name=\"*Control*3\" id=\"MyFoo\"/>\n"
		"</keybindings>\n";
	char simpleb [] =
		"<submenu name=\"File\" _label=\"_File\">\n"
		"	<menuitem name=\"open\" _label=\"_OpenB\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Open you fool\"/>\n"
		"       <separator/>\n"
		"       <menuitem name=\"toggle\" type=\"toggle\" id=\"MyFoo\" _label=\"_ToggleMe\" _tip=\"a\" accel=\"*Control*t\"/>\n"
		"       <placeholder name=\"Nice\" delimit=\"top\"/>\n"
		"	<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseB\" _tip=\"hi\""
		"        pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"</submenu>\n";
	char simplec [] =
		"<submenu name=\"File\" _label=\"_FileC\" _tip=\"what!\">\n"
		"    <placeholder name=\"Nice\" delimit=\"top\" hidden=\"0\">\n"
		"	<menuitem name=\"fooa\" _label=\"_FooA\" type=\"radio\" group=\"foogroup\" _tip=\"Radio1\"/>\n"
		"	<menuitem name=\"foob\" _label=\"_FooB\" type=\"radio\" group=\"foogroup\" _tip=\"kippers\"/>\n"
		"	<menuitem name=\"wibble\" verb=\"ThisForcesAnError\" _label=\"_Baa\""
		"        pixtype=\"stock\" pixname=\"Open\" sensitive=\"0\" _tip=\"fish\"/>\n"
		"       <separator/>\n"
		"    </placeholder>\n"
		"</submenu>\n";
	char simpled [] =
		"<menuitem name=\"save\" _label=\"_SaveD\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip1\"/>\n";
	char simplee [] =
		"<menuitem name=\"fish\" _label=\"_Inplace\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip2\"/>\n";
	char toola [] =
		"<dockitem name=\"Toolbar\" homogeneous=\"0\" vlook=\"icon\">\n"
		"	<toolitem type=\"toggle\" name=\"foo2\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Save\""
		"        _label=\"TogSave\" _tip=\"My tooltip\" priority=\"1\"/>\n"
		"	<separator/>\n"
		"	<toolitem name=\"baa\" pixtype=\"stock\" pixname=\"Open\" _label=\"baa\" _tip=\"My 2nd tooltip\" verb=\"testme\"/>\n"
		"	<control name=\"AControl\" _tip=\"a tip on a control\" hidden=\"0\" vdisplay=\"button\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-italic\" _label=\"EntryControl\" verb=\"OpenEntry\"/>\n"
		"	<control name=\"BControl\" _tip=\"another tip on a control\" hidden=\"0\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-stop\"/>\n"
		"</dockitem>";
	char toolb [] =
		"<dockitem name=\"Toolbar\" look=\"icon\" relief=\"none\">\n"
		"	<toolitem name=\"foo1\" _label=\"Insensitive\" sensitive=\"0\" hidden=\"0\" priority=\"1\"/>\n"
		"	<toolitem type=\"toggle\" name=\"foo5\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Close\""
		"	 _label=\"TogSame\" _tip=\"My tooltip\"/>\n"
		"</dockitem>";
/*	char statusa [] =
		"<item name=\"main\">Kippers</item>\n";*/
	char statusb [] =
		"<status>\n"
		"	<item name=\"main\"/>\n"
		"	<control name=\"Progress\"/>\n"
		"</status>";

	ev = &real_ev;
	CORBA_exception_init (ev);

	free (malloc (8));

	program = gnome_program_init ("test-ui", VERSION,
			    LIBBONOBOUI_MODULE,
			    argc, argv, NULL);

	textdomain (GETTEXT_PACKAGE);

	bonobo_activate ();

	dump_prefs ();

	win = BONOBO_WINDOW (bonobo_window_new ("Win", "My Test Application"));
	container = bonobo_window_get_ui_container (win);
	
	bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win),
					  "/test-ui/UIConfig/kvps");

	corba_container = BONOBO_OBJREF (container);

	{
		GtkWidget *box = gtk_vbox_new (FALSE, 0);
		GtkWidget *button;
		GtkWidget *path_entry, *state_entry;

		button = gtk_button_new_with_label ("Press me to test!");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_quit, NULL);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Dump Xml tree");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_dump, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Popup");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_popup, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Hide toolbar");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_hide_toolbar, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		path_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (path_entry), "/commands/MyFoo");
		gtk_widget_show (GTK_WIDGET (path_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), path_entry);

		state_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (state_entry), "1");
		g_signal_connect (GTK_OBJECT (state_entry), "changed",
				    (GtkSignalFunc) cb_set_state, path_entry);
		gtk_widget_show (GTK_WIDGET (state_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), state_entry);

		gtk_widget_show (GTK_WIDGET (box));
		bonobo_window_set_contents (win, box);
	}

	g_signal_connect (GTK_OBJECT (win), "size_request", 
			    G_CALLBACK (slow_size_request), NULL);

	componenta = bonobo_ui_component_new ("A");
	bonobo_object_unref (BONOBO_OBJECT (componenta));

	componenta = bonobo_ui_component_new ("A");
	componentb = bonobo_ui_component_new ("B");
	componentc = bonobo_ui_component_new ("C");


	bonobo_ui_component_set_container (componenta, corba_container, NULL);
	bonobo_ui_component_set_container (componentb, corba_container, NULL);
	bonobo_ui_component_set_container (componentc, corba_container, NULL);

	global_component = componenta;

	fname = bonobo_ui_util_get_ui_fname (NULL, "../doc/std-ui.xml");
	if (fname && g_file_test (fname, G_FILE_TEST_EXISTS)) {
		fprintf (stderr, "\n\n--- Add std-ui.xml ---\n\n\n");
		bonobo_ui_util_set_ui (componenta, NULL, "../doc/std-ui.xml",
				       "gdm", NULL);

/*		bonobo_ui_component_set_prop (
			componenta, "/menu/Preferences",
			"pixname", "/demo/a.xpm", NULL);*/

		gtk_widget_show (GTK_WIDGET (win));

		bonobo_main ();
	} else {
		g_warning ("Can't find ../doc/std-ui.xml");
		gtk_widget_show (GTK_WIDGET (win));
	}
	g_free (fname);


	bonobo_ui_component_freeze (componenta, NULL);

	fprintf (stderr, "\n\n--- Remove A ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

/*	bonobo_ui_component_set_translate (componentb, "/status", statusa, ev);
	g_assert (!BONOBO_EX (ev));*/

	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",
				 "<popups> <popup name=\"MyStuff\"/> </popups>", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/popups/MyStuff", simpleb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/", keysa, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",   toola, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_button_new_with_label ("My Label");
		BonoboControl *control = bonobo_control_new (widget);
		BonoboUIComponent *componentp;

		g_signal_connect (GTK_OBJECT (widget), "button_press_event",
				    G_CALLBACK (do_sane_popup), control);
		componentp = bonobo_control_get_popup_ui_component (control);
#if 1
		bonobo_ui_component_set (componentp, "/", "<popups>"
					 "<popup name=\"button3\"/></popups>", ev);
		g_assert (!BONOBO_EX (ev));
		bonobo_ui_component_set_translate (
			componentp, "/popups/button3", simpleb, ev);
		g_assert (!BONOBO_EX (ev));
#endif

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta,
						"/menu/File/MyControl",
						BONOBO_OBJREF (control),
						ev);
		bonobo_object_unref (BONOBO_OBJECT (control));
		g_assert (!BONOBO_EX (ev));

		widget = gtk_menu_item_new_with_mnemonic ("_Foo item");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/menu/File/MyControl2",
						widget, ev);
	}

	{
		GtkWidget *widget = gtk_entry_new ();
		
		gtk_entry_set_text (GTK_ENTRY (widget), "Example text");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/AControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}
	{
		GtkWidget *widget;
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (tame_xpm);
		widget = bonobo_ui_toolbar_button_item_new (pixbuf, "Test Control");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/BControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}

	bonobo_ui_component_add_listener (componentb, "MyFoo", toggled_cb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",     statusb, ev);
	g_assert (!BONOBO_EX (ev));

	/* Duplicate set */
	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_add_verb_list_with_data (
		componenta, verbs, GUINT_TO_POINTER (15));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB2", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA3", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_rm (componenta, "/status", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB4", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA5", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA6>", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB7", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "", ev);
	g_assert (!BONOBO_EX (ev));

	g_assert (bonobo_ui_component_get_prop (
		componentb, "/status/main", "non-existant", ev) == NULL);
	g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_UIContainer_NonExistentAttr));
	CORBA_exception_free (ev);

  	{
 		const char *good = "<item name=\"main\">WhatA6&gt;</item>\n";

  		txt = bonobo_ui_component_get (componenta, "/status/main", TRUE, NULL);
 
 		if (!txt || strcmp (txt, good)) {
 			g_warning ("Broken merging code '%s' should be '%s'", txt, good);
 			bonobo_window_dump (win, "on fatal error");
  			g_assert_not_reached ();
  		}

		CORBA_free (txt);
  	}

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/menu", simpleb, ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_translate (componenta, "/",     toolb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_prop (componenta, "/menu/File", "label", "_Goo-wan>", ev);
	g_assert (!BONOBO_EX (ev));

	/* A 'transparent' node merge */
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("Before merge look '%s'\n", txt);
	bonobo_ui_component_set_translate (componenta, "/", "<dockitem name=\"Toolbar\"/>", ev);
	g_assert (!BONOBO_EX (ev));
	g_free (txt);
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("After merge look '%s'\n", txt);
	if (txt == NULL || strcmp (txt, "icon"))
		g_warning ("Serious transparency regression");
	g_free (txt);

	bonobo_ui_component_set_translate (componenta, "/menu/File/Nice", simplee, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_progress_bar_new ();
		BonoboControl *control = bonobo_control_new (widget);
		guint id;

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta, "/status/Progress",
						BONOBO_OBJREF (control),
						NULL);

		id = gtk_timeout_add (100, (GSourceFunc) update_progress, widget);
		g_signal_connect (GTK_OBJECT (widget), "destroy",
				    G_CALLBACK (disconnect_progress), GUINT_TO_POINTER (id));
		bonobo_object_unref (BONOBO_OBJECT (control));
	}

	bonobo_ui_component_set_status (componenta, "This is a very long status message "
					"that should cause the window to be resized if "
					"there is in fact a bug in it", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	g_warning ("Begginning stress test, this may take some time ...");
	for (i = 0; i < 100; i++) {
		bonobo_ui_component_freeze (componentc, ev);
		g_assert (!BONOBO_EX (ev));
		
		bonobo_ui_component_set_translate (componentc, "/commands",
						   "<cmd name=\"MyFoo\" sensitive=\"0\"/>", ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_set_translate (componentc, "/menu", simplec, ev);
		g_assert (!BONOBO_EX (ev));
	
		bonobo_ui_component_set_translate (componentc, "/menu/File", simpled, ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_thaw (componentc, ev);
		g_assert (!BONOBO_EX (ev));
	}
	g_warning ("Done stress test");
	bonobo_main ();
	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 2 ---\n\n\n");
	bonobo_ui_component_rm (componentb, "/", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_prop (componentc, "/menu/File/save",
				      "label", "SaveC", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 3 ---\n\n\n");
	bonobo_ui_component_rm (componentc, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 1 ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_object_unref (BONOBO_OBJECT (componenta));
	bonobo_object_unref (BONOBO_OBJECT (componentb));
	bonobo_object_unref (BONOBO_OBJECT (componentc));

	gtk_widget_destroy (GTK_WIDGET (win));

	CORBA_exception_free (ev);

	g_object_unref (program);

	return bonobo_ui_debug_shutdown ();
}
Пример #29
0
int
main (int argc, char *argv [])
{
	BonoboObject     *object;
	Bonobo_Unknown    ref;
	CORBA_Environment *ev, real_ev;

        g_thread_init (NULL);

	free (malloc (8));

	if (bonobo_init (&argc, argv) == FALSE)
		g_error ("Can not bonobo_init");
	bonobo_activate ();

	ev = &real_ev;
	CORBA_exception_init (ev);

	fprintf (stderr, "Local lifecycle\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		g_assert (bonobo_object_ref (object) == object);
		g_assert (bonobo_object_unref (BONOBO_OBJECT (object)) == NULL);

		bonobo_object_unref (BONOBO_OBJECT (object));
	}

	fprintf (stderr, "In-proc lifecycle\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		ref = CORBA_Object_duplicate (BONOBO_OBJREF (object), NULL);

		bonobo_object_release_unref (ref, NULL);
	}

	fprintf (stderr, "Query interface\n");
	{
		BonoboObject *a, *b;

		a = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));
		b = BONOBO_OBJECT (g_object_new (
			bonobo_stream_mem_get_type (), NULL));

		bonobo_object_add_interface (a, b);

		fprintf (stderr, "  invalid interface\n");
		object = bonobo_object_query_local_interface (
			a, "IDL:This/Is/Not/There:1.0");
		g_assert (object == CORBA_OBJECT_NIL);

		fprintf (stderr, "  symmetry\n");
		object = bonobo_object_query_local_interface (
			a, "IDL:Bonobo/Stream:1.0");
		g_assert (object == b);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			b, "IDL:Bonobo/Stream:1.0");
		g_assert (object == b);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			a, "IDL:Bonobo/Moniker:1.0");
		g_assert (object == a);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			b, "IDL:Bonobo/Moniker:1.0");
		g_assert (object == a);
		bonobo_object_unref (object);

		fprintf (stderr, "  remote\n");
		ref = Bonobo_Unknown_queryInterface (
			BONOBO_OBJREF (a), "IDL:Broken/1.0", ev);
		g_assert (!BONOBO_EX (ev));
		g_assert (ref == CORBA_OBJECT_NIL);

		ref = Bonobo_Unknown_queryInterface (
			BONOBO_OBJREF (a), "IDL:Bonobo/Stream:1.0", ev);
		g_assert (!BONOBO_EX (ev));
		g_assert (ref == BONOBO_OBJREF (b));
		bonobo_object_release_unref (ref, ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_object_unref (a);
	}

	fprintf (stderr, "Environment exception checks\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		g_signal_connect (G_OBJECT (object),
				  "system_exception",
				  G_CALLBACK (system_exception_cb),
				  object);

		CORBA_exception_set_system (
			ev, ex_CORBA_COMM_FAILURE,
			CORBA_COMPLETED_MAYBE);
		g_assert (BONOBO_EX (ev));

		signal_emitted = 0;
		BONOBO_OBJECT_CHECK (
			object, BONOBO_OBJREF (object), ev);
		g_assert (signal_emitted);

		CORBA_exception_free (ev);

		bonobo_object_unref (object);
	}

	fprintf (stderr, "Servant mapping...\n");
	{
		PortableServer_Servant servant;

		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		servant = (PortableServer_Servant) &object->servant;

		g_assert (bonobo_object (object) == object);
		g_assert (bonobo_object (&object->servant) == object);
		g_assert (bonobo_object_get_servant (object) == servant);
		g_assert (bonobo_object_from_servant (servant) == object);
		g_assert (bonobo_object_fast (object) == object);
		g_assert (bonobo_object_fast (servant) == object);

		bonobo_object_unref (object);
	}

	fprintf (stderr, "Ret-ex tests...\n");
	{
		g_assert (!ret_ex_test (ev));
		ex_test (ev);

		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_Bonobo_PropertyBag_NotFound, NULL);
		g_assert (ret_ex_test (ev));
		
		CORBA_exception_free (ev);
	}

	fprintf (stderr, "General error tests...\n");
	{
		bonobo_exception_general_error_set (
			ev, NULL, "a%s exception occurred", "n exceptional");
		g_assert (BONOBO_EX (ev));
		g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_GeneralError));
		g_assert (!strcmp (bonobo_exception_get_text (ev),
				   "an exceptional exception occurred"));
	}

	fprintf (stderr, "All tests passed\n");

	return bonobo_debug_shutdown ();
}