-extern "C" {
- void
- do_close (GtkWidget *menuitem, DOC_ROOT *doc)
- {
- doc_root_destroy (doc);
- }
-
- void
- do_exit (GtkWidget *menuitem, DOC_ROOT *doc)
- {
- GList *l;
- while ((l=documents))
- doc_root_destroy ((DOC_ROOT *)l->data);
- }
-
- static void
- do_about_box (GtkWidget *w, DOC_ROOT *doc)
- {
- GladeXML *gui = glade_xml_new (GPDF_GLADE_DIR "/about.glade", NULL);
- g_return_if_fail (gui);
- GtkWidget *wi = glade_xml_get_widget (gui, "about_box");
- g_return_if_fail (wi);
- gtk_widget_show (wi);
- gtk_object_destroy (GTK_OBJECT (gui));
- }
-
- static void
- simple_connect (DOC_ROOT *doc, const char *name, GtkSignalFunc func)
- {
- GtkWidget *w;
- w = glade_xml_get_widget (doc->gui, name);
- gtk_signal_connect (GTK_OBJECT (w), "activate", func, doc);
- }
-
- static void
- connect_signals (DOC_ROOT *doc)
- {
- simple_connect (doc, "about_menu", GTK_SIGNAL_FUNC (do_about_box));
- simple_connect (doc, "close_menu", GTK_SIGNAL_FUNC (do_close));
- simple_connect (doc, "exit_menu", GTK_SIGNAL_FUNC (do_exit));
- }
+static void
+file_open_cmd (GtkWidget *widget, Application *app)
+{
+ 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 (app->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] != '/') {
+ if (app->contains_pdf)
+ app = application_new ();
+ char *fname = g_strdup (name);
+ open_pdf (app, fname);
+ 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 (app->app));
+ gnome_dialog_run (GNOME_DIALOG (dialog));
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (fsel));
+}
+
+static void
+close_cmd (GtkWidget *widget, Application *app)
+{
+ application_destroy (app);
+}
+
+static void
+exit_cmd (void)
+{
+ applications_destroy ();
+}
+
+static GnomeUIInfo container_file_menu [] = {
+ GNOMEUIINFO_MENU_OPEN_ITEM (file_open_cmd, NULL),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_MENU_CLOSE_ITEM(close_cmd, NULL),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_MENU_EXIT_ITEM (exit_cmd, NULL),
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo container_main_menu [] = {
+ GNOMEUIINFO_MENU_FILE_TREE (container_file_menu),
+ GNOMEUIINFO_END
+};
+
+static Application *
+application_new (void)
+{
+ Application *app;
+ GnomeUIHandlerMenuItem *menu_list;
+
+ app = g_new0 (Application, 1);
+ app->app = gnome_app_new ("gpdf",
+ "GNOME PDF viewer");
+ app->container = GNOME_CONTAINER (gnome_container_new ());
+ app->contains_pdf = FALSE;
+
+ app->box = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (app->box);
+ gnome_app_set_contents (GNOME_APP (app->app), app->box);
+
+ /*
+ * Create the menus.
+ */
+ app->uih = gnome_ui_handler_new ();
+
+ gnome_ui_handler_set_app (app->uih, GNOME_APP (app->app));
+ gnome_ui_handler_create_menubar (app->uih);
+
+ menu_list = gnome_ui_handler_menu_parse_uiinfo_list_with_data (container_main_menu, app);
+ gnome_ui_handler_menu_add_list (app->uih, "/", menu_list);
+ gnome_ui_handler_menu_free_list (menu_list);
+
+/* gnome_ui_handler_create_toolbar (app->uih, "Common");
+ gnome_ui_handler_toolbar_new_item (app->uih,
+ "/Common/item 1",
+ "Container-added Item 1", "I am the container. Hear me roar.",
+ 0, GNOME_UI_HANDLER_PIXMAP_NONE, NULL, 0, 0,
+ NULL, NULL);*/
+
+ gtk_widget_show (app->app);
+
+ apps = g_list_append (apps, app);
+ return app;