Пример #1
0
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
    // This is for python:
    if( aFileSet.size() != 1 )
    {
        UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ );
        DisplayError( this, msg );
        return false;
    }

    wxString fullFileName( aFileSet[0] );

    // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
    wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) );

    std::unique_ptr<wxSingleInstanceChecker> lockFile = ::LockFile( fullFileName );

    if( !lockFile )
    {
        wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName );
        DisplayError( this, msg );
        return false;
    }

    if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
    {
        if( !HandleUnsavedChanges( this, _( "The current PCB has been modified.  Save changes?" ),
            [&]()->bool { return SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE ); } ) )
        {
            return false;
        }
    }

    // Release the lock file, until the new file is actually loaded
    ReleaseFile();

    wxFileName pro = fullFileName;
    pro.SetExt( ProjectFileExtension );

    bool is_new = !wxFileName::IsFileReadable( fullFileName );

    // If its a non-existent schematic and caller thinks it exists
    if( is_new && !( aCtl & KICTL_CREATE ) )
    {
        // notify user that fullFileName does not exist, ask if user wants to create it.
        wxString ask = wxString::Format( _( "PCB \"%s\" does not exist.  Do you wish to create it?" ),
                                         fullFileName );
        if( !IsOK( this, ask ) )
            return false;
    }

    Clear_Pcb( false );     // pass false since we prompted above for a modified board

    IO_MGR::PCB_FILE_T  pluginType = plugin_type( fullFileName, aCtl );

    bool converted =  pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD_SEXP;

    if( !converted )
    {
        // PROJECT::SetProjectFullName() is an impactful function.  It should only be
        // called under carefully considered circumstances.

        // The calling code should know not to ask me here to change projects unless
        // it knows what consequences that will have on other KIFACEs running and using
        // this same PROJECT.  It can be very harmful if that calling code is stupid.
        Prj().SetProjectFullName( pro.GetFullPath() );

        // load project settings before BOARD
        LoadProjectSettings();
    }

    if( is_new )
    {
        OnModify();
    }
    else
    {
        BOARD* loadedBoard = 0;   // it will be set to non-NULL if loaded OK

        PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );

        // This will rename the file if there is an autosave and the user want to recover
		CheckForAutoSaveFile( fullFileName );

        try
        {
            PROPERTIES  props;
            char        xbuf[30];
            char        ybuf[30];

            // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
            sprintf( xbuf, "%d", GetPageSizeIU().x );
            sprintf( ybuf, "%d", GetPageSizeIU().y );

            props["page_width"]  = xbuf;
            props["page_height"] = ybuf;

#if USE_INSTRUMENTATION
            // measure the time to load a BOARD.
            unsigned startTime = GetRunningMicroSecs();
#endif

            loadedBoard = pi->Load( fullFileName, NULL, &props );

#if USE_INSTRUMENTATION
            unsigned stopTime = GetRunningMicroSecs();
            printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime );
#endif
        }
        catch( const IO_ERROR& ioe )
        {
            if( ioe.Problem() != wxT( "CANCEL" ) )
            {
                wxString msg = wxString::Format( _( "Error loading board file:\n%s" ), fullFileName );
                DisplayErrorMessage( this, msg, ioe.What() );
            }

            return false;
        }


        // 6.0 TODO: some settings didn't make it into the board file in 5.1 so as not to
        // change the file format.  For 5.1 we must copy them across from the config-initialized
        // board.
        BOARD_DESIGN_SETTINGS& bds = loadedBoard->m_designSettings;
        BOARD_DESIGN_SETTINGS& configBds = GetBoard()->GetDesignSettings();

        bds.m_RequireCourtyards                 = configBds.m_RequireCourtyards;
        bds.m_ProhibitOverlappingCourtyards     = configBds.m_ProhibitOverlappingCourtyards;
        bds.m_HoleToHoleMin                     = configBds.m_HoleToHoleMin;
        bds.m_LineThickness[LAYER_CLASS_OTHERS] = configBds.m_LineThickness[LAYER_CLASS_OTHERS];
        bds.m_TextSize[LAYER_CLASS_OTHERS]      = configBds.m_TextSize[LAYER_CLASS_OTHERS];
        bds.m_TextThickness[LAYER_CLASS_OTHERS] = configBds.m_TextThickness[LAYER_CLASS_OTHERS];
        std::copy( configBds.m_TextItalic,  configBds.m_TextItalic + 4,  bds.m_TextItalic );
        std::copy( configBds.m_TextUpright, configBds.m_TextUpright + 4, bds.m_TextUpright );
        bds.m_DiffPairDimensionsList            = configBds.m_DiffPairDimensionsList;
        bds.m_CopperEdgeClearance               = configBds.m_CopperEdgeClearance;

        SetBoard( loadedBoard );

        // we should not ask PLUGINs to do these items:
        loadedBoard->BuildListOfNets();
        loadedBoard->SynchronizeNetsAndNetClasses();

        // If this is a legacy board then we set the copper edge clearance to 1/2 the edge-cut
        // line width (which was a legacy kludge for implementing edge clearances).
        if( bds.m_CopperEdgeClearance == Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ) )
            bds.SetCopperEdgeClearance( inferLegacyEdgeClearance( loadedBoard ) );

        if( loadedBoard->IsModified() )
            OnModify();
        else
            GetScreen()->ClrModify();

        if( pluginType == IO_MGR::LEGACY &&
            loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION )
        {
            DisplayInfoMessage( this,
                _(  "This file was created by an older version of Pcbnew.\n"
                    "It will be stored in the new file format when you save this file again." ) );
        }
    }

    {
        wxFileName fn = fullFileName;

        if( converted )
            fn.SetExt( PcbFileExtension );

        wxString fname = fn.GetFullPath();

        fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        GetBoard()->SetFileName( fname );
    }

    // Lock the file newly opened:
    m_file_checker.reset( lockFile.release() );

    if( !converted )
        UpdateFileHistory( GetBoard()->GetFileName() );

    // Rebuild the new pad list (for drc and ratsnet control ...)
    GetBoard()->m_Status_Pcb = 0;

    // Select netclass Default as current netclass (it always exists)
    SetCurrentNetClass( NETCLASS::Default );

    // Rebuild list of nets (full ratsnest rebuild)
    Compile_Ratsnest( NULL, true );
    GetBoard()->BuildConnectivity();

    onBoardLoaded();

    // Refresh the 3D view, if any
    EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();

    if( draw3DFrame )
        draw3DFrame->NewDisplay();

