gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. f367a84703026e34cb19


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. f367a84703026e34cb1914affca5a2bcb7579b25
Date: Mon, 08 Nov 2010 23:14:05 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  f367a84703026e34cb1914affca5a2bcb7579b25 (commit)
      from  ea3abc1a66158177e118a417a897bb3b850cf939 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=f367a84703026e34cb1914affca5a2bcb7579b25


commit f367a84703026e34cb1914affca5a2bcb7579b25
Author: Sandro Santilli <address@hidden>
Date:   Tue Nov 9 00:13:08 2010 +0100

    Define supported options using boost::program_options, use the definition 
for the help string.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 21c5bb2..848faf3 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -27,6 +27,7 @@
 #include <iterator>
 #include <ios>
 #include <boost/format.hpp>
+#include <boost/program_options.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
@@ -58,35 +59,12 @@ gnash::LogFile& dbglogfile = 
gnash::LogFile::getDefaultInstance();
 gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
 }
 
-static void
-usage_gui_keys(std::ostream& os)
+static boost::program_options::options_description
+getSupportedOptions()
 {
-    os
-    << _("Keys:") << std::endl
-    << std::endl
-    << "  CTRL-Q, CTRL-W           "
-    << _("Quit")
-    << std::endl
-    << "  CTRL-F                   "
-    << _("Toggle fullscreen")
-    << std::endl 
-    << "  CTRL-P                   "
-    << _("Toggle pause") 
-    << std::endl 
-    << "  CTRL-R                   "
-    << _("Restart the movie") 
-    << std::endl 
-    << "  CTRL-O                   "
-    << _("Take a screenshot") 
-    << std::endl 
-    << "  CTRL-L                   "
-    << _("Force immediate redraw") 
-    << std::endl;
-}
+    namespace po = boost::program_options;
+    using std::string;
 
