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); }
static void on_view_as_activate (GtkMenuItem *item, ViewAsData *d) { GtkWidget *w, *c, *s; Bonobo_Control control; CORBA_Environment ev; CameraFile *f; int result; Bonobo_PersistStream pstream; BonoboObject *stream; const char *data = NULL; unsigned long int size; const char *type; g_return_if_fail (d->iid != NULL); CORBA_exception_init (&ev); control = bonobo_get_object (d->iid, "IDL:Bonobo/Control:1.0", &ev); if (BONOBO_EX (&ev) || (control == CORBA_OBJECT_NIL)) { CORBA_exception_free (&ev); g_warning ("Could not get control from '%s'.", d->iid); return; } w = bonobo_window_new (d->file, d->file); c = bonobo_widget_new_control_from_objref (control, CORBA_OBJECT_NIL); gtk_widget_show (c); bonobo_window_set_contents (BONOBO_WINDOW (w), c); gtk_widget_show (w); s = gtkam_status_new (_("Downloading '%s' from '%s'..."), d->file, d->folder); g_signal_emit (G_OBJECT (d->list), signals[NEW_STATUS], 0, s); gp_file_new (&f); result = gp_camera_file_get (d->camera->camera, d->folder, d->file, GP_FILE_TYPE_NORMAL, f, GTKAM_STATUS (s)->context->context); if (d->camera->multi) gp_camera_exit (d->camera->camera, NULL); if (result >= 0) { CORBA_exception_init (&ev); pstream = Bonobo_Unknown_queryInterface (control, "IDL:Bonobo/PersistStream:1.0", &ev); if (!BONOBO_EX (&ev) && (pstream != CORBA_OBJECT_NIL)) { gp_file_get_data_and_size (f, &data, &size); gp_file_get_mime_type (f, &type); stream = bonobo_stream_mem_create (data, size, TRUE, FALSE); Bonobo_PersistStream_load (pstream, bonobo_object_corba_objref (stream), type, &ev); g_object_unref (G_OBJECT (stream)); bonobo_object_release_unref (pstream, NULL); } CORBA_exception_free (&ev); } gp_file_unref (f); gtk_object_destroy (GTK_OBJECT (s)); }
Bonobo_Unknown bonobo_stream_extender_resolve (BonoboMonikerExtender *extender, const Bonobo_Moniker m, const Bonobo_ResolveOptions *options, const CORBA_char *display_name, const CORBA_char *requested_interface, CORBA_Environment *ev) { char *mime_type; char *requirements; Bonobo_Unknown object; Bonobo_Unknown stream; Bonobo_Persist persist; #ifdef G_ENABLE_DEBUG g_message ("Stream extender: '%s'", display_name); #endif if (!m) return CORBA_OBJECT_NIL; stream = Bonobo_Moniker_resolve (m, options, "IDL:Bonobo/Stream:1.0", ev); if (!stream) return CORBA_OBJECT_NIL; mime_type = get_stream_type (stream, ev); if (!mime_type) goto unref_stream_exception; requirements = g_strdup_printf ( "bonobo:supported_mime_types.has ('%s') AND repo_ids.has ('%s') AND " "repo_ids.has ('IDL:Bonobo/PersistStream:1.0')", mime_type, requested_interface); object = bonobo_activation_activate (requirements, NULL, 0, NULL, ev); #ifdef G_ENABLE_DEBUG g_message ("Attempt activate object satisfying '%s': %p", requirements, object); #endif g_free (requirements); if (ev->_major != CORBA_NO_EXCEPTION) goto unref_stream_exception; if (object == CORBA_OBJECT_NIL) { #ifdef G_ENABLE_DEBUG g_warning ("Can't find object satisfying requirements"); #endif CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_Moniker_InterfaceNotFound, NULL); goto unref_stream_exception; } persist = Bonobo_Unknown_queryInterface ( object, "IDL:Bonobo/PersistStream:1.0", ev); if (ev->_major != CORBA_NO_EXCEPTION) goto unref_object_exception; if (persist != CORBA_OBJECT_NIL) { Bonobo_PersistStream_load ( persist, stream, (const Bonobo_Persist_ContentType) mime_type, ev); bonobo_object_release_unref (persist, ev); bonobo_object_release_unref (stream, ev); return bonobo_moniker_util_qi_return ( object, requested_interface, ev); } g_free (mime_type); unref_object_exception: bonobo_object_release_unref (object, ev); unref_stream_exception: bonobo_object_release_unref (stream, ev); return CORBA_OBJECT_NIL; }