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);
std::auto_ptr<link_state> 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),
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)
.second)
{
page_queue_.push(uri);
- if (!loading_)
- load_next_page();
}
}
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)