Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16280/src/gui
Modified Files:
wxIconManager.cpp
Log Message:
streamlined image loading code, don't pass by XPM conversion unless absolutely needed
Index: wxIconManager.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxIconManager.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -b -u -2 -r1.106 -r1.107
--- wxIconManager.cpp 12 Jan 2004 17:48:29 -0000 1.106
+++ wxIconManager.cpp 2 May 2004 14:00:11 -0000 1.107
@@ -39,4 +39,5 @@
#include <wx/mimetype.h>
#include <wx/file.h>
+#include <wx/filename.h>
#ifdef USE_ICONS_FROM_RESOURCES
@@ -297,6 +298,4 @@
wxIconManager::LoadImageXpm(String filename)
{
- String tempfile;
- String oldfilename = filename;
char **cpptr = NULL;
@@ -304,19 +303,18 @@
filename.c_str());
- // lets convert to xpm using image magick:
- if(! wxMatchWild(_T("*.xpm"),filename,FALSE))
+ wxFileName fn(filename);
+ if ( fn.GetExt() == _T("xpm") )
{
+ // try loading the file itself as an xpm
+ cpptr = LoadXpm(filename);
+ }
#ifdef OS_UNIX
- int i;
- tempfile = filename + _T(".xpm");
- // strip leading path
- i = tempfile.length();
- while(i && tempfile.c_str()[i] != '/')
- i--;
- tempfile.assign(tempfile,i+1,tempfile.length()-1-i);
- tempfile = String(
- (wxGetenv(_T("TMP")) && wxStrlen(wxGetenv(_T("TMP"))))
- ? wxGetenv(_T("TMP")) : _T("/tmp")
- ) + _T('/') + tempfile;
+ else // lets convert to xpm using image magick:
+ {
+ wxFileName fnXPM;
+ fnXPM.AssignTempFileName(_T("Mimg"));
+ fnXPM.SetExt(_T("xpm"));
+
+ String tempfile(fnXPM.GetFullPath());
String command;
command.Printf(READ_APPCONFIG_TEXT(MP_CONVERTPROGRAM),
@@ -327,11 +325,9 @@
if(wxSystem(command) == 0)
cpptr = LoadXpm(tempfile);
-#endif // OS_UNIX
- }
- if(! cpptr) // try loading the file itself as an xpm
- cpptr = LoadXpm(filename);
- if(tempfile.length()) // using a temporary file
wxRemoveFile(tempfile);
+ }
+#endif // OS_UNIX
+
return cpptr;
}
@@ -592,4 +588,8 @@
{
ms_IconPath = name.BeforeLast('/');
+
+ if ( !icon.LoadFile(name, wxBITMAP_TYPE_ANY) )
+ {
+ // try to load it via conversion to XPM
char **ptr = LoadImageXpm(name);
if(ptr)
@@ -597,4 +597,9 @@
icon = wxIcon(ptr);
FreeImage(ptr);
+ }
+ }
+
+ if ( icon.Ok() )
+ {
id = new IconData;
id->iconRef = icon;
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates