From c5b2c095ea46391abe7c916aa3aaa819882fc726 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 27 Nov 2005 21:09:44 +0000 Subject: [PATCH] Cleaned up option processing. Changed to accept only a single URI, which is then passed to the WebDvdWindow constructor, since all pages reachable from the first URI will be included. Removed use of "about:" as a default URI. --- webdvd.cpp | 65 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/webdvd.cpp b/webdvd.cpp index ee44118..a6d456a 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -133,10 +133,12 @@ namespace class WebDvdWindow : public Gtk::Window { public: - WebDvdWindow(const video::frame_params & frame_params); - void add_page(const std::string & uri); + WebDvdWindow( + const video::frame_params & frame_params, + const std::string & main_page_uri); private: + void add_page(const std::string & uri); void add_video(const std::string & uri); void load_next_page(); void on_net_state_change(const char * uri, gint flags, guint status); @@ -161,7 +163,9 @@ namespace std::auto_ptr link_state_; }; - WebDvdWindow::WebDvdWindow(const video::frame_params & frame_params) + WebDvdWindow::WebDvdWindow( + const video::frame_params & frame_params, + const std::string & main_page_uri) : frame_params_(frame_params), stylesheet_(load_css("file://" WEBDVD_LIB_DIR "/webdvd.css")), loading_(false), @@ -172,6 +176,9 @@ namespace browser_widget_.show(); browser_widget_.signal_net_state().connect( SigC::slot(*this, &WebDvdWindow::on_net_state_change)); + + add_page(main_page_uri); + load_next_page(); } void WebDvdWindow::add_page(const std::string & uri) @@ -181,8 +188,6 @@ namespace .second) { page_queue_.push(uri); - if (!loading_) - load_next_page(); } } @@ -812,24 +817,44 @@ int main(int argc, char ** argv) setenv("XAUTHORITY", fb.get_x_authority().c_str(), true); setenv("DISPLAY", fb.get_x_display().c_str(), true); - // Initialise Gtk and Mozilla + // Initialise Gtk Gtk::Main kit(argc, argv); - BrowserWidget::init(); - WebDvdWindow window(frame_params); + // Check we have the right number of arguments. We can't + // do this earlier because we need to let Gtk read and remove + // any of the many options it understands. int argi = 1; - if (std::strcmp(argv[argi], "--video-std") == 0) - argi += 2; - else if (std::strcmp(argv[argi], "--") == 0) - argi += 1; - else if (argv[argi][0] == '-') - throw std::runtime_error( - std::string("Invalid option: ").append(argv[argi])); - if (argi == argc) - window.add_page("about:"); - else - for (/* no initialisation */; argi != argc; ++argi) - window.add_page(argv[argi]); + while (argi != argc) + { + if (std::strcmp(argv[argi], "--video-std") == 0) + { + argi += 2; + } + else if (std::strcmp(argv[argi], "--") == 0) + { + argi += 1; + break; + } + else if (argv[argi][0] == '-') + { + std::cerr << "Invalid option: " << argv[argi] << "\n"; + return EXIT_FAILURE; + } + else + break; + } + if (argi != argc - 1) + { + std::cerr << "Usage: " << argv[0] + << (" [gtk-options] [--video-std std-name]" + "front-page-url\n"); + return EXIT_FAILURE; + } + + // Initialise Mozilla + BrowserWidget::init(); + + WebDvdWindow window(frame_params, argv[argi]); Gtk::Main::run(window); } catch (std::exception & e) -- 2.39.5