Пример #1
0
static void
impl_Bonobo_UIComponent_execVerb (PortableServer_Servant servant,
				  const CORBA_char      *cname,
				  CORBA_Environment     *ev)
{
	BonoboUIComponent *component;
	UIVerb *verb;

	component = bonobo_ui_from_servant (servant);

	bonobo_object_ref (BONOBO_OBJECT (component));
	
/*	g_warning ("TESTME: Exec verb '%s'", cname);*/

	verb = g_hash_table_lookup (component->priv->verbs, cname);
	if (verb && verb->closure)
		/* We need a funny arg order here - so for
		   our C closure we do odd things ! */
		bonobo_closure_invoke (
			verb->closure, G_TYPE_NONE,
			BONOBO_TYPE_UI_COMPONENT, component,
			G_TYPE_STRING, cname,
			G_TYPE_INVALID);
	else
		g_warning ("FIXME: verb '%s' not found, emit exception", cname);

	g_signal_emit (component, signals [EXEC_VERB], 0, cname);

	bonobo_object_unref (BONOBO_OBJECT (component));
}
Пример #2
0
int
main (int argc, char **argv)
{
	BonoboObject *context;

        g_thread_init (NULL);

	if (!bonobo_init (&argc, argv))
		g_error ("Could not initialize Bonobo");

	orb = bonobo_orb ();

	create_bag ();

	print_props ();

	/* FIXME: this is unusual, with a factory you normally
	 * want to use bonobo_running_context_auto_exit_unref */
	context = bonobo_context_running_get ();
	g_signal_connect_data (
		G_OBJECT (context), "last_unref",
		G_CALLBACK (quit_main), NULL, NULL, 0);
	bonobo_object_unref (context);

	bonobo_main ();

	return bonobo_debug_shutdown ();
}
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);
}
Пример #4
0
static void
impl_Bonobo_Listener_event (PortableServer_Servant servant, 
			    const CORBA_char      *event_name, 
			    const CORBA_any       *args, 
			    CORBA_Environment     *ev)
{
	BonoboListener *listener;

	listener = BONOBO_LISTENER (bonobo_object_from_servant (servant));

	bonobo_object_ref (BONOBO_OBJECT (listener));

	if (listener->priv->event_callback)
		bonobo_closure_invoke (
			listener->priv->event_callback,
			G_TYPE_NONE,
			BONOBO_TYPE_LISTENER,                       listener,
			G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, event_name,
			BONOBO_TYPE_STATIC_CORBA_ANY,               args,
			BONOBO_TYPE_STATIC_CORBA_EXCEPTION,         ev,
			G_TYPE_INVALID);
		
	g_signal_emit (G_OBJECT (listener),
		       signals [EVENT_NOTIFY], 0,
		       event_name, args, ev);

	bonobo_object_unref (BONOBO_OBJECT (listener));
}
Пример #5
0
static void
idle_data_destroy (gpointer user_data)
{
	IdleData *d = user_data;

	bonobo_object_unref (d->gc);

	g_free (d);
}
Пример #6
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;
}
Пример #7
0
static gboolean
remove_object (gpointer key,
               gpointer value,
               gpointer user_data)
{
    g_free (key);
    bonobo_object_unref (value);

    return TRUE;
}
Пример #8
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 ();
}
Пример #9
0
static void
test_exit (TestGnomeApp *app)
{
	bonobo_object_unref (BONOBO_OBJECT (app->ui_component));

	gtk_widget_destroy (app->app);
	
	g_free (app);

	gtk_main_quit ();
}
static void
impl_dispose (GObject *object)
{
	EvolutionConfigControl *config_control;
	EvolutionConfigControlPrivate *priv;

	config_control = EVOLUTION_CONFIG_CONTROL (object);
	priv = config_control->priv;

	if (priv->control != NULL) {
		bonobo_object_unref (BONOBO_OBJECT (priv->control));
		priv->control = NULL;
	}

	if (priv->event_source != NULL) {
		bonobo_object_unref (BONOBO_OBJECT (priv->event_source));
		priv->event_source = NULL;
	}

	(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
Пример #11
0
/**
 * bonobo_event_source_notify_listeners:
 * @event_source: the Event Source that will emit the event.
 * @event_name: Name of the event being emitted
 * @opt_value: A CORBA_any value that contains the data that is passed
 * to interested clients, or NULL for an empty value
 * @opt_ev: A CORBA_Environment where a failure code can be returned, can be NULL.
 *
 * This will notify all clients that have registered with this EventSource
 * (through the addListener or addListenerWithMask methods) of the availability
 * of the event named @event_name.  The @value CORBA::any value is passed to
 * all listeners.
 *
 * @event_name can not contain comma separators, as commas are used to
 * separate the various event names.
 */
void
bonobo_event_source_notify_listeners (BonoboEventSource *event_source,
                                      const char        *event_name,
                                      const CORBA_any   *opt_value,
                                      CORBA_Environment *opt_ev)
{
    GSList *l, *notify;
    CORBA_Environment  *ev, temp_ev;
    const BonoboArg *my_value;

    g_return_if_fail (BONOBO_IS_EVENT_SOURCE (event_source));

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

    if (!opt_value)
        my_value = bonobo_arg_new (BONOBO_ARG_NULL);
    else
        my_value = opt_value;

    notify = NULL;

    for (l = event_source->priv->listeners; l; l = l->next) {
        ListenerDesc *desc = (ListenerDesc *) l->data;

        if (desc->event_masks == NULL ||
                event_match (event_name, desc->event_masks)) {
            notify = g_slist_prepend (
                         notify,
                         CORBA_Object_duplicate (desc->listener, ev));
        }
    }

    bonobo_object_ref (BONOBO_OBJECT (event_source));

    for (l = notify; l; l = l->next) {
        Bonobo_Listener_event (l->data, event_name, my_value, ev);
        CORBA_Object_release (l->data, ev);
    }

    bonobo_object_unref (BONOBO_OBJECT (event_source));

    g_slist_free (notify);

    if (!opt_ev)
        CORBA_exception_free (ev);

    if (!opt_value)
        bonobo_arg_release ((BonoboArg *) my_value);
}
Пример #12
0
BonoboControl *
itip_bonobo_control_new (void)
{
	BonoboControl *control;
	BonoboPropertyBag *prop_bag;
	BonoboPersistStream *stream;
	GtkWidget *itip;

	itip = e_itip_control_new ();
	gtk_widget_show (itip);
	control = bonobo_control_new (itip);

	/* create a property bag */
	prop_bag = bonobo_property_bag_new (get_prop, set_prop, itip);
	bonobo_property_bag_add (prop_bag, "from_address", FROM_ADDRESS_ARG_ID, BONOBO_ARG_STRING, NULL,
				 "from_address", 0 );
	bonobo_property_bag_add (prop_bag, "view_only", VIEW_ONLY_ARG_ID, BONOBO_ARG_INT, NULL,
				 "view_only", 0 );

	bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (prop_bag)), NULL);
	bonobo_object_unref (BONOBO_OBJECT (prop_bag));

	bonobo_control_set_automerge (control, TRUE);

	stream = bonobo_persist_stream_new (pstream_load, pstream_save,
					    pstream_get_content_types,
					    "OAFIID:GNOME_Evolution_Calendar_iTip_Control:" BASE_VERSION,
					    itip);

	if (stream == NULL) {
		bonobo_object_unref (BONOBO_OBJECT (control));
		return NULL;
	}

	bonobo_object_add_interface (BONOBO_OBJECT (control),
				     BONOBO_OBJECT (stream));

	return control;
}
Пример #13
0
static BonoboObject *
bonobo_shlib_factory_new_generic (BonoboGenericFactory *factory,
				  const char           *act_iid)
{
	BonoboObject *retval;

	retval = BONOBO_GENERIC_FACTORY_CLASS (
		bonobo_shlib_factory_parent_class)->new_generic (factory, act_iid);

	/* The factory reference doesn't persist inside bonobo-activation */
	bonobo_object_unref (BONOBO_OBJECT (factory));

	return retval;
}
Пример #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
/* Free application data. */
static void
release_data (void)
{
	if (gth_application != NULL)
                bonobo_object_unref (gth_application);
                	
	free_icon_pixbufs ();

	if (gth_monitor != NULL) {
		g_object_unref (gth_monitor);
		gth_monitor = NULL;
	}

	gthumb_release ();
	eel_global_client_free ();
}
Пример #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
static gboolean
spi_application_toolkit_event_listener (GSignalInvocationHint *signal_hint,
					guint                  n_param_values,
					const GValue          *param_values,
					gpointer               data)
{
  Accessibility_Event e;
  AtkObject      *aobject;
  SpiAccessible *source;
  GSignalQuery   signal_query;
  char          *event_name;

  g_return_val_if_fail (the_app != NULL, FALSE);

  g_signal_query (signal_hint->signal_id, &signal_query);

  /* TODO: move GTK reference out of app.c into bridge */
  event_name = g_strdup_printf ("Gtk:%s:%s",
				g_type_name (signal_query.itype), 
				signal_query.signal_name);

#ifdef SPI_DEBUG  
  fprintf (stderr, "Received signal %s\n", event_name);
#endif
  
  aobject = get_atk_object_ref (g_value_get_object (param_values + 0));

  source = spi_accessible_new (aobject);
  e.type = CORBA_string_dup (event_name);
  e.source = CORBA_OBJECT_NIL;
  e.detail1 = 0;
  e.detail2 = 0;
  spi_init_any_nil (&e.any_data, 
		    spi_accessible_new_return (atk_get_root (), FALSE, NULL),
		    Accessibility_ROLE_UNKNOWN,
		    "");
  notify_listeners (the_app->toolkit_listeners, source, &e);

  bonobo_object_unref (BONOBO_OBJECT (source));
  g_object_unref (G_OBJECT (aobject));

  g_free (event_name);

  return TRUE;
}
Пример #18
0
/**
 * bonobo_item_container_remove_by_name:
 * @container: The object to operate on.
 * @name: The name of the object to remove from the container
 *
 * Removes the named object from the @container
 */
