Commit 8497178f authored by charras's avatar charras
Browse files

removed unused files. Switch to RC5

parent 52dbb13c
Loading
Loading
Loading
Loading

bitmaps/icon_python.xpm

deleted100644 → 0
+0 −113
Original line number Diff line number Diff line
/* XPM */
#ifndef XPMMAIN
extern const char * icon_python_xpm[];

#else
const char * icon_python_xpm[] = {
"32 32 72 1",
" 	c None",
".	c #7EA5C6",
"+	c #6495BD",
"@	c #4383B6",
"#	c #437FB2",
"$	c #6491B5",
"%	c #7DA1BF",
"&	c #3882BE",
"*	c #387CB5",
"=	c #3779AF",
"-	c #3776AB",
";	c #4988BB",
">	c #CDDFEE",
",	c #F7F7FF",
"'	c #82ADD1",
")	c #3773A5",
"!	c #7096B5",
"~	c #4385BB",
"{	c #FFFFFF",
"]	c #F6F5F5",
"^	c #3C729E",
"/	c #9BBDDA",
"(	c #366D9C",
"_	c #387FBA",
":	c #5A91BF",
"<	c #376A94",
"[	c #FFED60",
"}	c #FFE659",
"|	c #F8E16E",
"1	c #FFEB5E",
"2	c #FFE354",
"3	c #4489C0",
"4	c #3885C3",
"5	c #FFDB4C",
"6	c #FBCE47",
"7	c #FFD544",
"8	c #72A0C5",
"9	c #507CA1",
"0	c #FFE052",
"a	c #FFD040",
"b	c #F5D98D",
"c	c #7F9EB8",
"d	c #F1ECDA",
"e	c #FFCC3B",
"f	c #FBC840",
"g	c #FBD54F",
"h	c #FCC539",
"i	c #4379A7",
"j	c #DCE1E7",
"k	c #FAE262",
"l	c #FFC532",
"m	c #FBC037",
"n	c #80A6C6",
"o	c #FFBC29",
"p	c #F7CD74",
"q	c #427DAE",
"r	c #FABE40",
"s	c #FFB521",
"t	c #497FAC",
"u	c #FFCD57",
"v	c #FFE097",
"w	c #FFD67B",
"x	c #FFD849",
"y	c #FFFBF2",
"z	c #F7DE92",
"A	c #FFCF6A",
"B	c #FFEDC8",
"C	c #FFE4AC",
"D	c #F7D284",
"E	c #FFB531",
"F	c #F7D47B",
"G	c #FDBE2E",
"                                ",
"                                ",
"            .+@###$%            ",
"           &&&**==---           ",
"         ;&>,'*===))))!         ",
"         ~&{{]==--))))^         ",
"         &&'/@===)))(((         ",
"         __**===)))((((         ",
"                  (((((         ",
"     :&&&**====)))(((<<[[}}|    ",
"    &&&&&**===)))(((<<<11}22    ",
"   34&__***---))(((<<<<222556   ",
"   4&&&**====)))((<<<<<225557   ",
"  84&&***==--))(((<<<<900577ab  ",
"  ~&&&**===)))(((<<<<cd5577aef  ",
"  ___**====)))((<<<<9dg577eeeh  ",
"  __***==ijk[[[[[}225557aeelll  ",
"  @_**===j|[[[[[}}00577aeelllm  ",
"  n*==---k[[[[}}225577aellllop  ",
"   **=---}[[[[}225577eelllloo   ",
"   q===))[[[[}225577aeellloor   ",
"    --)))[[}}00577aeelllooos    ",
"     tiii11}005566fffffmmmmp    ",
"         22255                  ",
"         225557aeelllom         ",
"         00557aeeeuvwoo         ",
"         gx77aeelly{{sm         ",
"         z77aellllABCsD         ",
"           6ellloossE           ",
"             FmGoop             ",
"                                ",
"                                "};

#endif

bitmaps/icon_python_small.xpm

deleted100644 → 0
+0 −123
Original line number Diff line number Diff line
/* XPM */
#ifndef XPMMAIN
extern const char * icon_python_small_xpm[];