#if 0 && defined(DEBUG)
    // Output the board object tree to stdout, but please run from command prompt:
    GetBoard()->Show( 0, std::cout );
#endif

    // from EDA_APPL which was first loaded BOARD only:
    {
        /* For an obscure reason the focus is lost after loading a board file
         * when starting up the process.
         * (seems due to the recreation of the layer manager after loading the file)
         * Give focus to main window and Drawpanel
         * must be done for these 2 windows (for an obscure reason ...)
         * Linux specific
         * This is more a workaround than a fix.
         */
        SetFocus();
        GetCanvas()->SetFocus();
    }

    return true;
}
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
    // This is for python:
    if( aFileSet.size() != 1 )
    {
        UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ );
        DisplayError( this, msg );
        return false;
    }

    wxString fullFileName( aFileSet[0] );

    // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
    wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(),
        wxT( "bug in single_top.cpp or project manager." ) );

    if( !LockFile( fullFileName ) )
    {
        wxString msg = wxString::Format( _(
                "PCB file '%s' is already open." ),
                GetChars( fullFileName )
                );
        DisplayError( this, msg );
        return false;
    }

    if( GetScreen()->IsModify() )
    {
        int response = YesNoCancelDialog( this, _(
            "The current board has been modified.  Do you wish to save the changes?" ),
            wxEmptyString,
            _( "Save and Load" ),
            _( "Load Without Saving" )
            );

        if( response == wxID_CANCEL )
            return false;
        else if( response == wxID_YES )
            SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE );
        else
        {
            // response == wxID_NO, fall thru
        }
    }

    wxFileName pro = fullFileName;
    pro.SetExt( ProjectFileExtension );

    bool is_new = !wxFileName::IsFileReadable( fullFileName );

    // If its a non-existent schematic and caller thinks it exists
    if( is_new && !( aCtl & KICTL_CREATE ) )
    {
        // notify user that fullFileName does not exist, ask if user wants to create it.
        wxString ask = wxString::Format( _(
                "Board '%s' does not exist.  Do you wish to create it?" ),
                GetChars( fullFileName )
                );
        if( !IsOK( this, ask ) )
            return false;
    }

    Clear_Pcb( false );     // pass false since we prompted above for a modified board

    IO_MGR::PCB_FILE_T  pluginType = plugin_type( fullFileName, aCtl );

    bool converted =  pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD;

    if( !converted )
    {
        // PROJECT::SetProjectFullName() is an impactful function.  It should only be
        // called under carefully considered circumstances.

        // The calling code should know not to ask me here to change projects unless
        // it knows what consequences that will have on other KIFACEs running and using
        // this same PROJECT.  It can be very harmful if that calling code is stupid.
        Prj().SetProjectFullName( pro.GetFullPath() );

        // load project settings before BOARD
        LoadProjectSettings();
    }

    if( is_new )
    {
        OnModify();
    }
    else
    {
        BOARD* loadedBoard = 0;   // it will be set to non-NULL if loaded OK

        PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );

        try
        {
            PROPERTIES  props;
            char        xbuf[30];
            char        ybuf[30];

            // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
            sprintf( xbuf, "%d", GetPageSizeIU().x );
            sprintf( ybuf, "%d", GetPageSizeIU().y );

            props["page_width"]  = xbuf;
            props["page_height"] = ybuf;

#if USE_INSTRUMENTATION
            // measure the time to load a BOARD.
            unsigned startTime = GetRunningMicroSecs();
#endif

            loadedBoard = pi->Load( fullFileName, NULL, &props );

#if USE_INSTRUMENTATION
            unsigned stopTime = GetRunningMicroSecs();
            printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime );
#endif
        }
        catch( const IO_ERROR& ioe )
        {
            wxString msg = wxString::Format( _(
                    "Error loading board.\n%s" ),
                    GetChars( ioe.errorText )
                    );
            DisplayError( this, msg );

            return false;
        }

        SetBoard( loadedBoard );

        // we should not ask PLUGINs to do these items:
        loadedBoard->BuildListOfNets();
        loadedBoard->SynchronizeNetsAndNetClasses();

        SetStatusText( wxEmptyString );
        BestZoom();

        // update the layer names in the listbox
        ReCreateLayerBox( false );

        GetScreen()->ClrModify();

        {
            wxFileName fn = fullFileName;
            CheckForAutoSaveFile( fullFileName, fn.GetExt() );
        }

        if( pluginType == IO_MGR::LEGACY &&
            loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION )
        {
            DisplayInfoMessage( this,
                _(  "This file was created by an older version of Pcbnew.\n"
                    "It will be stored in the new file format when you save this file again." ) );
        }
    }

    {
        wxFileName fn = fullFileName;

        if( converted )
            fn.SetExt( PcbFileExtension );

        wxString fname = fn.GetFullPath();

        fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        GetBoard()->SetFileName( fname );
    }

    UpdateTitle();

    if( !converted )
        UpdateFileHistory( GetBoard()->GetFileName() );

    // Rebuild the new pad list (for drc and ratsnet control ...)
    GetBoard()->m_Status_Pcb = 0;

    // Update info shown by the horizontal toolbars
    SetCurrentNetClass( NETCLASS::Default );
    ReFillLayerWidget();
    ReCreateLayerBox();

    // upate the layer widget to match board visibility states, both layers and render columns.
    syncLayerVisibilities();
    syncLayerWidgetLayer();
    syncRenderStates();

    // Update the tracks / vias available sizes list:
    ReCreateAuxiliaryToolbar();

    // Update the RATSNEST items, which were not loaded at the time
    // BOARD::SetVisibleElements() was called from within any PLUGIN.
    // See case RATSNEST_VISIBLE: in BOARD::SetElementVisibility()
    GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() );

    // Display the loaded board:
    Zoom_Automatique( false );

    // Compile ratsnest and displays net info
    {
        wxBusyCursor dummy;    // Displays an Hourglass while building connectivity
        Compile_Ratsnest( NULL, true );
        GetBoard()->GetRatsnest()->ProcessBoard();
    }

    SetMsgPanel( GetBoard() );

    // Refresh the 3D view, if any
    if( m_Draw3DFrame )
        m_Draw3DFrame->NewDisplay();

