[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1437
Date       : Thu Jul 13 10:05:54 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/app.cpp
   M /Trunk/XaraLX/configure.in
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/camelot.h
   M /Trunk/XaraLX/wxOil/helpuser.cpp
   M /Trunk/XaraLX/wxOil/menucmds.cpp
   M /Trunk/XaraLX/wxOil/oilfltrs.cpp

Implement the new resource directory discovery algorithm


Diff:
Index: Trunk/XaraLX/Kernel/app.cpp
===================================================================
--- Trunk/XaraLX/Kernel/app.cpp	(revision 1436)
+++ Trunk/XaraLX/Kernel/app.cpp	(revision 1437)
@@ -616,12 +616,8 @@
 	//exe path with "	emplates\" on the end
 	if( m_TemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_TemplatesPath ) )
 	{
-		std::auto_ptr<char> Pathname( br_find_data_dir( "/usr/share" ) );
-
 		// Put the path name into a string
-		String_256 strPathname( Pathname.get() );
-		strPathname += _T("/xaralx/");
-		PathName ModulePath(strPathname);
+		PathName ModulePath( CCamApp::GetResourceDirectory() );
 
 		m_TemplatesPath = ModulePath.GetLocation(TRUE);
 
Index: Trunk/XaraLX/configure.in
===================================================================
--- Trunk/XaraLX/configure.in	(revision 1436)
+++ Trunk/XaraLX/configure.in	(revision 1437)
@@ -146,7 +146,7 @@
                             falling back to /usr/share/xaralx]],
 [
     if test "$withval" != "yes" -a "$withval" != ""; then
-        RESOURCE_DIR_DEFINE=-DRESOURCE_DIR=$withval
+        RESOURCE_DIR_DEFINE="-DRESOURCE_DIR=\\"$withval\\""
     fi
 ])
 