#else
const char *icon_python_small_xpm[] = {
"16 16 98 2",
"  	c None",
". 	c #5490C0",
"+ 	c #3E7EB4",
"@ 	c #3D7CB0",
"# 	c #5488B2",
"$ 	c #4686BB",
"% 	c #8FB8DA",
"& 	c #DCE6F1",
"* 	c #377AB0",
"= 	c #3778AD",
"- 	c #3773A5",
"; 	c #5684AA",
"> 	c #3880BC",
", 	c #4A8AC0",
"' 	c #538DBD",
") 	c #3779AF",
"! 	c #3774A8",
"~ 	c #3772A3",
"{ 	c #366D9C",
"] 	c #366C9A",
"^ 	c #799785",
"/ 	c #FFEA5C",
"( 	c #FCE464",
"_ 	c #3883BF",
": 	c #387EB7",
"< 	c #387AB1",
"[ 	c #366E9E",
"} 	c #376A94",
"| 	c #9BA876",
"1 	c #FFE658",
"2 	c #FFDF50",
"3 	c #4B8EC4",
"4 	c #3882BE",
"5 	c #387AB2",
"6 	c #3778AE",
"7 	c #3775A9",
"8 	c #A1AA77",
"9 	c #FFDE50",
"0 	c #FFD848",
"a 	c #FCD55B",
"b 	c #3B81BB",
"c 	c #3880BB",
"d 	c #387BB4",
"e 	c #3776AA",
"f 	c #376B96",
"g 	c #7E9CB2",
"h 	c #FADE70",
"i 	c #FFD646",
"j 	c #FFCF3E",
"k 	c #FDC93C",
"l 	c #3B80B9",
"m 	c #387CB5",
"n 	c #6393BB",
"o 	c #F3E486",
"p 	c #FFED60",
"q 	c #FFE85B",
"r 	c #FFE253",
"s 	c #FFDA4A",
"t 	c #FFD545",
"u 	c #FFCD3C",
"v 	c #FFC734",
"w 	c #FEC433",
"x 	c #508ABB",
"y 	c #3776AB",
"z 	c #9AAD84",
"A 	c #FFE558",
"B 	c #FFE152",
"C 	c #FFD342",
"D 	c #FFCB3A",
"E 	c #FFC532",
"F 	c #FFC330",
"G 	c #FCC242",
"H 	c #9BB082",
"I 	c #FFEB5E",
"J 	c #FFE659",
"K 	c #FFE052",
"L 	c #FFD241",
"M 	c #FFC02E",
"N 	c #FFBA27",
"O 	c #4379A7",
"P 	c #C0C273",
"Q 	c #FFDE4F",
"R 	c #FFDB4C",
"S 	c #FFD040",
"T 	c #FFCC3B",
"U 	c #FFCE54",
"V 	c #FFC540",
"W 	c #FDBE30",
"X 	c #F9DA70",
"Y 	c #FFD645",
"Z 	c #FFC836",
"` 	c #FFEEC9",
" .	c #FFD37B",
"..	c #F9C95E",
"+.	c #FCCC4D",
"@.	c #FEC232",
"#.	c #FFBC29",
"$.	c #FCBD3D",
"                                ",
"            . + @ #             ",
"        $ % & * = - - ;         ",
"        > , ' ) ! ~ { {         ",
"                  { ] ^ / (     ",
"    _ > : < = - [ ] } | 1 2     ",
"  3 4 : 5 6 7 ~ { } } 8 9 0 a   ",
"  b c d ) e - { f } g h i j k   ",
"  l m * n o p p q r s t u v w   ",
"  x * y z p p A B s C D E F G   ",
"    = ! H I J K 0 L D v M N     ",
"      O P 1 Q R                 ",
"        r 9 s S T U V W         ",
"        X Y S Z E `  ...        ",
"            +.@.#.$.            ",
"                                "
};
#endif

bitmaps/new_python.xpm