-static void
-usage()
-{
     std::vector<std::string> handlers;
     gnash::media::MediaFactory::instance().listKeys(back_inserter(handlers));
 
@@ -94,125 +72,174 @@ usage()
     boost::split(renderers, RENDERER_CONFIG,
         boost::is_any_of(" "), boost::token_compress_on);
 
-    cout
+    po::options_description desc("Options");
 
-    << _("Usage: gnash [options] movie_file.swf") << endl
-    << _("Plays a SWF (Shockwave Flash) movie") << endl
-    << _("Options:") << endl
-    << endl 
+    desc.add_options()
 
-    <<   "  -h,  --help              "
-    << _("Print this help and exit") << endl
+    ( "help,h",
+        _("Print this help and exit") )
 
-    <<   "  -V,  --version           "
-    << _("Print version information and exit") << endl
+    ( "version,V", 
+        _("Print version information and exit") )
 
-    <<   "  -s,  --scale <factor>    "
-    << _("Scale the movie by the specified factor") << endl
+    ( "scale,s", po::value<float>(),
+        _("Scale the movie by the specified factor") )
 
-    <<   "  -d,  --delay <num>       "
-    << _("Number of milliseconds to delay in main loop") << endl
+    ( "delay,d", po::value<int>(),
+        _("Number of milliseconds to delay in main loop") )
 
-    <<   "  -v,  --verbose           "
-    << _("Produce verbose output") << endl
+
+    ( "verbose,v",
+        _("Produce verbose output") )
 
 #if VERBOSE_ACTION
-    <<   "  -va                      "
-    << _("Be (very) verbose about action execution") << endl
+    ( "verbose-actions,a",
+        _("Be (very) verbose about action execution") )
 #endif
 
 #if VERBOSE_PARSE
-    <<   "  -vp                      "
-    << _("Be (very) verbose about parsing") << endl
+    ( "verbose-parsing,p",
+        _("Be (very) verbose about parsing") )
 #endif
 
-    <<   "  -A <file>                "
-    << _("Audio dump file (wave format)") << endl
+    ( "audio-dump,A", po::value<string>(),
+        _("Audio dump file (wave format)") )
 
-    <<   "  --hwaccel <none|vaapi>   "
-    << _("Hardware Video Accelerator to use") << endl
-    <<   "                           none|vaapi|omap (default: none)" 
-    << endl
+    ( "hwaccel", po::value<string>(),
+        ( string( _("Hardware Video Accelerator to use"))
+        + string( "\nnone|vaapi|omap (default: none)") ). c_str() ) 
 
-    <<   "  -x,  --xid <ID>          "
-    << _("X11 Window ID for display") << endl
+    ( "xid,x", po::value<long>(),
+        _("X11 Window ID for display") )
 
-    <<   "  -w,  --writelog          "
-    << _("Produce the disk based debug log") << endl
+    ( "writelog,w",
+        _("Produce the disk based debug log") )
 
-    <<   "  -j,  --width <width>     "
-    << _("Set window width") << endl
+    ( "width,j", po::value<int>(),
+        _("Set window width") )
 
-    <<   "  -k,  --height <height>   "
-    << _("Set window height") << endl
+    ( "height,k", po::value<int>(),
+        _("Set window height") )
 
-    <<   "  -X,  --x-pos <x-pos>     "
-    << _("Set window x position") << endl
+    ( "x-pos,X", po::value<int>(),
+        _("Set window x position") )
 
-    <<   "  -Y,  --y-pos <y-pos>     "
-    << _("Set window y position") << endl
+    ( "y-pos,Y", po::value<int>(),
+        _("Set window y position") )
 
-    <<   "  -1,  --once              "
-    << _("Exit when/if movie reaches the last frame") << endl
+    ( "once,1", 
+        _("Exit when/if movie reaches the last frame") )
 
-    <<   "  -r,  --render-mode <0|1|2|3>" << endl 
-    <<   "                           0 "
-    << _("disable rendering and sound") << endl
-    <<   "                           1 "
-    << _("enable rendering, disable sound") << endl
-    <<   "                           2 "
-    << _("enable sound, disable rendering") << endl
-    <<   "                           3 "
-    << _("enable rendering and sound (default)") << endl
+    ( "render-mode,r", po::value<int>(),
+        ( string("0 ")
+        + string(_("disable rendering and sound")) 
+        + string("\n1 ")
+        + string(_("enable rendering, disable sound"))
+        + string("\n2 ")
+        + string(_("enable sound, disable rendering"))
+        + string("\n3 ")
+        + string(_("enable rendering and sound (default)"))
+        ).c_str() )
 
-    <<   "  -M,  --media <" << boost::join(handlers, "|") << ">" << endl
-    <<   "                           "
-    << _("The media handler to use")
-    << " (default: " << handlers.front() << ")" << endl
+    ( "media,M", po::value<string>(),
+        ( string(_("The media handler to use"))
+        + string("\n") + boost::join(handlers, "|")
+        + string(" (default: ") + handlers.front() + string(")")
+        ).c_str() )
 
-    <<   "  -R,  --renderer <" << boost::join(renderers, "|") << ">" << endl
-    <<   "                           "
-    << _("The renderer to use")
-    << " (default: agg)" << endl
+    ( "renderer,R", po::value<string>(),
+        ( string(_("The renderer to use"))
+        + string("\n") + boost::join(renderers, "|")
+        + string(" (default: AGG)")
+        ).c_str() )
 
-    <<   "  -t,  --timeout <sec>     "
-    << _("Exit after the specified number of seconds") << endl
+    ( "timeout,t", po::value<int>(),
+        _("Exit after the specified number of seconds") )
 
-    <<   "  -u,  --real-url <url>    "
-    << _("Set \"real\" URL of the movie")  << endl
+    ( "real-url,u", po::value<string>(),
+        _("Set \"real\" URL of the movie") )
 
-    <<   "  -U,  --base-url <url>    "
-    << _("Set \"base\" URL for resolving relative URLs") << endl
+    ( "base-url,U", po::value<string>(),
+        _("Set \"base\" URL for resolving relative URLs") )
 
-    <<   "  -P,  --param <param>     "
-    << _("Set parameter (e.g. \"FlashVars=A=1&b=2\")") << endl
+    ( "param,P", po::value<string>(),
+        _("Set parameter (e.g. \"FlashVars=A=1&b=2\")") )
 
-    <<   "  -F,  --fd <fd>:<fd>      "
-    << _("Filedescriptor to use for external communications") << endl
+    ( "fd,F", po::value<string>(),
+        ( string(_("Filedescriptor to use for external communications"))
+        + string(" <fd>:<fd>")
+        ).c_str() )
 
 #ifdef GNASH_FPS_DEBUG
-    <<   "  -f,  --debug-fps <num>   "
-    << _("Print FPS every num seconds (float)") << endl
+    ( "debug-fps,f", po::value<int>(),
+        _("Print FPS every num seconds (float)") )
 #endif // def GNASH_FPS_DEBUG
-    
-    <<   "  --max-advances <num>     "
-    << _("Exit after specified number of frame advances") << endl
 
-    <<   "  --fullscreen             "
-    << _("Start in fullscreen mode") << endl
+    ( "max-advances", po::value<int>(),
+        _("Exit after specified number of frame advances") )
+
+    ( "fullscreen",
+        _("Start in fullscreen mode") )
+
+    // TODO: move to GUIs actually implementing this
+    ( "hide-menubar",
+        _("Start without displaying the menu bar") )
+
+    ( "screenshot", po::value<string>(),
+        _("List of frames to save as screenshots") )
+
+    ( "screenshot-file", po::value<string>(),
+        _("Filename pattern for screenshot images") )
+
+    ;
+
+
+    return desc;
+}
+
+
+static void
+usage_gui_keys(std::ostream& os)
+{
+    os
+    << _("Keys:") << std::endl
+    << std::endl
+    << "  CTRL-Q, CTRL-W           "
+    << _("Quit")
+    << std::endl
+    << "  CTRL-F                   "
+    << _("Toggle fullscreen")
+    << std::endl 
+    << "  CTRL-P                   "
+    << _("Toggle pause") 
+    << std::endl 
+    << "  CTRL-R                   "
+    << _("Restart the movie") 
+    << std::endl 
+    << "  CTRL-O                   "
+    << _("Take a screenshot") 
+    << std::endl 
+    << "  CTRL-L                   "
+    << _("Force immediate redraw") 
+    << std::endl;
+}
 
