+ 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)
+{
+ BonoboUIHandlerMenuItem *menu_list;
+
+ bonobo_ui_handler_create_menubar (container->uih);
+
+ /*
+ * Create the basic menus out of UIInfo structures.
+ */
+ menu_list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (container_main_menu, container);
+ bonobo_ui_handler_menu_add_list (container->uih, "/", menu_list);
+ bonobo_ui_handler_menu_free_list (menu_list);
+}
+
+static void
+container_create_toolbar (Container *container)
+{
+ BonoboUIHandlerToolbarItem *toolbar;
+
+ bonobo_ui_handler_create_toolbar (container->uih, "pdf");
+ toolbar = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (container_toolbar, container);
+ bonobo_ui_handler_toolbar_add_list (container->uih, "/pdf/", toolbar);
+ bonobo_ui_handler_toolbar_free_list (toolbar);
+}
+
+static Container *
+container_new (const char *fname)
+{
+ Container *container;
+ static GtkTargetEntry drag_types[] =
+ {
+ { "text/uri-list", 0, 0 },
+ };
+ static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
+
+ container = g_new0 (Container, 1);
+
+ container->app = gnome_app_new ("pdf-viewer",
+ "GNOME PDF viewer");
+
+ gtk_drag_dest_set (container->app,
+ GTK_DEST_DEFAULT_ALL,
+ drag_types, n_drag_types,
+ GDK_ACTION_COPY);
+
+ gtk_signal_connect (GTK_OBJECT(container->app),
+ "drag_data_received",
+ GTK_SIGNAL_FUNC(filenames_dropped),
+ (gpointer)container);
+
+ gtk_window_set_default_size (GTK_WINDOW (container->app), 600, 600);
+ gtk_window_set_policy (GTK_WINDOW (container->app), TRUE, TRUE, FALSE);
+
+ container->container = bonobo_container_new ();
+ container->view_widget = NULL;
+ container->slot = gtk_event_box_new ();
+ gtk_widget_show (container->slot);
+
+ gnome_app_set_contents (GNOME_APP (container->app), GTK_WIDGET (container->slot));
+
+ gtk_object_set_data (GTK_OBJECT (container->app), "container_data", container);
+ gtk_signal_connect (GTK_OBJECT (container->app), "delete_event",
+ GTK_SIGNAL_FUNC (container_destroy_cb), container);
+
+ /*
+ * Create the BonoboUIHandler object which will be used to
+ * create the container's menus and toolbars. The UIHandler
+ * also creates a CORBA server which embedded components use
+ * to do menu/toolbar merging.
+ */
+ container->uih = bonobo_ui_handler_new ();
+ bonobo_ui_handler_set_app (container->uih, GNOME_APP (container->app));
+
+ container_create_menus (container);
+ container_create_toolbar (container);
+
+ gtk_widget_show_all (container->app);
+
+ containers = g_list_append (containers, container);
+
+ if (fname)
+ if (!open_pdf (container, fname)) {
+ container_destroy (container);
+ return NULL;
+ }
+
+ gtk_widget_show_all (container->app);
+
+ return container;