deleted100644 → 0
+0 −136
Original line number Diff line number Diff line
/* XPM */
#ifndef XPMMAIN
extern const char * new_python_xpm[];
#else
const char * new_python_xpm[] = {
"16 16 112 2",
"  	c None",
". 	c #000000",
"+ 	c #FEFEFE",
"@ 	c #090909",
"# 	c #EEEEEE",
"$ 	c #F1F1F1",
"% 	c #FBFBFB",
"& 	c #DAE2E8",
"* 	c #CDDBE7",
"= 	c #528DBD",
"- 	c #3C7BB0",
"; 	c #5689B2",
"> 	c #DAE1E7",
", 	c #E9EBED",
"' 	c #767676",
") 	c #5590C1",
"! 	c #79A9D1",
"~ 	c #709FC6",
"{ 	c #3777AC",
"] 	c #3672A4",
"^ 	c #3C73A2",
"/ 	c #B2C4D4",
"( 	c #161616",
"_ 	c #C1D2E1",
": 	c #C2D3E2",
"< 	c #BFD0DE",
"[ 	c #BBCCDB",
"} 	c #366E9D",
"| 	c #467695",
"1 	c #C4C787",
"2 	c #F8E78A",
"3 	c #C4C4C4",
"4 	c #B7CDDF",
"5 	c #3881BD",
"6 	c #387EB7",
"7 	c #3779B0",
"8 	c #3775A9",
"9 	c #366F9F",
"0 	c #366B99",
"a 	c #597F89",
"b 	c #DACF62",
"c 	c #FFDF50",
"d 	c #EEEDEC",
"e 	c #ECECEC",
"f 	c #4287C0",
"g 	c #387EB8",
"h 	c #377AB1",
"i 	c #3776AB",
"j 	c #366D9B",
"k 	c #386A94",
"l 	c #728F8F",
"m 	c #E6CF5B",
"n 	c #FFD545",
"o 	c #F8D774",
"p 	c #EBEBEB",
"q 	c #3A7FB9",
"r 	c #377BB4",
"s 	c #4E86B5",
"t 	c #A8B890",
"u 	c #AEBA7A",
"v 	c #AEB674",
"w 	c #AFB26D",
"x 	c #DCC969",
"y 	c #FED348",
"z 	c #FFCA38",
"A 	c #F8CE5E",
"B 	c #EAEAEA",
"C 	c #4784B7",
"D 	c #3778AD",
"E 	c #88A38E",
"F 	c #FDEC63",
"G 	c #FFE95C",
"H 	c #FFE254",
"I 	c #FFDA4A",
"J 	c #FFD140",
"K 	c #FFC836",
"L 	c #FFC330",
"M 	c #F7CA65",
"N 	c #E8E8E8",
"O 	c #C1D1DE",
"P 	c #457EAE",
"Q 	c #95AB84",
"R 	c #FFE95B",
"S 	c #FBDB5F",
"T 	c #FBD55E",
"U 	c #FACE56",
"V 	c #FAC851",
"W 	c #FAC249",
"X 	c #E7E7E7",
"Y 	c #B9C9D7",
"Z 	c #D4CD6F",
"` 	c #FFE152",
" .	c #FFD949",
"..	c #F4D881",
"+.	c #F1DA9F",
"@.	c #F1D494",
"#.	c #E9DFC6",
"$.	c #E6E6E6",
"%.	c #E5E5E5",
"&.	c #F8DD79",
"*.	c #FFD646",
"=.	c #FFCE3D",
"-.	c #FFC735",
";.	c #FFE5AA",
">.	c #FDCC64",
",.	c #ECD9AF",
"'.	c #E4E4E4",
").	c #F0E8D3",
"!.	c #FBC94A",
"~.	c #FDBF36",
"{.	c #F9C150",
"].	c #E3E3E3",
"  . . . . . . . . . . . .       ",
". + + + + + + + + + + @ + .     ",
". + # # # $ $ $ $ $ $ @ % + .   ",
". + # # & * = - ; > , @ ' + + . ",
". + # # ) ! ~ { ] ^ / @ @ @ ( . ",
". + # # _ : < [ } | 1 2 # # 3 . ",
". + 4 5 6 7 8 9 0 a b c d e 3 . ",
". + f g h i ] j k l m n o p 3 . ",
". + q r s t u v w x y z A B 3 . ",
". + C D E F G H I J K L M N 3 . ",
". + O P Q R H S T U V W X X 3 . ",
". + # Y Z `  ...+.@.#.$.$.%.3 . ",
". + # # &.*.=.-.;.>.,.%.'.'.3 . ",
". + # # # ).!.~.{.# '.].].].3 . ",
". 3 3 3 3 3 3 3 3 3 3 3 3 3 3 . ",
"  . . . . . . . . . . . . . .   "};
#endif
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#endif