-    <<   "  --hide-menubar           "
-    << _("Start without displaying the menu bar") << endl
+static void
+usage()
+{
 
-    <<   "  --screenshot <list>      "
-    << _("List of frames to save as screenshots") << endl
+    namespace po = boost::program_options;
+    po::options_description opts = getSupportedOptions();
 
-    <<   "  --screenshot-file <file> "
-    << _("Filename pattern for screenshot images.") << endl
+    cout
 
+    << _("Usage: gnash [options] movie_file.swf") << endl
+    << _("Plays a SWF (Shockwave Flash) movie") << endl
+    << opts
     << endl;
 
     // Add gui keys
+    // TODO: stop printing these in here ?
     usage_gui_keys(cout);
 
     cout << std::endl;
@@ -247,9 +274,21 @@ build_options()
 }
 
 static void
-parseCommandLine(int argc, char* argv[], gnash::Player& player)
+_parseCommandLine(int argc, char* argv[], gnash::Player& player)
 {
+    namespace po = boost::program_options;
+    po::options_description opts = getSupportedOptions();
+
+    po::variables_map vm;
+    po::store(po::parse_command_line(argc, argv, opts), vm);
+    po::notify(vm);
 
+    // TODO: get this done :)
+}
+
+static void
+parseCommandLine(int argc, char* argv[], gnash::Player& player)
+{
     const Arg_parser::Option opts[] =
         {
         { 'h', "help",              Arg_parser::no  },

-----------------------------------------------------------------------

Summary of changes:
 gui/gnash.cpp |  253 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 146 insertions(+), 107 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]