void
bonobo_item_container_remove_by_name (BonoboItemContainer *container,
                                      const char          *name)
{
    gpointer key, value;

    g_return_if_fail (name != NULL);
    g_return_if_fail (BONOBO_IS_ITEM_CONTAINER (container));

    if (!g_hash_table_lookup_extended (container->priv->objects, name,
                                       &key, &value))
        g_warning ("Removing '%s' but not in container", name);
    else {
        g_free (key);
        bonobo_object_unref (value);
        g_hash_table_remove (container->priv->objects, name);
    }
}
Пример #19
0
static void
impl_Bonobo_UIComponent_uiEvent (PortableServer_Servant             servant,
				 const CORBA_char                  *id,
				 const Bonobo_UIComponent_EventType type,
				 const CORBA_char                  *state,
				 CORBA_Environment                 *ev)
{
	BonoboUIComponent *component;

	component = bonobo_ui_from_servant (servant);

/*	g_warning ("TESTME: Event '%s' '%d' '%s'\n", path, type, state);*/

	bonobo_object_ref (BONOBO_OBJECT (component));

	g_signal_emit (component, signals [UI_EVENT], 0, id, type, state);

	bonobo_object_unref (BONOBO_OBJECT (component));
}
static void
e_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
	ECalView *view;
	ECalViewPrivate *priv;

	view = E_CAL_VIEW (object);
	priv = view->priv;

	switch (property_id) {
	case PROP_VIEW:
		if (priv->view != CORBA_OBJECT_NIL)
			bonobo_object_release_unref (priv->view, NULL);

		priv->view = bonobo_object_dup_ref (g_value_get_pointer (value), NULL);
		break;
	case PROP_LISTENER:
		if (priv->listener) {
			g_signal_handlers_disconnect_matched (priv->listener, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
			bonobo_object_unref (BONOBO_OBJECT (priv->listener));
		}

		priv->listener = bonobo_object_ref (g_value_get_pointer (value));

		g_signal_connect (G_OBJECT (priv->listener), "objects_added",
				  G_CALLBACK (objects_added_cb), view);
		g_signal_connect (G_OBJECT (priv->listener), "objects_modified",
				  G_CALLBACK (objects_modified_cb), view);
		g_signal_connect (G_OBJECT (priv->listener), "objects_removed",
				  G_CALLBACK (objects_removed_cb), view);
		g_signal_connect (G_OBJECT (priv->listener), "view_progress",
				  G_CALLBACK (view_progress_cb), view);
		g_signal_connect (G_OBJECT (priv->listener), "view_done",
				  G_CALLBACK (view_done_cb), view);
		break;
	case PROP_CLIENT:
		priv->client = E_CAL (g_value_dup_object (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
Пример #21
0
/**
 * bonobo_ui_component_unset_container:
 * @component: the component
 * 
 * This dis-associates the @component from its associated
 * #BonoboUIContainer.
 **/
void
bonobo_ui_component_unset_container (BonoboUIComponent *component,
				     CORBA_Environment *opt_ev)
{
	Bonobo_UIContainer container;

	g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));

	bonobo_object_ref (BONOBO_OBJECT (component));

	container = component->priv->container;
	component->priv->container = CORBA_OBJECT_NIL;

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

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

		Bonobo_UIContainer_deregisterComponent (container, name, ev);
		
		if (!opt_ev && BONOBO_EX (ev)) {
			char *err;
			g_warning ("Serious exception deregistering component '%s'",
				   (err = bonobo_exception_get_text (ev)));
			g_free (err);
		}

		CORBA_Object_release (container, ev);

		if (!opt_ev)
			CORBA_exception_free (&temp_ev);
	}

	bonobo_object_unref (BONOBO_OBJECT (component));
}
Пример #22
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);
};
Пример #23
0
/**
 * bonobo_ui_component_add_verb_list_with_data:
 * @component: the component
 * @list: the list of verbs
 * @user_data: the user data passed to the verb callbacks
 * 
 * This is a helper function to save registering verbs individualy
 * it allows registration of a great batch of verbs at one time
 * in a list of #BonoboUIVerb terminated by #BONOBO_UI_VERB_END
 **/