#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2010-02-26)"
#define KICAD_BUILD_VERSION "(2010-02-28)"
#endif

#define VERSION_STABILITY "RC5"

common/pyhandler.cpp

deleted100644 → 0
+0 −467
Original line number Diff line number Diff line
#include "fctsys.h"
#include "common.h"

#include <id.h>

#include <wx/dir.h>

#include <pyhandler.h>
#include <iostream>

using namespace boost::python;


/*****************************************************************************/
/*                        Common Python Binding                              */
/*****************************************************************************/

static int GetLastID() { return ID_END_LIST; }

static object ChooseFile( str objTitle, str objMask, object objOpen )
{
    wxString mask = PyHandler::MakeStr( objMask );
    int open  = extract<int>( objOpen );

    wxString script = EDA_FileSelector( PyHandler::MakeStr( objTitle ),
                                        wxEmptyString,
                                        wxEmptyString,
                                        mask,
                                        mask,
                                        NULL,
                                        open ? wxFD_OPEN : wxFD_SAVE,
                                        TRUE );

    return PyHandler::Convert( script );
}

static void Print( str message )
{
    std::cout << extract<char *>(message) << std::endl;
}


static void Clear() {}


static void RegisterCb( str objKey, object callback )
{
    PyHandler::GetInstance()->RegisterCallback( PyHandler::MakeStr(objKey),
                                                callback );
}


static void UnRegisterCb( str objKey, object callback )
{
    PyHandler::GetInstance()->UnRegisterCallback( PyHandler::MakeStr(objKey),
                                                  callback );
}


static void init_base_utils()
{
    def ( "ChooseFile",         &ChooseFile );
    def ( "RegisterCallback",   &RegisterCb );
    def ( "UnRegisterCallback", &UnRegisterCb );
    def ( "GetLastID",          &GetLastID );

    def ( "Print",              &Print );
    def ( "Clear",              &Clear);
}


// Dummy boost callback
static void InitPyModules()
{
    PyHandler::GetInstance()->InitNextModule();
}


/*****************************************************************************/
/*                                PyHandler                                  */
/*****************************************************************************/

// std::vector< T > -> python object implicit conversion
template <typename T> struct std_vector_to_tuple
{
	static PyObject * makeItem( const wxString & str )
        {
            return boost::python::incref( PyHandler::Convert( str ).ptr() );
        }

	static PyObject * makeItem( const std::string & str )
        {
            return boost::python::incref(
                boost::python::str( str.c_str() ).ptr() );
        }

	static PyObject * makeItem( int item )
        {
            return boost::python::incref( PyInt_FromLong( item ) );
        }

	static PyObject * convert( const T& vect )
	{
		PyObject * tuple = PyTuple_New( vect.size() );
		for ( unsigned int i = 0; i < vect.size() ; i++ )
		{
			PyTuple_SET_ITEM( tuple, i, makeItem( vect[i] ) );
		}
		return tuple;
	}
};

PyHandler* PyHandler::m_instance = NULL;


/* Singleton implementation */
PyHandler * PyHandler::GetInstance()
{
	if( !PyHandler::m_instance )
	{
		PyHandler::m_instance = new PyHandler();
	}
	return PyHandler::m_instance;
}