#if 0 && defined(DEBUG)
    // Output the board object tree to stdout, but please run from command prompt:
    GetBoard()->Show( 0, std::cout );
#endif

    // from EDA_APPL which was first loaded BOARD only:
    {
        /* For an obscure reason the focus is lost after loading a board file
         * when starting up the process.
         * (seems due to the recreation of the layer manager after loading the file)
         * Give focus to main window and Drawpanel
         * must be done for these 2 windows (for an obscure reason ...)
         * Linux specific
         * This is more a workaround than a fix.
         */
        SetFocus();
        GetCanvas()->SetFocus();
    }

    return true;
}
int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
{
    int open_ctl;
    wxString fileName;
    PICKED_ITEMS_LIST undoListPicker;
    ITEM_PICKER picker( NULL, UR_NEW );

    PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
    BOARD* board = getModel<BOARD>();
    KIGFX::VIEW* view = getView();

    if( !editFrame )
        return 0;

    // Pick a file to append
    if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
        return 0;

    IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
    PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );

    // keep track of existing items, in order to know what are the new items
    // (for undo command for instance)

    // Tracks are inserted, not appended, so mark the existing tracks to know what are the new tracks
    for( TRACK* track = board->m_Track; track; track = track->Next() )
        track->SetFlags( FLAG0 );

    // Other items are appended to the item list, so keep trace to the last existing item is enough
    MODULE* module = board->m_Modules.GetLast();
    BOARD_ITEM* drawing = board->m_Drawings.GetLast();
    int zonescount = board->GetAreaCount();

    // Keep also the count of copper layers, to adjust if necessary
    int initialCopperLayerCount = board->GetCopperLayerCount();
    LSET initialEnabledLayers = board->GetEnabledLayers();

    // Load the data
    try
    {
        PROPERTIES  props;
        char        xbuf[30];
        char        ybuf[30];

        // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
        sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
        sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );

        props["page_width"]  = xbuf;
        props["page_height"] = ybuf;

        editFrame->GetDesignSettings().m_NetClasses.Clear();
        pi->Load( fileName, board, &props );
    }
    catch( const IO_ERROR& ioe )
    {
        wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.errorText ));
        DisplayError( editFrame, msg );

        return 0;
    }

    m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );

    // Process the new items
    for( TRACK* track = board->m_Track; track; track = track->Next() )
    {
        if( track->GetFlags() & FLAG0 )
        {
            track->ClearFlags( FLAG0 );
            continue;
        }

        picker.SetItem( track );
        undoListPicker.PushItem( picker );
        view->Add( track );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, track );
    }

    module = module ? module->Next() : board->m_Modules;

    for( ; module; module = module->Next() )
    {
        picker.SetItem( module );
        undoListPicker.PushItem( picker );

        module->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
        view->Add( module );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, module );
    }

    drawing = drawing ? drawing->Next() : board->m_Drawings;

    for( ; drawing; drawing = drawing->Next() )
    {
        picker.SetItem( drawing );
        undoListPicker.PushItem( picker );
        view->Add( drawing );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, drawing );
    }

    for( ZONE_CONTAINER* zone = board->GetArea( zonescount ); zone;
         zone = board->GetArea( zonescount ) )
    {
        picker.SetItem( zone );
        undoListPicker.PushItem( picker );
        zonescount++;
        view->Add( zone );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, zone );
    }

    if( undoListPicker.GetCount() == 0 )
        return 0;

    editFrame->SaveCopyInUndoList( undoListPicker, UR_NEW );

    // Synchronize layers
    // we should not ask PLUGINs to do these items:
    int copperLayerCount = board->GetCopperLayerCount();

    if( copperLayerCount > initialCopperLayerCount )
        board->SetCopperLayerCount( copperLayerCount );

    // Enable all used layers, and make them visible:
    LSET enabledLayers = board->GetEnabledLayers();
    enabledLayers |= initialEnabledLayers;
    board->SetEnabledLayers( enabledLayers );
    board->SetVisibleLayers( enabledLayers );
    editFrame->ReCreateLayerBox();
    editFrame->ReFillLayerWidget();
    static_cast<PCB_DRAW_PANEL_GAL*>( editFrame->GetGalCanvas() )->SyncLayersVisibility( board );

    // Ratsnest
    board->BuildListOfNets();
    board->SynchronizeNetsAndNetClasses();
    board->GetRatsnest()->Recalculate();

    // Start dragging the appended board
    VECTOR2D v( static_cast<BOARD_ITEM*>( undoListPicker.GetPickedItem( 0 ) )->GetPosition() );
    getViewControls()->WarpCursor( v, true, true );
    m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );

    return 0;
}
bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl )
{
    IO_MGR::PCB_FILE_T  pluginType = plugin_type( aFullFileName, aCtl );
    PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );

    // keep trace of existing items, in order to know what are the new items
    // (for undo command for instance)

    // Tracks are inserted, not append, so mark existing tracks to know what are
    // the new tracks
    for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
        track->SetFlags( FLAG0 );

    // Other items are append to the item list, so keep trace to the
    // last existing item is enough
    MODULE* module = GetBoard()->m_Modules.GetLast();
    BOARD_ITEM* drawing = GetBoard()->m_Drawings.GetLast();
    int zonescount = GetBoard()->GetAreaCount();

    // Keep also the count of copper layers, because we can happen boards
    // with different copper layers counts,
    // and the enabled layers
    int initialCopperLayerCount = GetBoard()->GetCopperLayerCount();
    LSET initialEnabledLayers = GetBoard()->GetEnabledLayers();

    try
    {
        PROPERTIES  props;
        char        xbuf[30];
        char        ybuf[30];

        // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
        sprintf( xbuf, "%d", GetPageSizeIU().x );
        sprintf( ybuf, "%d", GetPageSizeIU().y );

        props["page_width"]  = xbuf;
        props["page_height"] = ybuf;

        GetDesignSettings().m_NetClasses.Clear();
        pi->Load( aFullFileName, GetBoard(), &props );
    }
    catch( const IO_ERROR& ioe )
    {
        for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
            track->ClearFlags( FLAG0 );

        wxString msg = wxString::Format( _(
                "Error loading board.\n%s" ),
                GetChars( ioe.What() )
                );
        DisplayError( this, msg );

        return false;
    }

    // Now prepare a block move command to place the new items, and
    // prepare the undo command.
    BLOCK_SELECTOR& blockmove = GetScreen()->m_BlockLocate;
    HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) );
    PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
    PICKED_ITEMS_LIST undoListPicker;
    ITEM_PICKER picker( NULL, UR_NEW );

    EDA_RECT bbox;          // the new items bounding box, for block move
    bool bboxInit = true;   // true until the bounding box is initialized

    for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
    {
        if( track->GetFlags() & FLAG0  )
        {
            track->ClearFlags( FLAG0 );
            continue;
        }

        track->SetFlags( IS_MOVED );
        picker.SetItem( track );
        undoListPicker.PushItem( picker );
        blockitemsList.PushItem( picker );

        if( bboxInit )
            bbox = track->GetBoundingBox();
        else
            bbox.Merge( track->GetBoundingBox() );

        bboxInit = false;
    }

    if( module )
        module = module->Next();
    else
        module = GetBoard()->m_Modules;

    for( ; module; module = module->Next() )
    {
        module->SetFlags( IS_MOVED );
        picker.SetItem( module );
        undoListPicker.PushItem( picker );
        blockitemsList.PushItem( picker );

        if( bboxInit )
            bbox = module->GetBoundingBox();
        else
            bbox.Merge( module->GetBoundingBox() );

        bboxInit = false;
    }

    if( drawing )
        drawing = drawing->Next();
    else
        drawing = GetBoard()->m_Drawings;

    for( ; drawing; drawing = drawing->Next() )
    {
        drawing->SetFlags( IS_MOVED );
        picker.SetItem( drawing );
        undoListPicker.PushItem( picker );
        blockitemsList.PushItem( picker );

        if( bboxInit )
            bbox = drawing->GetBoundingBox();
        else
            bbox.Merge( drawing->GetBoundingBox() );

        bboxInit = false;
    }

    for( ZONE_CONTAINER* zone = GetBoard()->GetArea( zonescount ); zone;
         zone = GetBoard()->GetArea( zonescount ) )
    {
        zone->SetFlags( IS_MOVED );
        picker.SetItem( zone );
        undoListPicker.PushItem( picker );
        blockitemsList.PushItem( picker );
        zonescount++;

        if( bboxInit )
            bbox = zone->GetBoundingBox();
        else
            bbox.Merge( zone->GetBoundingBox() );

        bboxInit = false;
    }

    SaveCopyInUndoList( undoListPicker, UR_NEW );

    // we should not ask PLUGINs to do these items:
    int copperLayerCount = GetBoard()->GetCopperLayerCount();

    if( copperLayerCount > initialCopperLayerCount )
        GetBoard()->SetCopperLayerCount( copperLayerCount );

    // Enable all used layers, and make them visible:
    LSET enabledLayers = GetBoard()->GetEnabledLayers();
    enabledLayers |= initialEnabledLayers;
    GetBoard()->SetEnabledLayers( enabledLayers );
    GetBoard()->SetVisibleLayers( enabledLayers );
    ReCreateLayerBox();
    ReFillLayerWidget();

    if( IsGalCanvasActive() )
        static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() );

    GetBoard()->BuildListOfNets();
    GetBoard()->SynchronizeNetsAndNetClasses();

    SetStatusText( wxEmptyString );
    BestZoom();

    // Finish block move command:
    wxPoint cpos = GetNearestGridPosition( bbox.Centre() );
    blockmove.SetOrigin( bbox.GetOrigin() );
    blockmove.SetSize( bbox.GetSize() );
    blockmove.SetLastCursorPosition( cpos );
    HandleBlockEnd( NULL );

    return true;
}
Пример #5
0
int main (int argc, char *argv[])
{
   char c;
   char plugins[100][100], s[20];
   char romfile[PATH_MAX];
   int old_i, i, i1, i2, i3, i4;
   int p, p_fullscreen = 0, p_emumode = 0, p_gfx = 0, p_audio = 0, p_input = 0, p_rsp = 0, p_help = 0, p_error = 0;
   int p_emumode_value=1, fileloaded = 0, p_interactive = 0;
   int true = 1;
   char *buffer, *buffer2;
   
#if defined (__linux__)
   if (signal(SIGTERM, sigterm_handler) == SIG_ERR)
     printf("Warning: Couldn't register SIGTERM signal handler!\n");
#endif
   
   //Set working dir
#ifdef WITH_HOME
     {
	char temp[PATH_MAX], orig[PATH_MAX];
	FILE *src, *dest;
	struct dirent *entry;
	DIR *dir;
	
	strcpy(g_WorkingDir, getenv("HOME"));
	strcat(g_WorkingDir, "/.mupen64/");
	strcpy(cwd, g_WorkingDir);
	mkdir(g_WorkingDir, 0700);
	
	strcpy(temp, g_WorkingDir);
	strcat(temp, "mupen64.ini");
	dest = fopen(temp, "rb");
	if (dest == NULL)
	  {
	     unsigned char byte;
	     dest = fopen(temp, "wb");
	     strcpy(orig, WITH_HOME);
	     strcat(orig, "share/mupen64/mupen64.ini");
	     src = fopen(orig, "rb");
	     while(fread(&byte, 1, 1, src))
	       fwrite(&byte, 1, 1, dest);
	     fclose(src);
	     fclose(dest);
	  }
	else fclose(dest);
	
	strcpy(temp, g_WorkingDir);
	strcat(temp, "lang");
	strcpy(orig, WITH_HOME);
	strcat(orig, "share/mupen64/lang");
	symlink(orig, temp);
	
	/*strcpy(temp, g_WorkingDir);
	strcat(temp, "plugins");
	strcpy(orig, WITH_HOME);
	strcat(orig, "share/mupen64/plugins");
	symlink(orig, temp);*/
	
	strcpy(temp, g_WorkingDir);
	strcat(temp, "plugins");
	mkdir(temp, 0700);
	strcpy(orig, WITH_HOME);
	strcat(orig, "share/mupen64/plugins");
	dir = opendir(orig);
	while((entry = readdir(dir)) != NULL)
	  {
	     if(strcmp(entry->d_name + strlen(entry->d_name) - 3, ".so"))
	       {
		  strcpy(orig, WITH_HOME);
		  strcat(orig, "share/mupen64/plugins/");
		  strcat(orig, entry->d_name);
		  src = fopen(orig, "rb");
		  if(src == NULL) continue;
		  
		  strcpy(temp, g_WorkingDir);
		  strcat(temp, "plugins/");
		  strcat(temp, entry->d_name);
		  dest = fopen(temp, "rb");
		  if(dest == NULL)
		    {
		       unsigned char byte;
		       dest = fopen(temp, "wb");
		       while(fread(&byte, 1, 1, src))
			 fwrite(&byte, 1, 1, dest);
		       fclose(src);
		       fclose(dest);
		    }
		  else fclose(dest);
	       }
	     else
	       {
		  strcpy(temp, g_WorkingDir);
		  strcat(temp, "plugins/");
		  strcat(temp, entry->d_name);
		  strcpy(orig, WITH_HOME);
		  strcat(orig, "share/mupen64/plugins/");
		  strcat(orig, entry->d_name);
		  symlink(orig, temp);
	       }
	  }
	
	strcpy(temp, g_WorkingDir);
	strcat(temp, "save/");
	mkdir(temp, 0700);
	
	chdir(g_WorkingDir);
     }
#else
   if (argv[0][0] != '/')
     {
	getcwd(cwd, 1024);
	strcat(cwd, "/");
	strcat(cwd, argv[0]);
     }
   else
     strcpy(cwd, argv[0]);
   while(cwd[strlen(cwd)-1] != '/') cwd[strlen(cwd)-1] = '\0';
   strcpy(g_WorkingDir, cwd);
#endif
   
   //read config file, read plugins
   config_read();
   plugin_scan_directory(cwd);
   
   //get config file settings
   
   buffer = (char*)config_get_string("Gfx Plugin", "");
   buffer2= plugin_name_by_filename(buffer);
   if(buffer2)
     {
	strcpy(plugins[100], buffer2);
	p_gfx = true;
     }
   else if(buffer) printf("GFX Plugin from ini-file could not be loaded\n");
   
   buffer = (char*)config_get_string("Audio Plugin", "");
   buffer2= plugin_name_by_filename(buffer);
   if(buffer2)
     {
	strcpy(plugins[99], buffer2);
	p_audio = true;
     }
   else if(buffer) printf("Audio Plugin from ini-file could not be loaded\n");
   
   buffer = (char*)config_get_string("Input Plugin", "");
   buffer2= plugin_name_by_filename(buffer);
   if(buffer2)
     {
	strcpy(plugins[98], buffer2);
	p_input = true;
     }
   else if(buffer) printf("Input Plugin from ini-file could not be loaded\n");
   
   buffer = (char*)config_get_string("RSP Plugin", "");
   buffer2= plugin_name_by_filename(buffer);
   if(buffer2)
     {
	strcpy(plugins[97], buffer2);
	p_rsp = true;
     }
   else if(buffer) printf("RSP Plugin from ini-file could not be loaded\n");
   
   buffer = (char*)config_get_string("Core", "");
   if(strcmp(buffer,""))
     {
	p_emumode = true;
	p_emumode_value = buffer[0]-'0'+1;
     }
   
   buffer = (char*)config_get_string("Fullscreen", "");
   if(strcmp(buffer,""))
     {
	if(!strcmp(buffer, "true"))
	  p_fullscreen = true;
     }
   
   buffer = (char*)config_get_string("No Ask", "");
   if(strcmp(buffer,""))
     {
	if(!strcmp(buffer, "true"))
	  p_noask = true;
     }
   
   // Command Line Parameter - Parsing
   
   for(p=1; p<argc; p++)
     {
	if(argv[p][0] == '-')
	  {
	     if(!strcmp(argv[p], "--fullscreen"))
	       p_fullscreen = true;
	     else if(!strcmp(argv[p], "--help"))
	       p_help = true;
	     else if(!strcmp(argv[p], "--noask"))
	       p_noask = true;
	     else if(!strcmp(argv[p], "--interactive"))
	       p_interactive = true;
	     else if(!strcmp(argv[p], "--emumode"))
	       {
		  p++;
		  if(p < argc)
		    {
		       p_emumode_value = argv[p][0];
		       p_emumode = true;
		    }
	       }
	     else if(!strcmp(argv[p], "--gfx"))
	       {
		  p++;
		  if(p < argc)
		    {
		       buffer = plugin_name_by_filename(argv[p]);
		       if(buffer)
			 {
			    strcpy(plugins[100], buffer);
			    p_gfx = true;
			 }
		       else printf("specified GFX Plugin couldn't be loaded!\n");
		    }
	       }
	     else if(!strcmp(argv[p], "--audio"))
	       {
		  p++;
		  if(p < argc)
		    {
		       buffer = plugin_name_by_filename(argv[p]);
		       if(buffer)
			 {
			    strcpy(plugins[99], buffer);
			    p_audio = true;
			 }
		       else printf("specified Audio Plugin couldn't be loaded!\n");
		    }
	       }
	     else if(!strcmp(argv[p], "--input"))
	       {
		  p++;
		  if(p < argc)
		    {
		       buffer = plugin_name_by_filename(argv[p]);
		       if(buffer)
			 {
			    strcpy(plugins[98], buffer);
			    p_input = true;
			 }
		       else printf("specified Input Plugin couldn't be loaded!\n");
		    }
	       }
	     else if(!strcmp(argv[p], "--rsp"))
	       {
		  p++;
		  if(p < argc)
		    {
		       buffer = plugin_name_by_filename(argv[p]);
		       if(buffer)
			 {
			    strcpy(plugins[97], buffer);
			    p_rsp = true;
			 }
		       else printf("specified RSP Plugin couldn't be loaded!\n");
		    }
	       }
	  }
	else
	  {
	     strcpy(romfile, argv[p]);
	     fileloaded = true;
	  }
     }
   
   if(p_interactive)
     {
	p_emumode = 0;
	p_gfx = 0;
	p_audio = 0;
	p_input = 0;
	p_rsp = 0;
     }
   
   printf("\nMupen64 version : %s\n", VERSION);
   
   if (argc < 2 || p_help || p_error || fileloaded != true)
     {
	printf("\n\n"
	       "syntax: mupen64_nogui [parameter(s)] rom\n"
	       "\n"
	       "Parameters:\n"
	       "  --fullscreen       : turn fullscreen mode on\n"
	       "  --gfx (plugin)     : set gfx plugin to (plugin)\n"
	       "  --audio (plugin)   : set audio plugin to (plugin)\n"
	       "  --input (plugin)   : set input plugin to (plugin)\n"
	       "  --rsp (plugin)     : set rsp plugin to (plugin)\n"
	       "  --emumode (number) : set emu mode to: 1=interp./2=recomp./3=pure interp\n"
	       "  --noask            : don't ask to force load on bad dumps\n"
	       "  --interactive      : ask interactively for all plugins\n"
	       "\n"
	       "You can also use the Config-File from the Gui-Version\n"
	       "but there are aditional Parameters for the NO-GUI Version\n"
	       "\n");
	return 0;
     }
   
   if (rom_read(romfile))
     {
	if(rom) free(rom);
	if(ROM_HEADER) free(ROM_HEADER);
	return 1;
     }
   printf("Goodname:%s\n", ROM_SETTINGS.goodname);
   printf("16kb eeprom=%d\n", ROM_SETTINGS.eeprom_16kb);
   printf ("emulation mode:\n"
	   "     1. interpreter\n"
	   "     2. dynamic recompiler (default)\n"
           "     3. pure interpreter\n");
   
   if(p_emumode)
     c = p_emumode_value;
   else
     c = getchar();
   
   if (c == '1') dynacore=0;
   else if (c == '3') dynacore=2;
   else dynacore=1;
   
   SDL_Init(SDL_INIT_VIDEO);
   SDL_SetVideoMode(10, 10, 16, 0);
   SDL_ShowCursor(0);
   SDL_EnableKeyRepeat(0, 0);
   SDL_EnableUNICODE(1);
   init_memory();
   // --------------------- loading plugins ----------------------
   i=1;
   i1=1;
   printf("  Choose your gfx plugin : \n");
   while(plugin_type() != -1)
     {
	if (plugin_type() == PLUGIN_TYPE_GFX)
	  {
	     strcpy(plugins[i], plugin_next());
	     printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i]));
	     i++;
	  }
	else
	  plugin_next();
     }
   
   if(p_gfx)
     i1 = 100;
   else
     {
	if(p_emumode)
	  getchar();
	/*c = getchar();
	 s[0] = c;
	 s[1] = 0;*/
	scanf("%10s", s);
	i1 = atoi(s);
     }
   
   plugin_rewind();
   old_i = i;
   printf("  Choose your audio plugin : \n");
   while(plugin_type() != -1)
     {
	if (plugin_type() == PLUGIN_TYPE_AUDIO)
	  {
	     strcpy(plugins[i], plugin_next());
	     printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i]));
	     i++;
	  }
	else
	  plugin_next();
     }
   /*getchar();
   c = getchar();
   //getchar();
   s[0] = c;
   s[1] = 0;*/
   if(p_audio)
     i2 = 99;
   else
     {
	scanf("%10s", s);
	i2 = old_i + atoi(s) - 1;
     }
   
   plugin_rewind();
   old_i = i;
   printf("  Choose your input plugin : \n");
   while(plugin_type() != -1)
     {
	if (plugin_type() == PLUGIN_TYPE_CONTROLLER)
	  {
	     strcpy(plugins[i], plugin_next());
	     printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i]));
	     i++;
	  }
	else
	  plugin_next();
     }
   /*getchar();
   c = getchar();
   //getchar();
   s[0] = c;
   s[1] = 0;*/
   if(p_input)
     i3 = 98;
   else
     {
	scanf("%10s", s);
	i3 = old_i + atoi(s) - 1;
     }
   
   plugin_rewind();
   old_i = i;
   printf("  Choose your RSP plugin : \n");
   while(plugin_type() != -1)
     {
	if (plugin_type() == PLUGIN_TYPE_RSP)
	  {
	     strcpy(plugins[i], plugin_next());
	     printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i]));
	     i++;
	  }
	else
	  plugin_next();
     }
   /*getchar();
   c = getchar();
   getchar();
   s[0] = c;
   s[1] = 0;*/
   if(p_rsp)
     i4 = 97;
   else
     {
	scanf("%10s", s);
	i4 = old_i + atoi(s) - 1;
     }
   
   printf("\n\nSelected Plugins: %s, %s, %s, %s\n", plugins[i1], plugins[i2], plugins[3], plugins[i4]);
   
   plugin_load_plugins(plugins[i1], plugins[i2], plugins[i3], plugins[i4]);
   romOpen_gfx();
   romOpen_audio();
   romOpen_input();
   // ------------------------------------------------------------
   SDL_SetEventFilter(filter);
   
   if(p_fullscreen)
     changeWindow();
   
   go();
   romClosed_RSP();
   romClosed_input();
   romClosed_audio();
   romClosed_gfx();
   closeDLL_RSP();
   closeDLL_input();
   closeDLL_audio();
   closeDLL_gfx();
   free(rom);
   free(ROM_HEADER);
   free_memory();
   return 0;
}
Пример #6
0
int main (int argc, char *argv[])
{
   GtkWidget *load_button;
   GtkWidget *table;
   GtkWidget *pixmapwid;
   GtkStyle *style;
   GdkPixmap *pixmap;
   GdkBitmap *mask;
   GtkWidget *label_core;
   
   GList *glist_gfx = NULL;
   GtkWidget *label_gfx;
   GtkWidget *config_gfx_button;
   GtkWidget *test_gfx_button;
   GtkWidget *about_gfx_button;
   
   GList *glist_audio = NULL;
   GtkWidget *label_audio;
   GtkWidget *config_audio_button;
   GtkWidget *test_audio_button;
   GtkWidget *about_audio_button;
   
   GList *glist_input = NULL;
   GtkWidget *label_input;
   GtkWidget *config_input_button;
   GtkWidget *test_input_button;
   GtkWidget *about_input_button;
   
   GList *glist_RSP = NULL;
   GtkWidget *label_RSP;
   GtkWidget *config_RSP_button;
   GtkWidget *test_RSP_button;
   GtkWidget *about_RSP_button;
   
#ifdef DBG
   if (!g_thread_supported())
     g_thread_init(NULL);
   else
     {
	fprintf(stderr, "mupen64 will certainly have problems with GTK threads.\n");
	fprintf(stderr, "Check your GLIB/GDK/GTK installation for thread support.\n");
     }
#endif
   
   gtk_init(&argc, &argv);
   
   if (argv[0][0] != '/')
     {
	getcwd(cwd, 1024);
	strcat(cwd, "/");
	strcat(cwd, argv[0]);
     }
   else
     strcpy(cwd, argv[0]);
   while(cwd[strlen(cwd)-1] != '/') cwd[strlen(cwd)-1] = '\0';
   
   // création de la fenêtre
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
   gtk_widget_show(window);
   
   // création du bouton Load rom
   load_button = gtk_button_new_with_label("Load rom...");   
   gtk_widget_show(load_button);
   
   // création du logo
   style = gtk_widget_get_style(window);
   pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask,
					 &style->bg[GTK_STATE_NORMAL],
					 (gchar **)logo_xpm);
   pixmapwid = gtk_pixmap_new(pixmap, mask);
   gtk_widget_show(pixmapwid);
   
   // création de la selection du mode d'émulation
   label_core = gtk_frame_new("cpu core : ");
   gtk_widget_show(label_core);
   interp = gtk_radio_button_new_with_label(NULL, "interpreter");
   gtk_widget_show(interp);
   dynam = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(interp)),
					   "dynamic compiler");
   gtk_widget_show(dynam);
   pure_interp = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(interp)), 
						 "pure interpreter");
   gtk_widget_show(pure_interp);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dynam), TRUE);
   
   // création de l'option 'debugger'
