[yast-commit] r58193 - in /trunk/libyui/src: Makefile.am YApplication.cc YApplication.h YIconLoader.cc YIconLoader.h YSelectionWidget.cc

Author: kmachalkova Date: Tue Jul 28 15:17:14 2009 New Revision: 58193 URL: http://svn.opensuse.org/viewcvs/yast?rev=58193&view=rev Log: Introducing IconLoader Modified: trunk/libyui/src/Makefile.am trunk/libyui/src/YApplication.cc trunk/libyui/src/YApplication.h trunk/libyui/src/YIconLoader.cc trunk/libyui/src/YIconLoader.h trunk/libyui/src/YSelectionWidget.cc Modified: trunk/libyui/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/Makefile.am?rev=58193&... ============================================================================== --- trunk/libyui/src/Makefile.am (original) +++ trunk/libyui/src/Makefile.am Tue Jul 28 15:17:14 2009 @@ -29,6 +29,7 @@ YEventFilter.cc \ YEnvVar.cc \ YItem.cc \ + YIconLoader.cc \ YMacro.cc \ YProperty.cc \ YShortcut.cc \ @@ -115,6 +116,7 @@ YEventFilter.h \ YEnvVar.h \ YItem.h \ + YIconLoader.h \ YMenuItem.h \ YMacro.h \ YMacroPlayer.h \ Modified: trunk/libyui/src/YApplication.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YApplication.cc?rev=58... ============================================================================== --- trunk/libyui/src/YApplication.cc (original) +++ trunk/libyui/src/YApplication.cc Tue Jul 28 15:17:14 2009 @@ -42,10 +42,10 @@ , reverseLayout( false ) {} - string iconBasePath; string productName; bool reverseLayout; YFunctionKeyMap defaultFunctionKey; + YIconLoader* iconLoader; }; @@ -53,6 +53,7 @@ : priv( new YApplicationPrivate() ) { YUI_CHECK_NEW( priv ); + priv->iconLoader = new YIconLoader(); } @@ -77,14 +78,20 @@ string YApplication::iconBasePath() const { - return priv->iconBasePath; + return priv->iconLoader->iconBasePath(); } void YApplication::setIconBasePath( const string & newIconBasePath ) { - priv->iconBasePath = newIconBasePath; + priv->iconLoader->setIconBasePath ( newIconBasePath ); +} + +YIconLoader * +YApplication::iconLoader() +{ + return priv->iconLoader; } void Modified: trunk/libyui/src/YApplication.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YApplication.h?rev=581... ============================================================================== --- trunk/libyui/src/YApplication.h (original) +++ trunk/libyui/src/YApplication.h Tue Jul 28 15:17:14 2009 @@ -23,6 +23,7 @@ #include "YUI.h" #include "ImplPtr.h" #include "YMenuItem.h" +#include "YIconLoader.h" using std::string; @@ -76,6 +77,8 @@ **/ virtual void setIconBasePath( const string & newIconBasePath ); + YIconLoader *iconLoader(); + /** * Return the default function key number for a widget with the specified * label or 0 if there is none. Any keyboard shortcuts that may be Modified: trunk/libyui/src/YIconLoader.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YIconLoader.cc?rev=581... ============================================================================== --- trunk/libyui/src/YIconLoader.cc (original) +++ trunk/libyui/src/YIconLoader.cc Tue Jul 28 15:17:14 2009 @@ -10,19 +10,24 @@ YIconLoader::YIconLoader() { - addIconPath(FALLBACK_ICON_PATH); + addIconSearchPath(FALLBACK_ICON_PATH); } YIconLoader::~YIconLoader() { } -void YIconLoader::addBasePath( string path) +void YIconLoader::setIconBasePath( string path) { - iconBasePath = path; + _iconBasePath = path; } -void YIconLoader::addIconPath( string path ) +string YIconLoader::iconBasePath() const +{ + return _iconBasePath; +} + +void YIconLoader::addIconSearchPath( string path ) { icon_dirs.push_front( path ); } @@ -38,12 +43,17 @@ if (name[0] == '/') return name; + string fullPath; + // Look in global search path - string fullPath = iconBasePath + name; - if ( fileExists ( fullPath ) ) + if ( !_iconBasePath.empty () ) { - yuiMilestone() << "Found " << name << " in global search path" << endl; - return fullPath; + fullPath = _iconBasePath + name; + if ( fileExists ( fullPath ) ) + { + yuiMilestone() << "Found " << name << " in global search path" << endl; + return fullPath; + } } // Now search the fallback dirs Modified: trunk/libyui/src/YIconLoader.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YIconLoader.h?rev=5819... ============================================================================== --- trunk/libyui/src/YIconLoader.h (original) +++ trunk/libyui/src/YIconLoader.h Tue Jul 28 15:17:14 2009 @@ -16,12 +16,17 @@ string findIcon( string name ); - void addBasePath( string path ); - void addIconPath( string path ); + //FIXME: these two are here for compatibility reasons + // deprecate them in due course and treat base path just + // like any other search path + void setIconBasePath( string path ); + string iconBasePath() const; + + void addIconSearchPath( string path ); private: - string iconBasePath; + string _iconBasePath; list <string> icon_dirs; bool fileExists( string fname ); Modified: trunk/libyui/src/YSelectionWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YSelectionWidget.cc?re... ============================================================================== --- trunk/libyui/src/YSelectionWidget.cc (original) +++ trunk/libyui/src/YSelectionWidget.cc Tue Jul 28 15:17:14 2009 @@ -126,7 +126,7 @@ if ( priv->iconBasePath.empty() || priv->iconBasePath[0] != '/' ) { - fullPath = YUI::yApp()->iconBasePath(); + return YUI::yApp()->iconLoader()->findIcon( iconName ); } fullPath += priv->iconBasePath + "/" + iconName; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org