/* Init the Python env */
PyHandler::PyHandler()
{
    Py_Initialize();
    PyEval_InitThreads();
    m_ModulesLoaded = false;
    m_current = 0;
    if( !wxPyCoreAPI_IMPORT() )
    {
        std::cerr << "Can't get wx Python binding\n" ;
        PyErr_Print();
    }
//    m_mainTState = wxPyBeginAllowThreads(); // I can't figure out why this make py crash ...
    m_mainTState = NULL;

    // Make the console appear in a window:
    wxString initConsole;
    initConsole += wxT( "import sys\n" );
    initConsole += wxT( "import wx\n" );
    initConsole += wxT( "output = wx.PyOnDemandOutputWindow()\n" );
    initConsole += wxT( "sys.stdout = sys.stderr = output\n" );
    RunSimpleString( initConsole );

    AddToModule  ( wxT( "common" ), &init_base_utils );

    // Register converters

    to_python_converter < std::vector< std::string >,
        std_vector_to_tuple< const std::vector < std::string > >  > ();
    to_python_converter < std::vector< wxString >,
        std_vector_to_tuple< const std::vector < wxString > >  > ();
}


void PyHandler::DoInitModules()
{
    if ( m_ModulesLoaded )
        return;

    m_ModulesLoaded = true;

    for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ )
    {
        detail::init_module( m_ModuleRegistry[i].name.mb_str(),
                             &InitPyModules );
    }
}


/* Returns the module index in the registry, -1 if not found*/
int PyHandler::GetModuleIndex( const wxString & name ) const
{
    for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ )
    {
        if ( m_ModuleRegistry[i].name == name ) return i;
    }
    return -1;
}


/* Adds an init function to a python module */
void PyHandler::AddToModule( const wxString & name,
                             PyHandler::initfunc_t initfunc )
{
    if (!initfunc)
        return;

    int i = GetModuleIndex( name );

    if ( -1 == i )
    {
        m_ModuleRegistry.push_back( ModuleRecord( name ) );
        i = m_ModuleRegistry.size() - 1;
    }

    m_ModuleRegistry[i].registry.push_back( initfunc );
}


/* Called to initialize a module on py 'import module' */
void PyHandler::InitNextModule()
{
    for ( unsigned int j = 0;
          j < m_ModuleRegistry[m_current].registry.size();
          j++ )
    {
        m_ModuleRegistry[m_current].registry[j]();
    }

    m_current++;
}


/* Closes the Python env */
PyHandler::~PyHandler()
{
    wxPyEndAllowThreads(m_mainTState);
	Py_Finalize();
}


/* Run scripts looking in 'base' directory */
void PyHandler::RunBaseScripts( const wxString & base )
{
    const wxString sep = wxFileName().GetPathSeparator();

	// check if we can have a kicad_startup.py around ?
	wxString script = base + wxT( "scripts" ) + sep + wxT( "kicad_startup.py" );
	if ( wxFileExists( script ) )
        RunScript( script );

	// First find scripts/<name>.py and run it if found :

	script = base + wxString::FromAscii( "scripts" ) + sep + m_appName
        + wxString::FromAscii(".py");

	if ( wxFileExists(  script ) )
        RunScript( script );

	// Now lets see if we can find a suitable plugin directory
    // (plugin/<name>) somewhere

	wxString pluginDir = base + wxT( "plugins" ) + sep + m_appName;
	if ( wxDirExists( pluginDir ) )
	{
		// We do have a systemwide plugin dir, let's find files in it
		wxArrayString pluginList;
		wxDir::GetAllFiles( pluginDir, &pluginList, wxT("*.py") );

		for ( unsigned int i = 0; i < pluginList.Count() ; i++ )
		{
			RunScript( pluginList[i] );
		}
	}
}


/* Run application startup scripts */
void PyHandler::RunScripts()
{
	// SYSTEMWIDE:

    const wxString sep = wxFileName().GetPathSeparator();

	wxString dataPath = ReturnKicadDatasPath();
	if ( wxDirExists( dataPath ) )	RunBaseScripts( dataPath );

	// USER Scripts:
	wxString userDir = wxGetUserHome() + sep
        + wxString::FromAscii(".kicad.d") + sep;
	if ( wxDirExists( userDir ) )
        RunBaseScripts( userDir );
	userDir = wxGetUserHome() + sep + wxString::FromAscii("_kicad_d") + sep;
	if ( wxDirExists( userDir ) )
        RunBaseScripts( userDir );

}


