Author: kmachalkova
Date: Thu Apr 14 10:44:18 2011
New Revision: 63774
URL: http://svn.opensuse.org/viewcvs/yast?rev=63774&view=rev
Log:
Have libyui understand CLI options such as --gtk,
--qt, --ncurses + add some inane logic which UI
plugin to load
Modified:
trunk/libyui/src/YUILoader.cc
trunk/libyui/src/YUILoader.h
trunk/libyui/src/YUIPlugin.cc
trunk/libyui/src/YUIPlugin.h
Modified: trunk/libyui/src/YUILoader.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUILoader.cc?rev=63774&r1=63773&r2=63774&view=diff
==============================================================================
--- trunk/libyui/src/YUILoader.cc (original)
+++ trunk/libyui/src/YUILoader.cc Thu Apr 14 10:44:18 2011
@@ -38,8 +38,10 @@
/-*/
#include // getenv()
-#include // isatty()
+#include // isatty()a
+#include
+#include "YCommandLine.h"
#include "YUILoader.h"
#include "YUIPlugin.h"
#include "YUIException.h"
@@ -49,25 +51,38 @@
{
const char * envDisplay = getenv( "DISPLAY" );
- if ( envDisplay )
+ YCommandLine cmdline;
+
+ bool wantNcurses = cmdline.find("--ncurses") != -1;
+ bool wantQt = cmdline.find("--qt") != -1;
+ bool wantGtk = cmdline.find("--gtk") != -1;
+
+ bool haveQt = pluginExists( YUIPlugin_Qt );
+ bool haveGtk = pluginExists( YUIPlugin_Gtk );
+
+ if ( envDisplay && !wantNcurses )
{
- //
- // Qt UI
- //
-
+ string wantedGUI;
+
+ if ( haveQt && !wantGtk)
+ wantedGUI = YUIPlugin_Qt;
+ else if ( haveGtk && !wantQt )
+ wantedGUI = YUIPlugin_Gtk;
+
try
{
- loadPlugin( YUIPlugin_Qt, withThreads );
+ loadPlugin( wantedGUI, withThreads );
return;
}
catch ( YUIException & ex)
{
YUI_CAUGHT( ex );
}
+
}
if ( isatty( STDOUT_FILENO ) )
- {
+ {
//
// NCurses UI
//
@@ -109,3 +124,17 @@
YUI_THROW( YUIPluginException( name ) );
}
+
+bool YUILoader::pluginExists( const string & pluginBaseName )
+{
+ struct stat fileinfo;
+ string fullPath;
+
+ fullPath.append( PLUGINDIR "/" ); // from -DPLUGINDIR in Makefile.am
+ fullPath.append( PLUGIN_PREFIX );
+ fullPath.append( pluginBaseName );
+ fullPath.append( PLUGIN_SUFFIX );
+
+ return stat( fullPath.c_str(), &fileinfo) == 0;
+
+}
Modified: trunk/libyui/src/YUILoader.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUILoader.h?rev=63774&r1=63773&r2=63774&view=diff
==============================================================================
--- trunk/libyui/src/YUILoader.h (original)
+++ trunk/libyui/src/YUILoader.h Thu Apr 14 10:44:18 2011
@@ -74,6 +74,8 @@
**/
static void loadPlugin( const string & name, bool withThreads = false );
+ static bool pluginExists( const string & pluginBaseName );
+
private:
YUILoader() {}
~YUILoader() {}
Modified: trunk/libyui/src/YUIPlugin.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUIPlugin.cc?rev=63774&r1=63773&r2=63774&view=diff
==============================================================================
--- trunk/libyui/src/YUIPlugin.cc (original)
+++ trunk/libyui/src/YUIPlugin.cc Thu Apr 14 10:44:18 2011
@@ -45,11 +45,6 @@
#include "YUIPlugin.h"
-
-#define PLUGIN_PREFIX "libpy2"
-#define PLUGIN_SUFFIX ".so.2"
-
-
using std::string;
Modified: trunk/libyui/src/YUIPlugin.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUIPlugin.h?rev=63774&r1=63773&r2=63774&view=diff
==============================================================================
--- trunk/libyui/src/YUIPlugin.h (original)
+++ trunk/libyui/src/YUIPlugin.h Thu Apr 14 10:44:18 2011
@@ -41,6 +41,9 @@
#ifndef YUIPlugin_h
#define YUIPlugin_h
+#define PLUGIN_PREFIX "libpy2"
+#define PLUGIN_SUFFIX ".so.2"
+
#include <string>
using std::string;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org