Esempio n. 1
0
/**
 * Main function
 */
int	main(int argc, char **argv)
{
  try
    {
      // !both filestr and backup are used for the file logger
      std::ofstream	filestr(FILE_TO_LOG);
      std::streambuf*	backup = std::clog.rdbuf();

      std::clog.rdbuf(filestr.rdbuf());
      std::clog << "#### New session opened ####" << std::endl;

      Glib::OptionContext	oc("Here's the parameters");
      Glib::OptionGroup		og("main", "main description");

      Glib::OptionEntry		verbose;
      verbose.set_long_name("verbose");
      verbose.set_short_name('v');
      verbose.set_description("set verbose level");
      verbose.set_arg_description("verbose level");

      og.add_entry(verbose);

      oc.set_main_group(og);
      oc.set_help_enabled();

      Gtk::Main		kit(argc, argv, oc);
      WindowManager	mywindow;

      Gtk::Main::run();

      std::clog << "#### Session closed ####" << std::endl;
      std::clog.rdbuf(backup);
      filestr.close();
    }
  catch (Glib::OptionError oe)
    {
      std::cerr << "OptionError: " << oe.what() << std::endl;
    }

  return 0;
}
Esempio n. 2
0
ApplicationSettings get_settings_cmdline(int argc, char *argv[])
{
    ApplicationSettings settings;
    settings.input_path = LIGHT_DETECTION_FILENAME;
    settings.output_path = VIDEO_OUTPUT_PATH;
    settings.light_seconds = LIGHT_DETECTION_SECONDS;
    settings.audio_device = AUDIO_DEVICE;
    settings.video_bitrate = VIDEO_BITRATE;
    settings.video_caps = VIDEO_CAPS;
    settings.video_speedpreset = VIDEO_SPEEDPRESET;
    settings.video_device = VIDEO_DEVICE;
    settings.streaming_enable = STREAMING_ENABLE;
    settings.streaming_port = STREAMING_PORT;
    settings.invert_value = INVERT_VALUE;

    Glib::OptionGroup pathesGroup("settings", "application settings");
    Glib::OptionEntry pathDetector;
    pathDetector.set_short_name('i');
    pathDetector.set_long_name("input-path");
    Glib::OptionEntry pathOutput;
    pathOutput.set_short_name('o');
    pathOutput.set_long_name("output-path");
    Glib::OptionEntry lightSeconds;
    lightSeconds.set_short_name('s');
    lightSeconds.set_long_name("light-seconds");
    Glib::OptionEntry audioDevice;
    audioDevice.set_short_name('a');
    audioDevice.set_long_name("alsa-device");
    Glib::OptionEntry videoBitrate;
    videoBitrate.set_short_name('r');
    videoBitrate.set_long_name("video-bitrate");
    Glib::OptionEntry videoCaps;
    videoCaps.set_short_name('c');
    videoCaps.set_long_name("video-caps");
    Glib::OptionEntry videoDevice;
    videoDevice.set_short_name('v');
    videoDevice.set_long_name("v4l-device");
    Glib::OptionEntry videoSpeedPreset;
    videoSpeedPreset.set_short_name('p');
    videoSpeedPreset.set_long_name("video-speed-preset");
    Glib::OptionEntry streamingEnable;
    streamingEnable.set_long_name("enable-streaming");
    Glib::OptionEntry streamingPort;
    streamingPort.set_long_name("streaming-port");
    Glib::OptionEntry invertValue;
    invertValue.set_long_name("invert-value");

    pathesGroup.add_entry_filename(pathDetector, settings.input_path);
    pathesGroup.add_entry_filename(pathOutput, settings.output_path);
    pathesGroup.add_entry(lightSeconds, settings.light_seconds);
    pathesGroup.add_entry(audioDevice, settings.audio_device);
    pathesGroup.add_entry(videoBitrate, settings.video_bitrate);
    pathesGroup.add_entry(videoCaps, settings.video_caps);
    pathesGroup.add_entry(videoDevice, settings.video_device);
    pathesGroup.add_entry(videoSpeedPreset, settings.video_speedpreset);
    pathesGroup.add_entry(streamingEnable, settings.streaming_enable);
    pathesGroup.add_entry(streamingPort, settings.streaming_port);
    pathesGroup.add_entry(invertValue, settings.invert_value);

    Glib::OptionContext context;

    context.set_help_enabled(true);
    context.set_main_group(pathesGroup);

    context.parse(argc, argv);

    return settings;
}
Esempio n. 3
0
int main(int argc, char * argv[])
{
  bool bShowVersion = false;
  Glib::OptionGroup::vecustrings listRemaining;

#ifdef ENABLE_NLS
  setlocale(LC_ALL, "");
  bindtextdomain("gvbam", LOCALEDIR);
  textdomain("gvbam");
#endif // ENABLE_NLS

  Glib::set_application_name(_("VBA-M"));

  Gtk::Main oKit(argc, argv);

#ifdef USE_OPENGL
  Gtk::GL::init(argc, argv);
#endif // USE_OPENGL

  Glib::OptionContext oContext;
  Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));

  Glib::OptionEntry oVersion;
  oVersion.set_long_name("version");
  oVersion.set_short_name('v');
  oVersion.set_description(_("Output version information."));
  oGroup.add_entry(oVersion, bShowVersion);

  Glib::OptionEntry oFileName;
  oFileName.set_long_name(G_OPTION_REMAINING);
  oFileName.set_description(G_OPTION_REMAINING);
  oGroup.add_entry(oFileName, listRemaining);

  oContext.set_main_group(oGroup);

  try
  {
    oContext.parse(argc, argv);
  }
  catch (const Glib::Error& e)
  {
    Gtk::MessageDialog oDialog(e.what(),
                               false,
                               Gtk::MESSAGE_ERROR,
                               Gtk::BUTTONS_OK);
    oDialog.run();
    return 1;
  }

  if (bShowVersion)
  {
    g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
    exit(0);
  }

  Gtk::Window::set_default_icon_name("vbam");

  std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");

  Glib::RefPtr<Gtk::Builder> poXml;
  try
  {
    poXml = Gtk::Builder::create();
    poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
    poXml->add_from_file(sGtkBuilderFile, "MainWindow");
  }
  catch (const Gtk::BuilderError & e)
  {
    Gtk::MessageDialog oDialog(e.what(),
                               false,
                               Gtk::MESSAGE_ERROR,
                               Gtk::BUTTONS_OK);
    oDialog.run();
    return 1;
  }

  VBA::Window * poWindow = NULL;
  poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);

  if (listRemaining.size() == 1)
  {
    // Display the window before loading the file
    poWindow->show();
    while (Gtk::Main::events_pending())
    {
      Gtk::Main::iteration();
    }

    poWindow->bLoadROM(listRemaining[0]);
  }

  Gtk::Main::run(*poWindow);
  delete poWindow;

  return 0;
}