28 #define YUILogComponent "ui"
31 #include "YApplication.h"
33 #include "YUIException.h"
34 #include "YShortcut.h"
37 #include "YCommandLine.h"
42 typedef map<string, int> YFunctionKeyMap;
48 : productName(
"SUSE Linux" )
49 , reverseLayout(
false )
50 , showProductLogo(
false )
55 string applicationTitle;
56 string applicationIcon;
57 YFunctionKeyMap defaultFunctionKey;
59 map<string,string> releaseNotes;
67 YUI_CHECK_NEW( priv );
70 if ( cmdLine.
argc() > 0 )
71 priv->applicationTitle = cmdLine.
arg(0);
96 return priv->iconLoader->iconBasePath();
103 priv->iconLoader->setIconBasePath ( newIconBasePath );
107 YApplication::iconLoader()
109 return priv->iconLoader;
122 return priv->productName;
128 priv->releaseNotes = relNotes;
134 return priv->releaseNotes;
140 priv->showProductLogo = show;
146 return priv->showProductLogo;
152 priv->reverseLayout = reverse;
158 return priv->reverseLayout;
165 YFunctionKeyMap::const_iterator result =
168 if ( result == priv->defaultFunctionKey.end() )
171 return result->second;
188 priv->defaultFunctionKey.clear();
197 if ( ! encoding.empty() )
203 setenv(
"LANG", lang.c_str(), 1 );
204 setlocale( LC_NUMERIC,
"C" );
206 yuiMilestone() <<
"Setting language to " << lang << endl;
213 const char *lang_env = getenv(
"LANG" );
218 string lang( lang_env );
222 string::size_type pos = lang.find_first_of(
".@" );
224 if ( pos != string::npos )
226 lang = lang.substr( 0, pos );
237 if ( sym == YUIGlyph_ArrowLeft )
return (
reverseLayout() ?
"->" :
"<-" );
238 else if ( sym == YUIGlyph_ArrowRight )
return (
reverseLayout() ?
"<-" :
"->" );
239 else if ( sym == YUIGlyph_ArrowUp )
return (
"^" );
240 else if ( sym == YUIGlyph_ArrowDown )
return (
"v" );
241 else if ( sym == YUIGlyph_CheckMark )
return (
"x" );
242 else if ( sym == YUIGlyph_BulletArrowRight )
return (
"=>" );
243 else if ( sym == YUIGlyph_BulletCircle )
return (
"o" );
244 else if ( sym == YUIGlyph_BulletSquare )
return (
"[]" );
247 yuiError() <<
"Unknown glyph `" << sym << endl;
278 yuiError() <<
"Not in text mode: Cannot run external program in terminal." << endl;
285 priv->applicationTitle = title;
290 return priv->applicationTitle;
295 priv->applicationIcon = icon;
299 return priv->applicationIcon;
virtual float layoutUnits(YUIDimension dim, int deviceUnits)
Convert device dependent units into logical layout spacing units.
virtual const std::string & applicationIcon() const
Get the application Icon.
void setReleaseNotes(const std::map< std::string, std::string > &relNotes)
Set release notes; map product => text.
virtual void setReverseLayout(bool reverse)
Set reverse layout for Arabic / Hebrew support.
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
virtual ~YApplication()
Destructor.
std::string productName() const
Get the current product name ("openSUSE", "SLES", ...).
YWidget * findWidget(YWidgetID *id, bool doThrow=true) const
Find a widget in the topmost dialog by its ID.
virtual void setLanguage(const std::string &language, const std::string &encoding=std::string())
Set language and encoding for the locale environment ($LANG).
YApplication()
Constructor.
std::map< std::string, std::string > releaseNotes() const
Get the current release notes map.
std::string language(bool stripEncoding=false) const
Return the current language from the locale environment ($LANG).
virtual std::string glyph(const std::string &glyphSymbolName)
Return a string for a named glyph:
std::string arg(int index) const
Return command line argument no.
virtual void setApplicationTitle(const std::string &title)
Set the application title.
virtual bool openContextMenu(const YItemCollection &itemCollection)
Open a context menu for a widget.
virtual void setApplicationIcon(const std::string &icon)
Set the application Icon.
bool reverseLayout() const
Returns 'true' if widget geometry should be reversed for languages that have right-to-left writing di...
int defaultFunctionKey(const std::string &label) const
Return the default function key number for a widget with the specified label or 0 if there is none.
virtual void setProductName(const std::string &productName)
Set the current product name ("openSUSE", "SLES", ...).
virtual int deviceUnits(YUIDimension dim, float layoutUnits)
Convert logical layout spacing units into device dependent units.
virtual const std::string & applicationTitle() const
Get the application title.
virtual void setIconBasePath(const std::string &newIconBasePath)
Set the icon base path.
void clearDefaultFunctionKeys()
Clear all previous label-to-function-key mappings.
Utility class to access /proc/<pid>/cmdline to retrieve argc and argv.
bool showProductLogo() const
Return true if product logo should be shown.
std::string cleanShortcutString()
Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers.
virtual int runInTerminal(const std::string &command)
Run a shell command (typically an interactive program using NCurses) in a terminal (window).
virtual std::string iconBasePath() const
Get the base path for icons used by the UI.
void setDefaultFunctionKey(const std::string &label, int fkey)
Add a mapping from the specified label to the specified F-key number.
void setShowProductLogo(bool show)
Set whether the product logo (in top bar) should be shown.
Base class for UI Exceptions.
A window in the desktop environment.
static YDialog * currentDialog(bool doThrow=true)
Return the current (topmost) dialog.
int argc() const
Return the number of arguments in the command line.