#ifdef DBG
   button_debug = gtk_check_button_new_with_label("debugger mode");
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_debug), FALSE);
   gtk_widget_show(button_debug);
#endif
   
   // recherche des plugins
   plugin_scan_directory(cwd);
   while(plugin_type() != -1)
     switch (plugin_type())
       {
	case PLUGIN_TYPE_GFX:
	  glist_gfx = g_list_append(glist_gfx, plugin_next());
	  break;
	case PLUGIN_TYPE_AUDIO:
	  glist_audio = g_list_append(glist_audio, plugin_next());
	  break;
	case PLUGIN_TYPE_CONTROLLER:
	  glist_input = g_list_append(glist_input, plugin_next());
	  break;
	case PLUGIN_TYPE_RSP:
	  glist_RSP = g_list_append(glist_RSP, plugin_next());
	  break;
       }
   
   label_gfx = gtk_frame_new("gfx plugin : ");
   gtk_widget_show(label_gfx);
   combo_gfx = gtk_combo_new();
   gtk_combo_set_popdown_strings(GTK_COMBO(combo_gfx), glist_gfx);
   gtk_combo_set_value_in_list(GTK_COMBO(combo_gfx), TRUE, FALSE);
   gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_gfx)->entry), FALSE);
   gtk_widget_show(combo_gfx);
   config_gfx_button = gtk_button_new_with_label("Config");
   gtk_widget_show(config_gfx_button);
   test_gfx_button = gtk_button_new_with_label("Test");
   gtk_widget_show(test_gfx_button);
   about_gfx_button = gtk_button_new_with_label("About");
   gtk_widget_show(about_gfx_button);
   
   label_audio = gtk_frame_new("audio plugin : ");
   gtk_widget_show(label_audio);
   combo_audio = gtk_combo_new();
   gtk_combo_set_popdown_strings(GTK_COMBO(combo_audio), glist_audio);
   gtk_combo_set_value_in_list(GTK_COMBO(combo_audio), TRUE, FALSE);
   gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_audio)->entry), FALSE);
   gtk_widget_show(combo_audio);
   config_audio_button = gtk_button_new_with_label("Config");
   gtk_widget_show(config_audio_button);
   test_audio_button = gtk_button_new_with_label("Test");
   gtk_widget_show(test_audio_button);
   about_audio_button = gtk_button_new_with_label("About");
   gtk_widget_show(about_audio_button);
   
   label_input = gtk_frame_new("input plugin : ");
   gtk_widget_show(label_input);
   combo_input = gtk_combo_new();
   gtk_combo_set_popdown_strings(GTK_COMBO(combo_input), glist_input);
   gtk_combo_set_value_in_list(GTK_COMBO(combo_input), TRUE, FALSE);
   gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_input)->entry), FALSE);
   gtk_widget_show(combo_input);
   config_input_button = gtk_button_new_with_label("Config");
   gtk_widget_show(config_input_button);
   test_input_button = gtk_button_new_with_label("Test");
   gtk_widget_show(test_input_button);
   about_input_button = gtk_button_new_with_label("About");
   gtk_widget_show(about_input_button);
   
   label_RSP = gtk_frame_new("RSP plugin : ");
   gtk_widget_show(label_RSP);
   combo_RSP = gtk_combo_new();
   gtk_combo_set_popdown_strings(GTK_COMBO(combo_RSP), glist_RSP);
   gtk_combo_set_value_in_list(GTK_COMBO(combo_RSP), TRUE, FALSE);
   gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_RSP)->entry), FALSE);
   gtk_widget_show(combo_RSP);
   config_RSP_button = gtk_button_new_with_label("Config");
   gtk_widget_show(config_RSP_button);
   test_RSP_button = gtk_button_new_with_label("Test");
   gtk_widget_show(test_RSP_button);
   about_RSP_button = gtk_button_new_with_label("About");
   gtk_widget_show(about_RSP_button);
   
   // mise en place des évenements
   gtk_signal_connect(GTK_OBJECT(window), "delete_event",
		      GTK_SIGNAL_FUNC(delete_event), NULL);
   gtk_signal_connect(GTK_OBJECT(window), "destroy",
		      GTK_SIGNAL_FUNC(destroy), NULL);
   gtk_signal_connect(GTK_OBJECT(load_button), "clicked",
		      GTK_SIGNAL_FUNC(load), NULL);
   gtk_signal_connect(GTK_OBJECT(config_gfx_button), "clicked",
		      GTK_SIGNAL_FUNC(config_gfx), NULL);
   gtk_signal_connect(GTK_OBJECT(test_gfx_button), "clicked",
		      GTK_SIGNAL_FUNC(test_gfx), NULL);
   gtk_signal_connect(GTK_OBJECT(about_gfx_button), "clicked",
		      GTK_SIGNAL_FUNC(about_gfx), NULL);
   gtk_signal_connect(GTK_OBJECT(config_audio_button), "clicked",
		      GTK_SIGNAL_FUNC(config_audio), NULL);
   gtk_signal_connect(GTK_OBJECT(test_audio_button), "clicked",
		      GTK_SIGNAL_FUNC(test_audio), NULL);
   gtk_signal_connect(GTK_OBJECT(about_audio_button), "clicked",
		      GTK_SIGNAL_FUNC(about_audio), NULL);
   gtk_signal_connect(GTK_OBJECT(config_input_button), "clicked",
		      GTK_SIGNAL_FUNC(config_input), NULL);
   gtk_signal_connect(GTK_OBJECT(test_input_button), "clicked",
		      GTK_SIGNAL_FUNC(test_input), NULL);
   gtk_signal_connect(GTK_OBJECT(about_input_button), "clicked",
		      GTK_SIGNAL_FUNC(about_input), NULL);
   gtk_signal_connect(GTK_OBJECT(config_RSP_button), "clicked",
		      GTK_SIGNAL_FUNC(config_RSP), NULL);
   gtk_signal_connect(GTK_OBJECT(test_RSP_button), "clicked",
		      GTK_SIGNAL_FUNC(test_RSP), NULL);
   gtk_signal_connect(GTK_OBJECT(about_RSP_button), "clicked",
		      GTK_SIGNAL_FUNC(about_RSP), NULL);
   
   // mise en page
   table = gtk_table_new(55, 30, TRUE);
   gtk_widget_show(table);
   
   gtk_container_add(GTK_CONTAINER(window), table);
   gtk_table_attach_defaults(GTK_TABLE(table), load_button, 0, 10, 0, 3);
   gtk_table_attach_defaults(GTK_TABLE(table), label_core, 0, 10, 5, 15);
   gtk_table_attach_defaults(GTK_TABLE(table), pixmapwid, 10, 30, 0, 10);
   gtk_table_attach_defaults(GTK_TABLE(table), interp, 1, 10, 6, 9);
   gtk_table_attach_defaults(GTK_TABLE(table), dynam, 1, 10, 9, 12);
   gtk_table_attach_defaults(GTK_TABLE(table), pure_interp, 1, 10, 12, 15);
   