void
bonobo_ui_component_add_verb_list_with_data (BonoboUIComponent  *component,
					     const BonoboUIVerb *list,
					     gpointer            user_data)
{
	const BonoboUIVerb *l;

	g_return_if_fail (list != NULL);
	g_return_if_fail (BONOBO_IS_UI_COMPONENT (component));

	bonobo_object_ref (BONOBO_OBJECT (component));

	for (l = list; l && l->cname; l++) {
		bonobo_ui_component_add_verb (
			component, l->cname, l->cb,
			user_data ? user_data : l->user_data);
	}

	bonobo_object_unref (BONOBO_OBJECT (component));
}
Пример #24
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);
}
Пример #25
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;
}
/* Finalize handler for the calendar view */
static void
e_cal_view_finalize (GObject *object)
{
	ECalView *view;
	ECalViewPrivate *priv;

	g_return_if_fail (object != NULL);
	g_return_if_fail (E_IS_CAL_VIEW (object));

	view = E_CAL_VIEW (object);
	priv = view->priv;

	/* The server keeps a copy of the view listener, so we must unref it */
	g_signal_handlers_disconnect_matched (priv->listener, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
	bonobo_object_unref (BONOBO_OBJECT (priv->listener));

	if (priv->view != CORBA_OBJECT_NIL)
		bonobo_object_release_unref (priv->view, NULL);

	g_free (priv);

	if (G_OBJECT_CLASS (parent_class)->finalize)
		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
Пример #27
0
BonoboControl *
eab_vcard_control_new (void)
{
    BonoboControl       *control;
    BonoboPersistStream *stream;
    GtkWidget	    *display;
    GtkWidget           *button1, *button2;
    GtkWidget           *bbox;
    GtkWidget           *vbox;

    EABVCardControl    *vcard_control = g_new (EABVCardControl, 1);

    vcard_control->card_list = NULL;
    vcard_control->display = NULL;
    vcard_control->label = NULL;

    vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;

    /* Create the control. */

    display = eab_contact_display_new ();
    vcard_control->display = EAB_CONTACT_DISPLAY (display);

    bbox = gtk_hbutton_box_new ();
    gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
    gtk_box_set_spacing (GTK_BOX (bbox), 12);

    button1 = gtk_button_new_with_label(_("Show Full vCard"));
    g_signal_connect (button1, "clicked",
                      G_CALLBACK (toggle_full_vcard), vcard_control);
    gtk_box_pack_start (GTK_BOX (bbox), button1, FALSE, FALSE, 0);

    button2 = gtk_button_new_with_label(_("Save in addressbook"));
    g_signal_connect (button2, "clicked",
                      G_CALLBACK (save_in_addressbook), vcard_control);
    gtk_box_pack_start (GTK_BOX (bbox), button2, FALSE, FALSE, 0);

    /* This is intentionally not shown. */
    vcard_control->label = gtk_label_new ("");

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), display, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), vcard_control->label, TRUE, TRUE, 0);
    gtk_widget_show_all (bbox);
    gtk_widget_show (display);
    gtk_widget_show (vbox);

    control = bonobo_control_new (vbox);

    g_object_weak_ref (G_OBJECT (control), free_struct, vcard_control);

    stream = bonobo_persist_stream_new (pstream_load, pstream_save,
                                        pstream_get_content_types,
                                        VCARD_CONTROL_ID,
                                        vcard_control);

    if (stream == NULL) {
        bonobo_object_unref (BONOBO_OBJECT (control));
        return NULL;
    }

    bonobo_object_add_interface (BONOBO_OBJECT (control),
                                 BONOBO_OBJECT (stream));

    return control;
}
Пример #28
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);
}
Пример #29
0
static void
no_windows_left_cb (EShell *shell, gpointer data)
{
	bonobo_object_unref (BONOBO_OBJECT (shell));
	bonobo_main_quit ();
}
Пример #30
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 ();
}