28 #define YUILogComponent "ui" 31 #include "YApplication.h" 33 #include "YUIException.h" 34 #include "YShortcut.h" 37 #include "YCommandLine.h" 41 typedef std::map<std::string, int> YFunctionKeyMap;
47 : productName(
"SUSE Linux" )
48 , reverseLayout(
false )
49 , showProductLogo(
false )
52 std::string productName;
54 std::string applicationTitle;
55 std::string applicationIcon;
56 YFunctionKeyMap defaultFunctionKey;
58 std::map<std::string,std::string> releaseNotes;
66 YUI_CHECK_NEW( priv );
69 if ( cmdLine.
argc() > 0 )
70 priv->applicationTitle = cmdLine.
arg(0);
95 return priv->iconLoader->iconBasePath();
102 priv->iconLoader->setIconBasePath ( newIconBasePath );
106 YApplication::iconLoader()
108 return priv->iconLoader;
121 return priv->productName;
127 priv->releaseNotes = relNotes;
130 std::map<std::string,std::string>
133 return priv->releaseNotes;
139 priv->showProductLogo = show;
145 return priv->showProductLogo;
151 priv->reverseLayout = reverse;
157 return priv->reverseLayout;
164 YFunctionKeyMap::const_iterator result =
167 if ( result == priv->defaultFunctionKey.end() )
170 return result->second;
187 priv->defaultFunctionKey.clear();
196 if ( ! encoding.empty() )
202 setenv(
"LANG", lang.c_str(), 1 );
203 setlocale( LC_NUMERIC,
"C" );
205 yuiMilestone() <<
"Setting language to " << lang << endl;
212 const char *lang_env = getenv(
"LANG" );
217 std::string lang( lang_env );
221 std::string::size_type pos = lang.find_first_of(
".@" );
223 if ( pos != std::string::npos )
225 lang = lang.substr( 0, pos );
236 if ( sym == YUIGlyph_ArrowLeft )
return (
reverseLayout() ?
"->" :
"<-" );
237 else if ( sym == YUIGlyph_ArrowRight )
return (
reverseLayout() ?
"<-" :
"->" );
238 else if ( sym == YUIGlyph_ArrowUp )
return (
"^" );
239 else if ( sym == YUIGlyph_ArrowDown )
return (
"v" );
240 else if ( sym == YUIGlyph_CheckMark )
return (
"x" );
241 else if ( sym == YUIGlyph_BulletArrowRight )
return (
"=>" );
242 else if ( sym == YUIGlyph_BulletCircle )
return (
"o" );
243 else if ( sym == YUIGlyph_BulletSquare )
return (
"[]" );
246 yuiError() <<
"Unknown glyph `" << sym << endl;
263 return (
int) ( layoutUnits + 0.5 );
277 yuiError() <<
"Not in text mode: Cannot run external program in terminal." << endl;
284 priv->applicationTitle = title;
289 return priv->applicationTitle;
294 priv->applicationIcon = icon;
298 return priv->applicationIcon;
std::string productName() const
Get the current product name ("openSUSE", "SLES", ...).
bool showProductLogo() const
Return true if product logo should be shown.
virtual void setApplicationTitle(const std::string &title)
Set the application title.
virtual bool openContextMenu(const YItemCollection &itemCollection)
Open a context menu for a widget.
std::string language(bool stripEncoding=false) const
Return the current language from the locale environment ($LANG).
virtual std::string iconBasePath() const
Get the base path for icons used by the UI.
virtual const std::string & applicationIcon() const
Get the application Icon.
virtual float layoutUnits(YUIDimension dim, int deviceUnits)
Convert device dependent units into logical layout spacing units.
YApplication()
Constructor.
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...
std::vector< YItem * > YItemCollection
Collection of pointers to YItem.
void clearDefaultFunctionKeys()
Clear all previous label-to-function-key mappings.
virtual void setIconBasePath(const std::string &newIconBasePath)
Set the icon base path.
virtual int deviceUnits(YUIDimension dim, float layoutUnits)
Convert logical layout spacing units into device dependent units.
virtual ~YApplication()
Destructor.
void setShowProductLogo(bool show)
Set whether the product logo (in top bar) should be shown.
virtual const std::string & applicationTitle() const
Get the application title.
virtual int runInTerminal(const std::string &command)
Run a shell command (typically an interactive program using NCurses) in a terminal (window)...
std::string cleanShortcutString()
Returns the shortcut string ( from the widget's shortcut property ) without any "&" markers...
static YDialog * currentDialog(bool doThrow=true)
Return the current (topmost) dialog.
Utility class to access /proc/<pid>/cmdline to retrieve argc and argv.
YWidget * findWidget(YWidgetID *id, bool doThrow=true) const
Find a widget in the topmost dialog by its ID.
void setDefaultFunctionKey(const std::string &label, int fkey)
Add a mapping from the specified label to the specified F-key number.
bool reverseLayout() const
Returns 'true' if widget geometry should be reversed for languages that have right-to-left writing di...
virtual std::string glyph(const std::string &glyphSymbolName)
Return a string for a named glyph:
std::map< std::string, std::string > releaseNotes() const
Get the current release notes map.
virtual void setApplicationIcon(const std::string &icon)
Set the application Icon.
A window in the desktop environment.
virtual void setProductName(const std::string &productName)
Set the current product name ("openSUSE", "SLES", ...).
virtual void setReverseLayout(bool reverse)
Set reverse layout for Arabic / Hebrew support.
int argc() const
Return the number of arguments in the command line.
virtual void setLanguage(const std::string &language, const std::string &encoding=std::string())
Set language and encoding for the locale environment ($LANG).
Base class for UI Exceptions.
void setReleaseNotes(const std::map< std::string, std::string > &relNotes)
Set release notes; map product => text.
std::string arg(int index) const
Return command line argument no.