+
+ static void
+ set_ok (GtkWidget *widget, gboolean *dialog_result)
+ {
+ *dialog_result = TRUE;
+ gtk_main_quit ();
+ }
+
+ static guint
+ file_dialog_delete_event (GtkWidget *widget, GdkEventAny *event)
+ {
+ gtk_main_quit ();
+ return TRUE;
+ }
+
+ static void
+ container_open_cmd (GtkWidget *widget, Container *container)
+ {
+ GtkFileSelection *fsel;
+ gboolean accepted = FALSE;
+
+ fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Load file")));
+ gtk_window_set_modal (GTK_WINDOW (fsel), TRUE);
+
+ gtk_window_set_transient_for (GTK_WINDOW (fsel),
+ GTK_WINDOW (container->app));
+
+ /* Connect the signals for Ok and Cancel */
+ gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked",
+ GTK_SIGNAL_FUNC (set_ok), &accepted);
+ gtk_signal_connect (GTK_OBJECT (fsel->cancel_button), "clicked",
+ GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+ gtk_window_set_position (GTK_WINDOW (fsel), GTK_WIN_POS_MOUSE);
+
+ /*
+ * Make sure that we quit the main loop if the window is destroyed
+ */
+ gtk_signal_connect (GTK_OBJECT (fsel), "delete_event",
+ GTK_SIGNAL_FUNC (file_dialog_delete_event), NULL);
+
+ /* Run the dialog */
+ gtk_widget_show (GTK_WIDGET (fsel));
+ gtk_grab_add (GTK_WIDGET (fsel));
+ gtk_main ();
+
+ if (accepted) {
+ char *name = gtk_file_selection_get_filename (fsel);
+
+ if (name [strlen (name)-1] != '/') {
+ char *fname = g_strdup (name);
+ if (container->view_widget) /* any sort of MDI sucks :-] */
+ container = container_new (fname);
+ else {
+ if (!open_pdf (container, fname))
+ container_destroy (container);
+ }
+ g_free (fname);
+ } else {
+ GtkWidget *dialog;
+ dialog = gnome_message_box_new ("Can't open a directory",
+ GNOME_MESSAGE_BOX_ERROR,
+ GNOME_STOCK_BUTTON_OK, NULL);
+ gnome_dialog_set_parent (GNOME_DIALOG (dialog),
+ GTK_WINDOW (container->app));
+ gnome_dialog_run (GNOME_DIALOG (dialog));
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (fsel));
+ }
+
+ static void
+ component_destroy (Component *component)
+ {
+ CORBA_Environment ev;
+ g_return_if_fail (component != NULL);
+
+ CORBA_exception_init (&ev);
+
+ if (component->server)
+ GNOME_Unknown_unref (
+ gnome_object_corba_objref (GNOME_OBJECT (component->server)), &ev);
+ component->server = NULL;
+
+ CORBA_exception_free (&ev);
+ }
+
+ static void
+ container_destroy (Container *cont)
+ {
+ containers = g_list_remove (containers, cont);
+ if (cont->app)
+ gtk_widget_destroy (cont->app);
+
+ if (cont->component)
+ component_destroy (cont->component);
+ cont->component = NULL;
+
+ cont->app = NULL;
+
+ g_free (cont);
+ if (!containers)
+ gtk_main_quit ();
+ }
+
+ static void
+ container_close_cmd (GtkWidget *widget, Container *cont)
+ {
+ container_destroy (cont);
+ }
+
+ static void
+ container_exit_cmd (void)
+ {
+ while (containers)
+ container_destroy ((Container *)containers->data);
+ }
+
+
+static void
+container_about_cmd (GtkWidget *widget, Container *container)
+{
+ GtkWidget *about;
+ int i;
+
+ const gchar *authors[] = {
+ N_("Derek B. Noonburg, main author"),
+ N_("Michael Meeks, GNOME port maintainer."),
+ N_("Miguel de Icaza."),
+ N_("Nat Friedman."),
+ NULL
+ };
+
+#ifdef ENABLE_NLS
+ for (i = 0; authors[i] != NULL; i++)
+ authors [i] = _(authors [i]);
+#endif
+
+ about = gnome_about_new (_("GPDF"), VERSION,
+ _("(C) 1996-1999 Derek B. Noonburg."),
+ authors, NULL, NULL);
+
+ gnome_dialog_set_parent (GNOME_DIALOG (about), GTK_WINDOW (container->app));
+ gnome_dialog_set_close (GNOME_DIALOG (about), TRUE);
+ gtk_widget_show (about);
+}
+}
+
+static void
+container_set_view (Container *container, Component *component)
+{
+ GnomeViewFrame *view_frame;
+ GtkWidget *view_widget;
+
+ /*
+ * Create the remote view and the local ViewFrame.
+ */
+ view_frame = gnome_client_site_new_view (component->client_site);
+ component->view_frame = view_frame;
+
+ /*
+ * Set the GnomeUIHandler for this ViewFrame. That way, the
+ * embedded component can get access to our UIHandler server
+ * so that it can merge menu and toolbar items when it gets
+ * activated.
+ */
+ gnome_view_frame_set_ui_handler (view_frame, container->uih);
+
+ /*
+ * Embed the view frame into the application.
+ */
+ view_widget = gnome_view_frame_get_wrapper (view_frame);
+ container->view_widget = view_widget;
+ container->component = component;
+
+ /*
+ * Show the component.
+ */
+ gtk_scrolled_window_add_with_viewport (container->scroll, view_widget);
+
+ /*
+ * Activate it ( get it to merge menus etc. )
+ */
+ gnome_view_frame_view_activate (view_frame);
+
+ gtk_widget_show_all (GTK_WIDGET (container->scroll));
+}
+
+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);