[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h gui...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h gui... |
Date: |
Thu, 26 Jul 2007 05:14:54 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/07/26 05:14:54
Modified files:
. : ChangeLog
gui : Player.cpp Player.h gnash.cpp
Log message:
* gui/Player.{cpp,h}: add support for multiple GUI libs.
They can be statically or dynamically linked (not loaded as
plugins
yet).
* gui/gnash.cpp: add a -G switch to select GUI. If the gui
wasn't
compiled in an exception will be thrown (and dunno why not
propery
cought..).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3831&r2=1.3832
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.cpp?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gnash.cpp?cvsroot=gnash&r1=1.85&r2=1.86
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3831
retrieving revision 1.3832
diff -u -b -r1.3831 -r1.3832
--- ChangeLog 26 Jul 2007 04:05:50 -0000 1.3831
+++ ChangeLog 26 Jul 2007 05:14:53 -0000 1.3832
@@ -1,5 +1,14 @@
2007-07-25 Sandro Santilli <address@hidden>
+ * gui/Player.{cpp,h}: add support for multiple GUI libs.
+ They can be statically or dynamically linked (not loaded as plugins
+ yet).
+ * gui/gnash.cpp: add a -G switch to select GUI. If the gui wasn't
+ compiled in an exception will be thrown (and dunno why not propery
+ cought..).
+
+2007-07-25 Sandro Santilli <address@hidden>
+
* configure.ac: set the BUILD_<gui> conditionals *after* giving kde
gui a chance to be picked back as a dependency of 'klash'.
This fixes a buil bug when klash is enabled by only gtk gui is
Index: gui/Player.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- gui/Player.cpp 2 Jul 2007 18:32:53 -0000 1.58
+++ gui/Player.cpp 26 Jul 2007 05:14:54 -0000 1.59
@@ -21,36 +21,39 @@
#include "config.h"
#endif
-#ifndef GUI_KDE
-# ifdef GUI_GTK
+#ifdef GUI_GTK
# include "gtksup.h"
-# define GUI_CLASS GtkGui
-# elif defined(GUI_SDL)
+# define DEFAULT_GUI guiGTK
+#endif
+
+#ifdef GUI_SDL
# include "sdlsup.h"
-# define GUI_CLASS SDLGui
-# elif defined(GUI_AQUA)
+# define DEFAULT_GUI guiSDL
+#endif
+
+#ifdef GUI_AQUA
# include "aquasup.h"
-# define GUI_CLASS AquaGui
-# elif defined(GUI_RISCOS)
+# define DEFAULT_GUI guiAQUA
+#endif
+
+#ifdef GUI_RISCOS
# include "riscossup.h"
-# define GUI_CLASS RiscosGui
-# elif defined(GUI_FLTK)
+# define DEFAULT_GUI guiRISCOS
+#endif
+
+#ifdef GUI_FLTK
# include "fltksup.h"
-# define GUI_CLASS FltkGui
-# endif
-#else
-# ifdef HAVE_KDE
-# include "kdesup.h"
-# define GUI_CLASS KdeGui
-# else
-# error "KDE development packages not installed!"
-# endif
+# define DEFAULT_GUI guiFLTK
#endif
+#ifdef GUI_KDE
+# include "kdesup.h"
+# define DEFAULT_GUI guiKDE
+#endif
#ifdef GUI_FB
# include "fbsup.h"
-# define GUI_CLASS FBGui
+# define DEFAULT_GUI guiFB
#endif
#include "NullGui.h"
@@ -62,6 +65,7 @@
#include "movie_root.h"
#include "Player.h"
+#include "StringPredicates.h"
#include "URL.h"
#include "rc.h"
#include "GnashException.h"
@@ -114,6 +118,7 @@
#ifdef GNASH_FPS_DEBUG
,_fpsDebugTime(0.0)
#endif
+ ,_guiFlavor(DEFAULT_GUI)
{
init();
}
@@ -207,7 +212,7 @@
{
if ( do_render )
{
- _gui.reset(new GUI_CLASS(windowid, scale, do_loop, bit_depth));
+ _gui = getGui(_guiFlavor); // throws on unsupported gui
RcInitFile& rcfile = RcInitFile::getDefaultInstance();
if ( rcfile.startStopped() )
@@ -390,3 +395,82 @@
{
log_msg(_("fs_callback(%p): %s %s"), (void*)movie, command, args);
}
+
+/* private */
+std::auto_ptr<Gui>
+Player::getGui(GuiFlavor which)
+{
+ switch (which)
+ {
+
+ case guiGTK:
+#ifdef GUI_GTK // if we've been built with support for GTK
+ return std::auto_ptr<Gui>(new GtkGui(windowid, scale,
do_loop, bit_depth));
+#endif
+
+ case guiKDE:
+#ifdef GUI_KDE // if we've been built with support for KDE
+ return std::auto_ptr<Gui>(new KdeGui(windowid, scale,
do_loop, bit_depth));
+#else
+ throw GnashException("Support for KDE gui was not
compiled in");
+#endif
+
+ case guiSDL:
+#ifdef GUI_SDL // if we've been built with support for SDL
+ return std::auto_ptr<Gui>(new SDLGui(windowid, scale,
do_loop, bit_depth));
+#else
+ throw GnashException("Support for SDL gui was not
compiled in");
+#endif
+
+ case guiAQUA:
+#ifdef GUI_AQUA // if we've been built with support for AQUA
+ return std::auto_ptr<Gui>(new AquaGui(windowid, scale,
do_loop, bit_depth));
+#else
+ throw GnashException("Support for AQUA gui was not
compiled in");
+#endif
+
+ case guiRISCOS:
+#ifdef GUI_RISCOS // if we've been built with support for RISCOS
+ return std::auto_ptr<Gui>(new RiscosGui(windowid,
scale, do_loop, bit_depth));
+#else
+ throw GnashException("Support for RISCOS gui was not
compiled in");
+#endif
+
+ case guiFLTK:
+#ifdef GUI_FLTK // if we've been built with support for FLTK
+ return std::auto_ptr<Gui>(new FltkGui(windowid, scale,
do_loop, bit_depth));
+#else
+ throw GnashException("Support for FLTK gui was not
compiled in");
+#endif
+
+ case guiFB:
+#ifdef GUI_FB // if we've been built with support for FB
+ return std::auto_ptr<Gui>(new FBGui(windowid, scale,
do_loop, bit_depth));
+#else
+ throw GnashException("Support for FB gui was not
compiled in");
+#endif
+
+ }
+
+ std::stringstream ss;
+ ss << "Unknown gui flavor " << which << " requested";
+ throw GnashException(ss.str());
+}
+
+Player::GuiFlavor
+Player::parseGuiFlavorByName(const std::string& flavorName)
+{
+ StringNoCaseEqual match;
+
+ if ( match(flavorName, "GTK") ) return guiGTK;
+ if ( match(flavorName, "KDE") ) return guiKDE;
+ if ( match(flavorName, "SDL") ) return guiSDL;
+ if ( match(flavorName, "FLTK") ) return guiFLTK;
+ if ( match(flavorName, "FB") ) return guiFB;
+ if ( match(flavorName, "AQUA") ) return guiAQUA;
+ if ( match(flavorName, "RISCOS") ) return guiRISCOS;
+
+ std::stringstream ss;
+ ss << "Unknown Gui flavor " << flavorName;
+ throw GnashException(ss.str());
+}
Index: gui/Player.h
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gui/Player.h 2 Jul 2007 18:32:53 -0000 1.12
+++ gui/Player.h 26 Jul 2007 05:14:54 -0000 1.13
@@ -53,6 +53,30 @@
{
public:
+ enum GuiFlavor {
+
+ /// GTK gui
+ guiGTK,
+
+ /// QT/KDE gui
+ guiKDE,
+
+ /// SDL gui
+ guiSDL,
+
+ /// AQUA gui (for OS/X)
+ guiAQUA,
+
+ /// RISCOS gui
+ guiRISCOS,
+
+ /// FLTK2 gui
+ guiFLTK,
+
+ /// Framebuffer (no gui actually)
+ guiFB
+ };
+
Player();
~Player() {}
@@ -110,6 +134,16 @@
void setDoSound(bool b) { do_sound=b; }
+ /// Set gui flavor by name
+ //
+ /// Throws an exception if gui name is invalid
+ ///
+ void setGuiFlavor(const std::string& flavorName) {
+ setGuiFlavor(parseGuiFlavorByName(flavorName));
+ }
+
+ void setGuiFlavor(GuiFlavor which) { _guiFlavor = which; }
+
/// Set the base url for this run.
//
/// The base url will be used to resolve relative
@@ -137,6 +171,13 @@
private:
+ /// Parse gui by name
+ //
+ /// Throws an exception if gui name is invalid
+ ///
+ GuiFlavor parseGuiFlavorByName(const std::string& flavorName);
+
+
void init();
void init_sound();
@@ -145,6 +186,11 @@
void init_gui();
+ /// Initialize the given gui with parameters stored so far
+ //
+ /// Throws GnashException if the gui flavor provided isn't supported
+ std::auto_ptr<Gui> getGui(GuiFlavor which);
+
static void setFlashVars(sprite_instance& m, const std::string& varstr);
static void fs_callback(sprite_instance* movie,
@@ -197,6 +243,9 @@
#ifdef GNASH_FPS_DEBUG
float _fpsDebugTime;
#endif
+
+ GuiFlavor _guiFlavor;
+
};
Index: gui/gnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gnash.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- gui/gnash.cpp 25 Jul 2007 12:38:28 -0000 1.85
+++ gui/gnash.cpp 26 Jul 2007 05:14:54 -0000 1.86
@@ -93,6 +93,7 @@
"\n"), _(
" -h, --help Print this info.\n"
" -s <factor> Scale the movie up/down by the specified factor\n"
+ " -G <guiname> Use specified gui (gtk|kde|fltk|aqua|riscos|fb)\n"
" -c Produce a core file instead of letting SDL trap it\n"
" -d num Number of milliseconds to delay in main loop\n"
" -v Be verbose; i.e. print log messages to stdout\n"
@@ -206,7 +207,7 @@
}
}
- while ((c = getopt (argc, argv, "hvaps:cd:x:r:t:b:1wj:k:u:P:U:gVf:")) !=
-1)
+ while ((c = getopt (argc, argv, "hvaps:cd:x:r:t:b:1wj:k:u:P:U:gVf:G:")) !=
-1)
{
switch (c) {
// case 'c' (Disable SDL core dumps) is decoded in sdl.cpp:init()
@@ -317,6 +318,9 @@
case 't':
player.setExitTimeout( (float) atof(optarg) );
break;
+ case 'G':
+ player.setGuiFlavor(optarg);
+ break;
case 'b':
player.setBitDepth(atoi(optarg));
break;
@@ -396,7 +400,17 @@
rcfile.loadFiles();
- parseCommandLine(argc, argv, player);
+ try { parseCommandLine(argc, argv, player); }
+ catch (const std::exception& ex)
+ {
+ cerr << ex.what() << endl;
+ exit(EXIT_FAILURE);
+ }
+ catch (...)
+ {
+ cerr << "Exception thrown during parseCommandLine" << endl;
+ exit(EXIT_FAILURE);
+ }
// No file name was supplied
if (!infile) {