30 #define YUILogComponent "ui"
32 #include "YCommandLine.h"
33 #include "YUILoader.h"
34 #include "YUIPlugin.h"
35 #include "YUIException.h"
38 #include "Libyui_config.h"
43 const char * envDisplay = getenv(
"DISPLAY" );
47 bool wantNcurses = cmdline.
find(
"--ncurses") != -1;
48 bool wantQt = cmdline.
find(
"--qt") != -1;
49 bool wantGtk = cmdline.
find(
"--gtk") != -1;
51 bool haveQt = pluginExists( YUIPlugin_Qt );
52 bool haveGtk = pluginExists( YUIPlugin_Gtk );
54 if ( envDisplay && !wantNcurses )
56 std::string wantedGUI;
58 if ( haveQt && !wantGtk)
59 wantedGUI = YUIPlugin_Qt;
60 else if ( haveGtk && !wantQt )
61 wantedGUI = YUIPlugin_Gtk;
63 if ( strcmp( wantedGUI.c_str(),
"" ) )
77 if ( isatty( STDOUT_FILENO ) )
104 yuiMilestone() <<
"Shutting down UI" << std::endl;
115 if ( uiPlugin.success() )
117 createUIFunction_t createUI = (createUIFunction_t) uiPlugin.locateSymbol(
"_Z8createUIb" );
121 YUI * ui = createUI( withThreads );
139 void YUILoader::loadExternalWidgetsPlugin (
const std::string& name,
const std::string& plugin_name,
const std::string& symbol )
141 YUIPlugin uiPlugin ( plugin_name.c_str() );
143 if ( uiPlugin.success() )
145 createEWFunction_t createEW = ( createEWFunction_t ) uiPlugin.locateSymbol ( symbol.c_str() );
161 const char * envDisplay = getenv(
"DISPLAY" );
165 bool wantNcurses = cmdline.
find(
"--ncurses") != -1;
166 bool wantQt = cmdline.
find(
"--qt") != -1;
167 bool wantGtk = cmdline.
find(
"--gtk") != -1;
169 bool haveQt = pluginExists( YUIPlugin_Qt );
170 bool haveGtk = pluginExists( YUIPlugin_Gtk );
172 if ( envDisplay && !wantNcurses )
174 std::string wantedGUI = name;
175 wantedGUI.append(
"-");
177 if ( haveQt && !wantGtk)
178 wantedGUI.append(YUIPlugin_Qt);
179 else if ( haveGtk && !wantQt )
180 wantedGUI.append(YUIPlugin_Gtk);
184 loadExternalWidgetsPlugin(name, wantedGUI, symbol );
199 std::string wantedNcurses = name;
200 wantedNcurses.append(
"-");
201 wantedNcurses.append(YUIPlugin_NCurses);
202 loadExternalWidgetsPlugin(name, wantedNcurses, symbol );
212 bool YUILoader::pluginExists(
const std::string & pluginBaseName )
214 struct stat fileinfo;
215 std::string pluginName = PLUGIN_PREFIX;
217 pluginName.append( pluginBaseName );
218 pluginName.append( PLUGIN_SUFFIX );
220 YPath plugin ( PLUGINDIR, pluginName );
222 return stat( plugin.path().c_str(), &fileinfo) == 0;
Abstract base class of a libYUI user interface.
static void loadPlugin(const std::string &name, bool withThreads=false)
Load a UI plug-in.
static void loadExternalWidgets(const std::string &name, const std::string &symbol="_Z21createExternalWidgetsPKc")
Load the given External Widgets plugin followed by its graphical extension implementation in the foll...
Exception class for plugin load failure.
static void deleteUI()
This will make sure the UI singleton is deleted.
Utility class to access /proc/<pid>/cmdline to retrieve argc and argv.
int find(const std::string &argName) const
Find a command line argument 'argName' ("-display" etc.).
Exception class for UI plugin load failure.
Wrapper class for dlopen() and related.
Base class for UI Exceptions.
static void loadUI(bool withThreads=false)
Load any of the available UI plug-ins in this order: