- DOC_ROOT *doc = new DOC_ROOT();
- char s[20];
- char *p;
-
- // open PDF file
- doc->pdf = new PDFDoc(fileName);
- if (!doc->pdf->isOk()) {
- delete doc->pdf;
- delete doc;
- return gFalse;
- }
-
- doc->toplevel = gnome_app_new ("gpdf", "gpdf");
- gtk_window_set_policy(GTK_WINDOW(doc->toplevel), 1, 1, 0);
- gtk_window_set_default_size (GTK_WINDOW(doc->toplevel), 600, 400);
- doc->table = GTK_WIDGET (gtk_table_new (0, 0, 0));
- doc->appbar = GNOME_APPBAR (gnome_appbar_new (FALSE, TRUE,
- GNOME_PREFERENCES_USER));
- gnome_app_set_statusbar (GNOME_APP (doc->toplevel),
- GTK_WIDGET (doc->appbar));
- gnome_app_set_contents (GNOME_APP (doc->toplevel), doc->table);
- gnome_app_create_menus_with_data (GNOME_APP (doc->toplevel), main_menu, doc);
- gnome_app_install_menu_hints(GNOME_APP (doc->toplevel), main_menu);
-
- doc->pixmap = NULL;
- doc->area = GTK_DRAWING_AREA (gtk_drawing_area_new ());
- gtk_signal_connect (GTK_OBJECT (doc->area), "expose_event",
- (GtkSignalFunc) doc_redraw_event, NULL);
- gtk_signal_connect (GTK_OBJECT(doc->area),"configure_event",
- (GtkSignalFunc) doc_config_event, NULL);
-
- gtk_table_attach (GTK_TABLE (doc->table), GTK_WIDGET (doc->area),
- 0, 1, 1, 2,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
- 0, 0);
-
- gtk_widget_show_all (doc->toplevel);
-
- return gTrue;
+ GnomeViewFrame *view_frame;
+ GtkWidget *view_widget;
+
+ /*
+ * Create the remote view and the local ViewFrame.
+ */
+ view_frame = gnome_client_site_embeddable_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, component->container->uih);
+
+ /*
+ * Embed the view frame into the application.
+ */
+ view_widget = gnome_view_frame_get_wrapper (view_frame);
+ gtk_box_pack_start (GTK_BOX (component->views_hbox), view_widget,
+ FALSE, FALSE, 5);
+
+ /*
+ * The "user_activate" signal will be emitted when the user
+ * double clicks on the "cover". The cover is a transparent
+ * window which sits on top of the component and keeps any
+ * events (mouse, keyboard) from reaching it. When the user
+ * double clicks on the cover, the container (that's us)
+ * can choose to activate the component.
+ */
+ gtk_signal_connect (GTK_OBJECT (view_frame), "user_activate",
+ GTK_SIGNAL_FUNC (component_user_activate_request_cb), component);
+
+ /*
+ * In-place activation of a component is a two-step process.
+ * After the user double clicks on the component, our signal
+ * callback (compoennt_user_activate_request_cb()) asks the
+ * component to activate itself (see
+ * gnome_view_frame_view_activate()). The component can then
+ * choose to either accept or refuse activation. When an
+ * embedded component notifies us of its decision to change
+ * its activation state, the "view_activated" signal is
+ * emitted from the view frame. It is at that point that we
+ * actually remove the cover so that events can get through.
+ */
+ gtk_signal_connect (GTK_OBJECT (view_frame), "view_activated",
+ GTK_SIGNAL_FUNC (component_view_activated_cb), component);
+
+ /*
+ * The "user_context" signal is emitted when the user right
+ * clicks on the wrapper. We use it to pop up a verb menu.
+ */
+ gtk_signal_connect (GTK_OBJECT (view_frame), "user_context",
+ GTK_SIGNAL_FUNC (component_user_context_cb), component);
+
+ /*
+ * Show the component.
+ */
+ gtk_widget_show_all (view_widget);