/* Run the script specified by 'name' */
bool PyHandler::RunScript( const wxString & name )
{
    DoInitModules();

    object module( handle<>(borrowed(PyImport_AddModule("__main__"))));
    object ns = module.attr( "__dict__" );
    bool ret = true;

    FILE * file = fopen( name.mb_str(), "r" );

    wxPyBlock_t blocked = wxPyBeginBlockThreads();

    if ( !file )
    {
    	// do something
    	std::cout << "Unable to Load " << name.mb_str()  << "\n";
    	ret = false;
    }
    else
    {
        wxString currDir = wxGetCwd();

        wxFileName fname( name );
        wxString pyDir = fname.GetPath();

        wxSetWorkingDirectory( pyDir );
        try
        {
            ns["currentScript"] = Convert( name );
            handle<> ignored( PyRun_File( file, name.mb_str(), Py_file_input,
                                          ns.ptr(), ns.ptr() ) );
        }
        catch ( error_already_set )
        {
            PyErr_Print(); // should be printed into an error message ...
            ret = false;
        }
        wxSetWorkingDirectory( currDir );
    }

	fclose( file );
    wxPyEndBlockThreads(blocked);
	return ret;
}


bool PyHandler::RunSimpleString( const wxString & code )
/* Run the code in 'code' */
{
    wxPyBlock_t blocked = wxPyBeginBlockThreads();
	try
	{
    	PyRun_SimpleString( code.mb_str() );
	}
	catch ( error_already_set )
	{
		PyErr_Print(); // should be printed into an error message ...
        wxPyEndBlockThreads(blocked);
		return false;
	}

    wxPyEndBlockThreads(blocked);
	return true;
}


void PyHandler::SetAppName( const wxString & name )
/* Set the application name in the python scope */
{
	m_appName = name;
    object module( ( handle<>( borrowed( PyImport_AddModule( "__main__") ) ) ) );
    object ns = module.attr( "__dict__" );
	try
    {
		ns["kicadApp"] = std::string( name.ToAscii() );
	}
	catch( error_already_set )
	{
		PyErr_Print();
	}
}


const char * PyHandler::GetVersion() { return Py_GetVersion(); }


// Event handling :

void PyHandler::DeclareEvent( const wxString & key )
{
    m_EventRegistry.push_back( Event( key ) );
}


int PyHandler::GetEventIndex( const wxString & key )
{
    for ( unsigned int i = 0; i < m_EventRegistry.size(); i ++ )
    {
        if ( m_EventRegistry[i].key == key )
            return i;
    }

    return -1;
}


void PyHandler::TriggerEvent( const wxString & key )
{
    TriggerEvent( key, str( "" ) );
}


void PyHandler::TriggerEvent( const wxString & key, const object & param )
{

    int i = GetEventIndex( key );
    if ( -1 == i )
        return;

    wxPyBlock_t blocked = wxPyBeginBlockThreads();

    for( unsigned int j = 0; j < m_EventRegistry[i].functors.size(); j++ )
    {
        try
        {
            m_EventRegistry[i].functors[j]( param );
        }
        catch( error_already_set )
        {
            std::cout << "Error in event " << key.mb_str() << " callback"
                      << std::endl;
            PyErr_Print();
        }
    }

    wxPyEndBlockThreads( blocked );
}


void PyHandler::RegisterCallback( const wxString & key,
                                  const object & callback )
{
    int i = GetEventIndex( key );

    if( -1 == i )
        return;

    m_EventRegistry[i].functors.push_back( callback );
}


void PyHandler::UnRegisterCallback( const wxString & key,
                                    const object & callback )
{
    int i = GetEventIndex( key );
    if( -1 == i )
        return;
    for( unsigned int j = 0; j < m_EventRegistry[i].functors.size() ; j++ )
    {
        if ( callback == m_EventRegistry[i].functors[j] )
        {
            m_EventRegistry[i].functors.erase(
                m_EventRegistry[i].functors.begin() + j );
            break;
        }
    }
}


// Object conversion:

wxString PyHandler::MakeStr( const object & objStr )
{
    return wxString( extract<const char *>( objStr ), wxConvLocal );
}


object PyHandler::Convert( const wxString & wxStr )
{
    return str( std::string( wxStr.mb_str() ).c_str() );
}
Loading