Index: Trunk/XaraLX/wxOil/menucmds.cpp
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1436)
+++ Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1437)
@@ -964,7 +964,7 @@
 
 static void StartMovie( const wxString &strFile )
 {
-	wxString			strDataPath( br_find_data_dir( "/usr/share" ), wxConvUTF8 );
+	wxString			strDataPath( CCamApp::GetResourceDirectory() );
 	if( !wxDir::Exists( strDataPath ) )
 	{
 #if defined(_DEBUG)
@@ -974,7 +974,7 @@
 	}
 
 	wxString			strVideoPath( strDataPath );
-	strVideoPath += _("/xaralx/video");
+	strVideoPath += _("/video");
 	
 	wxString			strCommand( _T("mplayer -slave \"") );
 	strCommand += strVideoPath + _T("/") + strFile + _T("\"");	
@@ -993,7 +993,7 @@
 static void StartMovieNative( const wxString &strFile )
 {
 #if wxUSE_MEDIACTRL
-	wxString			strDataPath( br_find_data_dir( "/usr/share" ), wxConvUTF8 );
+	wxString			strDataPath( CCamApp::GetResourceDirectory() );
 	if( !wxDir::Exists( strDataPath ) )
 	{
 #if defined(_DEBUG)
@@ -1003,7 +1003,7 @@
 	}
 
 	wxString			strVideoPath( strDataPath );
-	strVideoPath += _("/xaralx/video");
+	strVideoPath += _("/video");
 	
 	CReplayWnd*		pWnd	= new CReplayWnd( CCamFrame::GetMainFrame() );
 	pWnd->Load( strVideoPath + _T("/") + strFile );
Index: Trunk/XaraLX/wxOil/helpuser.cpp
===================================================================
--- Trunk/XaraLX/wxOil/helpuser.cpp	(revision 1436)
+++ Trunk/XaraLX/wxOil/helpuser.cpp	(revision 1437)
@@ -1130,10 +1130,8 @@
 		strLocale = _T("en");
 
 	// Check the help dir exists, if not bomb out
-	PSTR		pszDataPath = br_find_data_dir( "/usr/share" );
-	wxString	strHelpPath( pszDataPath, wxConvUTF8 );
-	free( pszDataPath );
-	strHelpPath += _T("/xaralx/doc/");
+	wxString	strHelpPath( (PCTSTR)CCamApp::GetResourceDirectory() );
+	strHelpPath += _T("/doc/");
 	TRACEUSER( "jlh92", _T("Using filter discovery directory \"%s\"
"), PCTSTR(strHelpPath + strLocale) );
 	if( wxDir::Exists( strHelpPath + strLocale ) )
 		strHelpPath += strLocale + _T("/");
Index: Trunk/XaraLX/wxOil/oilfltrs.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilfltrs.cpp	(revision 1436)
+++ Trunk/XaraLX/wxOil/oilfltrs.cpp	(revision 1437)
@@ -350,10 +350,8 @@
 #endif
 
 	// Check the config dir exists, if not bomb out
-	PSTR		pszDataPath = br_find_data_dir( "/usr/share" );
-	wxString	strConfigPath( pszDataPath, wxConvUTF8 );
-	free( pszDataPath );
-	strConfigPath += _T("/xaralx/filters");
+	wxString	strConfigPath( (TCHAR*)CCamApp::GetResourceDirectory() );
+	strConfigPath += _T("/filters");
 	TRACEUSER( "jlh92", _T("Using filter discovery directory \"%s\"
"), PCTSTR(strConfigPath) );
 	if( !wxDir::Exists( strConfigPath ) )
 	{
@@ -365,6 +363,8 @@
 			return TRUE;
 	}
 
+	TRACEUSER( "luke", _T("Using %s as filter store
"), PCTSTR(strConfigPath) );
+
 	// Setup the directory scan
 	wxDir	dir( strConfigPath );
 	if( !dir.IsOpened() )
Index: Trunk/XaraLX/wxOil/camelot.h
===================================================================
--- Trunk/XaraLX/wxOil/camelot.h	(revision 1436)
+++ Trunk/XaraLX/wxOil/camelot.h	(revision 1437)
@@ -152,6 +152,9 @@
 
 	static BOOL LaunchWebBrowser(const wxString& strUrl);
 
+	// Get the path to the root of the resource directory structure
+	static StringBase& GetResourceDirectory();
+
 private:
 	INT32 RunFalseMainLoop();
 
@@ -161,7 +164,8 @@
 
 	static bool			s_bIsDisabled;
 
-	static wxString		m_strResourcePath;
+	static wxString		m_strResourcePath;		// The usually bound in resources
+	static String_256	m_strResourceDirPath;	// External resources (i.e. help files)
 
 	wxTimer				m_Timer;
 
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 1436)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 1437)
@@ -227,6 +227,7 @@
 DialogManager			CCamApp::m_DlgMgr;
 bool					CCamApp::s_bIsDisabled = false; // Initially system is not disabled.
 wxString				CCamApp::m_strResourcePath;
+String_256				CCamApp::m_strResourceDirPath;
 
 
 /***************************************************************************************************************************/
@@ -537,6 +538,37 @@
  	if( !Camelot.Init() )
 		return false;
 
+	// --------------------------------------------------------------------------
+	// Detect first-time run and make Open File dialog default to Examples folder
+	if (Camelot.DeclareSection(TEXT("Preferences"), 10))
+	{
+		Camelot.DeclarePref(NULL, TEXT("FirstRun"), &bFirstRun, 0, 1);
+	}
+
+	// Check the resource dir exists
+	Camelot.DeclarePref( NULL, TEXT("ResourceDir"), &m_strResourceDirPath );
+	if( bFirstRun )
+	{
+#if !defined(RESOURCE_DIR)
+		std::auto_ptr<char> pszDataPath( br_find_data_dir( "/usr/share" ) );
+		m_strResourceDirPath = ( pszDataPath.get() );
+		m_strResourceDirPath += _T("/xaralx");
+		TRACEUSER( "luke", _T("Using resource directory \"%s\"
"), PCTSTR(m_strResourceDirPath) );
+	#if defined(_DEBUG)
+		if( !wxDir::Exists( PCTSTR(m_strResourceDirPath) ) )
+		{
+			// We'll try default location under debug to make life easier
+			m_strResourceDirPath = _T("/usr/share/xaralx");
+			TRACEUSER( "luke", _T("Try = \"%s\"
"), PCTSTR(m_strResourceDirPath) );
+		}
+	#endif
+#else
+		// The "" is needed to stop the macro expanding to LRESOURCE_DIR
+		m_strResourceDirPath = _T(""RESOURCE_DIR);
+#endif
+	}
+	TRACEUSER( "luke", _T("ResDir = %s
"), PCTSTR(m_strResourceDirPath) );
+
 	TRACET(_T("CCamApp::Calling InitKernel"));
 	// then initialise the kernel (and almost everything else)	
 	if( !InitKernel() )
@@ -578,20 +610,11 @@
 	m_docManager->FileHistoryLoad(Preferences::GetOilPrefs());
 #endif
 
-	// --------------------------------------------------------------------------
-	// Detect first-time run and make Open File dialog default to Examples folder
-	if (Camelot.DeclareSection(TEXT("Preferences"), 10))
-	{
-		Camelot.DeclarePref(NULL, TEXT("FirstRun"), &bFirstRun, 0, 1);
-	}
-
 	if (bFirstRun)
 	{
 		// Set File Open dialog location to our Examples folder
-		PSTR		pszDataPath = br_find_data_dir("/usr/share");
-		wxString	strConfigPath(pszDataPath, wxConvUTF8);
-		free(pszDataPath);
-		strConfigPath += _T("/xaralx/Examples");
+		wxString	strConfigPath( (TCHAR*)m_strResourceDirPath );
+		strConfigPath += _T("/Examples");
 
 #if defined(_DEBUG)
 		// Debug-only fallback
@@ -1038,6 +1061,10 @@
 	(void)wxMessageBox( strMessage, wxT("About Xara LX") );
 }
 
+StringBase& CCamApp::GetResourceDirectory()
+{
+	return m_strResourceDirPath;
+}
 
 void CCamApp::GiveActiveCanvasFocus()
 {
@@ -1376,10 +1403,8 @@
 		strLocale = _T("en");
 
 	// Check the help dir exists, if not bomb out
-	PSTR		pszDataPath = br_find_data_dir( "/usr/share" );
-	wxString	strHelpPath( pszDataPath, wxConvUTF8 );
-	free( pszDataPath );
-	strHelpPath += _T("/xaralx/doc/");
+	wxString	strHelpPath( (TCHAR*)m_strResourceDirPath );
+	strHelpPath += _T("/doc/");
 	TRACEUSER( "jlh92", _T("Using filter discovery directory \"%s\"
"), PCTSTR(strHelpPath + strLocale) );
 	if( wxDir::Exists( strHelpPath + strLocale ) )
 		strHelpPath += strLocale + _T("/");


Xara