#ifdef DBG
   gtk_table_attach_defaults(GTK_TABLE(table), button_debug, 15, 25, 12, 15);
#endif
   
   gtk_table_attach_defaults(GTK_TABLE(table), label_gfx, 0, 30, 15, 25);
   gtk_table_attach_defaults(GTK_TABLE(table), combo_gfx, 1, 29, 17, 22);
   gtk_table_attach_defaults(GTK_TABLE(table), config_gfx_button, 1, 10, 22, 24);
   gtk_table_attach_defaults(GTK_TABLE(table), test_gfx_button, 10, 20, 22, 24);
   gtk_table_attach_defaults(GTK_TABLE(table), about_gfx_button, 20, 29, 22, 24);
   
   gtk_table_attach_defaults(GTK_TABLE(table), label_audio, 0, 30, 25, 35);
   gtk_table_attach_defaults(GTK_TABLE(table), combo_audio, 1, 29, 27, 32);
   gtk_table_attach_defaults(GTK_TABLE(table), config_audio_button, 1, 10, 32, 34);
   gtk_table_attach_defaults(GTK_TABLE(table), test_audio_button, 10, 20, 32, 34);
   gtk_table_attach_defaults(GTK_TABLE(table), about_audio_button, 20, 29, 32, 34);
   
   gtk_table_attach_defaults(GTK_TABLE(table), label_input, 0, 30, 35, 45);
   gtk_table_attach_defaults(GTK_TABLE(table), combo_input, 1, 29, 37, 42);
   gtk_table_attach_defaults(GTK_TABLE(table), config_input_button, 1, 10, 42, 44);
   gtk_table_attach_defaults(GTK_TABLE(table), test_input_button, 10, 20, 42, 44);
   gtk_table_attach_defaults(GTK_TABLE(table), about_input_button, 20, 29, 42, 44);
   
   gtk_table_attach_defaults(GTK_TABLE(table), label_RSP, 0, 30, 45, 55);
   gtk_table_attach_defaults(GTK_TABLE(table), combo_RSP, 1, 29, 47, 52);
   gtk_table_attach_defaults(GTK_TABLE(table), config_RSP_button, 1, 10, 52, 54);
   gtk_table_attach_defaults(GTK_TABLE(table), test_RSP_button, 10, 20, 52, 54);
   gtk_table_attach_defaults(GTK_TABLE(table), about_RSP_button, 20, 29, 52, 54);
   
   gtk_main();
   
   return 0;
}