+struct _Component {
+ Container *container;
+
+ GnomeClientSite *client_site;
+ GnomeViewFrame *view_frame;
+ GnomeObjectClient *server;
+};
+
+GList *containers = NULL;
+/*
+ * Static prototypes.
+ */
+extern "C" {
+ static Container *container_new (const char *fname);
+ static void container_destroy (Container *cont);
+ static void container_open_cmd (GtkWidget *widget, Container *container);
+ static void container_close_cmd (GtkWidget *widget, Container *container);
+ static void container_exit_cmd (void);
+ static Component *container_activate_component (Container *container, char *component_goad_id);
+ static void zoom_in_cmd (GtkWidget *widget, Container *container);
+ static void zoom_out_cmd (GtkWidget *widget, Container *container);
+ static void zoom_set (Container *container);
+}
+
+/*
+ * The menus.
+ */
+static GnomeUIInfo container_file_menu [] = {
+ GNOMEUIINFO_MENU_OPEN_ITEM (container_open_cmd, NULL),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_MENU_CLOSE_ITEM(container_close_cmd, NULL),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_MENU_EXIT_ITEM (container_exit_cmd, NULL),
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo container_menu_zoom [] = {
+ { GNOME_APP_UI_ITEM, N_("_Zoom in"),
+ N_("Increase the size of objects in the PDF"),
+ zoom_in_cmd },
+ { GNOME_APP_UI_ITEM, N_("_Zoom out"),
+ N_("Decrease the size of objects in the PDF"),
+ zoom_out_cmd },
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo container_main_menu [] = {
+ GNOMEUIINFO_MENU_FILE_TREE (container_file_menu),
+ { GNOME_APP_UI_SUBTREE, N_("_Zoom"), NULL, container_menu_zoom },
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo container_toolbar [] = {
+ GNOMEUIINFO_ITEM_STOCK (
+ N_("Open"), N_("Opens an existing workbook"),
+ container_open_cmd, GNOME_STOCK_PIXMAP_OPEN),
+
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_END
+};
+
+extern "C" {
+ static gboolean
+ open_pdf (Container *container, const char *name)
+ {
+ GnomeObjectClient *object;
+ GnomeStream *stream;
+ GNOME_PersistStream persist;
+ Component *comp;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (container != NULL, FALSE);
+ g_return_val_if_fail (container->view_widget == NULL, FALSE);
+
+ comp = container_activate_component (container, "bonobo-object:image-x-pdf");
+ if (!comp || !(object = comp->server)) {
+ gnome_error_dialog (_("Could not launch bonobo object."));
+ return FALSE;
+ }
+
+ CORBA_exception_init (&ev);
+ persist = GNOME_Unknown_query_interface (
+ gnome_object_corba_objref (GNOME_OBJECT (object)),
+ "IDL:GNOME/PersistStream:1.0", &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION ||
+ persist == CORBA_OBJECT_NIL) {
+ gnome_error_dialog ("Panic: component is well broken.");
+ return FALSE;
+ }
+
+ stream = gnome_stream_fs_open (name, GNOME_Storage_READ);
+
+ if (stream == NULL) {
+ char *err = g_strconcat (_("Could not open "), name, NULL);
+ gnome_error_dialog_parented (err, GTK_WINDOW(container->app));
+ g_free (err);
+ return FALSE;
+ }
+
+ GNOME_PersistStream_load (persist,
+ (GNOME_Stream) gnome_object_corba_objref (GNOME_OBJECT (stream)), &ev);