+static GnomeObjectClient *
+container_launch_component (GnomeClientSite *client_site,
+ GnomeContainer *container,
+ char *component_goad_id)
+{
+ GnomeObjectClient *object_server;
+
+ /*
+ * Launch the component.
+ */
+ object_server = gnome_object_activate_with_goad_id (
+ NULL, component_goad_id, GOAD_ACTIVATE_SHLIB, NULL);
+
+ if (object_server == NULL)
+ return NULL;
+
+ /*
+ * Bind it to the local ClientSite. Every embedded component
+ * has a local GnomeClientSite object which serves as a
+ * container-side point of contact for the embeddable. The
+ * container talks to the embeddable through its ClientSite
+ */
+ if (!gnome_client_site_bind_embeddable (client_site, object_server)) {
+ gnome_object_unref (GNOME_OBJECT (object_server));
+ return NULL;
+ }
+
+ /*
+ * The GnomeContainer object maintains a list of the
+ * ClientSites which it manages. Here we add the new
+ * ClientSite to that list.
+ */
+ gnome_container_add (container, GNOME_OBJECT (client_site));
+
+ return object_server;
+}
+
+/*
+ * Use query_interface to see if `obj' has `interface'.
+ */
+static gboolean
+gnome_object_has_interface (GnomeObject *obj, char *interface)
+{
+ CORBA_Environment ev;
+ CORBA_Object requested_interface;
+
+ CORBA_exception_init (&ev);
+
+ requested_interface = GNOME_Unknown_query_interface (
+ gnome_object_corba_objref (obj), interface, &ev);
+
+ CORBA_exception_free (&ev);
+
+ if (!CORBA_Object_is_nil(requested_interface, &ev) &&
+ ev._major == CORBA_NO_EXCEPTION)
+ {
+ /* Get rid of the interface we've been passed */
+ CORBA_Object_release (requested_interface, &ev);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+extern "C" {
+ static Component *
+ container_activate_component (Container *container, char *component_goad_id)
+ {
+ Component *component;
+ GnomeClientSite *client_site;
+ GnomeObjectClient *server;
+
+ /*
+ * The ClientSite is the container-side point of contact for
+ * the Embeddable. So there is a one-to-one correspondence
+ * between GnomeClientSites and GnomeEmbeddables. */
+ client_site = gnome_client_site_new (container->container);
+
+ /*
+ * A GnomeObjectClient is a simple wrapper for a remote
+ * GnomeObject (a server supporting GNOME::Unknown).
+ */
+ server = container_launch_component (client_site, container->container,
+ component_goad_id);
+ if (server == NULL) {
+ char *error_msg;
+
+ error_msg = g_strdup_printf (_("Could not launch Embeddable %s!"),
+ component_goad_id);
+ gnome_warning_dialog (error_msg);
+ g_free (error_msg);
+
+ return NULL;
+ }
+
+ /*
+ * Create the internal data structure which we will use to
+ * keep track of this component.
+ */
+ component = g_new0 (Component, 1);
+ component->container = container;
+ component->client_site = client_site;
+ component->server = server;
+
+ container_set_view (container, component);
+
+ return component;
+ }
+
+ static void
+ filenames_dropped (GtkWidget * widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ Container *container)
+ {
+ GList *names, *tmp_list;
+
+ names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
+ tmp_list = names;
+
+ while (tmp_list) {
+ const char *fname = (const char *)tmp_list->data;
+
+ if (fname) {
+ if (container->view_widget)
+ container = container_new (fname);
+ else
+ open_pdf (container, fname);
+ }
+
+ tmp_list = g_list_next (tmp_list);
+ }
+ }
+}
+
+static void
+container_create_menus (Container *container)
+{
+ GnomeUIHandlerMenuItem *menu_list;
+
+ gnome_ui_handler_create_menubar (container->uih);
+
+ /*
+ * Create the basic menus out of UIInfo structures.
+ */
+ menu_list = gnome_ui_handler_menu_parse_uiinfo_list_with_data (container_main_menu, container);
+ gnome_ui_handler_menu_add_list (container->uih, "/", menu_list);
+ gnome_ui_handler_menu_free_list (menu_list);
+}
+
+static void
+container_create_toolbar (Container *container)
+{
+ GnomeUIHandlerToolbarItem *toolbar;
+
+ gnome_ui_handler_create_toolbar (container->uih, "pdf");
+ toolbar = gnome_ui_handler_toolbar_parse_uiinfo_list_with_data (container_toolbar, container);
+ gnome_ui_handler_toolbar_add_list (container->uih, "/", toolbar);
+ gnome_ui_handler_toolbar_free_list (toolbar);
+}
+
+static Container *
+container_new (const char *fname)