Exemple #1
0
////////////////////////////////////////////////////////
//// private functions to interface with the system ////
////////////////////////////////////////////////////////
void TorrentWrapper::HandleCompleted()
{
	int num_completed = 0;
	{
	ScopedLocker<TorrenthandleInfoMap> l_torrent_table(m_handleInfo_map);
	const TorrenthandleInfoMap& infomap = l_torrent_table.Get();

	TorrenthandleInfoMap::const_iterator it = infomap.begin();
	for ( ; it != infomap.end(); ++it )
	{
		PlasmaResourceInfo info = it->first;
		libtorrent::torrent_handle handle = it->second;
		if ( handle.is_valid() && handle.is_seed() )
		{
			wxString dest_filename = sett().GetCurrentUsedDataDir() +
									 getDataSubdirForType( convertMediaType( info.m_type ) ) +
									 wxFileName::GetPathSeparator() +
									 TowxString( handle.get_torrent_info().file_at( 0 ).path.string() );
			if ( !wxFileExists( dest_filename ) )
			{
				wxString source_path = TowxString( handle.save_path().string() )  +
									   wxFileName::GetPathSeparator() +
									   TowxString( handle.get_torrent_info().file_at( 0 ).path.string() );
				wxString dest_path = wxPathOnly( dest_filename );
				if ( !wxDirExists( dest_path ) )
						wxMkdir( dest_path );
				bool ok = wxCopyFile( source_path, dest_filename );
				if ( !ok )
				{
					wxString msg = wxString::Format( _("File copy from %s to %s failed.\nPlease copy manually and reload maps/mods afterwards"),
								source_path.c_str(), dest_filename.c_str() );
					wxLogError( _T("DL: File copy from %s to %s failed."), source_path.c_str(), dest_filename.c_str() );
					#ifdef __WXMSW__
						UiEvents::StatusData data( msg, 1 );
						UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent( data );
					#else
						customMessageBoxNoModal( SL_MAIN_ICON, msg, _("Copy failed") );
					#endif
					//this basically invalidates the handle for further use
					m_torr->remove_torrent( handle );
				}
				else
				{
					wxRemoveFile( source_path );
					wxLogDebug( _T("DL complete: %s"), info.m_name.c_str() );
					UiEvents::StatusData data( wxString::Format( _("Download completed: %s"), info.m_name.c_str() ), 1 );
					UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent( data );
					num_completed++;
				}
			}
		}
	}
	}
	if ( num_completed > 0 )
	{
		usync().AddReloadEvent();
	}
}
bool NetDebugReport::Process()
{
    wxDebugReportCompress::Process(); //compress files into zip
    wxString filename = GetCompressedFileName();
    CwdGuard setCwd( wxPathOnly( filename ) );
	wxLogMessage( filename );
	wxStringOutputStream response;
	wxStringOutputStream rheader;
	CURL *curl_handle;
	curl_handle = curl_easy_init();
	struct curl_slist* m_pHeaders = NULL;
	struct curl_httppost*   m_pPostHead = NULL;
	struct curl_httppost*   m_pPostTail = NULL;
	struct curl_forms testform[2];

	// these header lines will overwrite/add to cURL defaults
	m_pHeaders = curl_slist_append(m_pHeaders, "Expect:") ;

	testform[0].option = CURLFORM_FILE;
	//we need to keep these buffers around for curl op duration
	wxCharBuffer filename_buffer = filename.mb_str();
	testform[0].value = (const char*)filename_buffer;
	testform[1].option = CURLFORM_END;
	curl_formadd(&m_pPostHead, &m_pPostTail, CURLFORM_COPYNAME,
						   "file",
						   CURLFORM_ARRAY, testform, CURLFORM_END);
	curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, m_pHeaders);
	curl_easy_setopt(curl_handle, CURLOPT_URL, m_url );
//	curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
	curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "SpringLobby");
	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, wxcurl_stream_write);
	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&response);
	curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *)&rheader);
	curl_easy_setopt(curl_handle, CURLOPT_POST, TRUE);
	curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, m_pPostHead);

	CURLcode ret = curl_easy_perform(curl_handle);

	wxLogError( rheader.GetString()  );

  /* cleanup curl stuff */
	curl_easy_cleanup(curl_handle);
	curl_formfree(m_pPostHead);

	wxString szResponse;
	if(ret == CURLE_OK)
		szResponse = wxT("SUCCESS!\n\n");
	else
		szResponse = wxT("FAILURE!\n\n");
	szResponse += wxFormat(wxT("\nResponse Code: %d\n\n") ) % ret;
	szResponse += rheader.GetString();
	szResponse += wxT("\n\n");
	szResponse += response.GetString();
	szResponse += wxT("\n\n");
	wxLogMessage( szResponse );

	return ret == CURLE_OK;
}
Exemple #3
0
bool Springsettings::OnInit()
{
	wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") );
    //this triggers the Cli Parser amongst other stuff
    if (!wxApp::OnInit())
        return false;

	SetAppName(_T("SpringSettings"));

	if ( !wxDirExists( GetConfigfileDir() ) )
		wxMkdir( GetConfigfileDir() );

	if (!m_crash_handle_disable) {
	#if wxUSE_ON_FATAL_EXCEPTION
		wxHandleFatalExceptions( true );
	#endif
	#if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT)
		//this undocumented function acts as a workaround for the dysfunctional
		// wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler )
		SetUnhandledExceptionFilter(filter);
	#endif
	}

    //initialize all loggers
	//TODO non-constant parameters
	wxLogChain* logchain  = 0;
	wxLogWindow* loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain );
	//this needs to called _before_ mainwindow instance is created

#ifdef __WXMSW__
	wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale");
#else
	#if defined(LOCALE_INSTALL_DIR)
		wxString path ( _T(LOCALE_INSTALL_DIR) );
	#else
		// use a dummy name here, we're only interested in the base path
		wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages);
		path = path.Left( path.First(_T("noneWH") ) );
	#endif
#endif
	m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path );
	m_translationhelper->Load();

    SetSettingsStandAlone( true );

	//unitsync first load, NEEDS to be blocking
	LSL::usync().ReloadUnitSyncLib();

	settings_frame* frame = new settings_frame(NULL,GetAppName());
    SetTopWindow(frame);
    frame->Show();

    if ( loggerwin ) { // we got a logwindow, lets set proper parent win
        loggerwin->GetFrame()->SetParent( frame );
    }

    return true;
}
void SpringOptionsTab::OnBrowseSync(wxCommandEvent& /*unused*/)
{
	wxFileDialog pick(this, _("Choose UnitSync library"),
			  wxPathOnly(TowxString(SlPaths::GetUnitSync())),
			  wxFileName::FileName(TowxString(SlPaths::GetUnitSync())).GetFullName(),
			  GetUnitsyncFilter());
	if (pick.ShowModal() == wxID_OK)
		m_sync_edit->SetValue(pick.GetPath());
}
void SpringOptionsTab::OnBrowseExec(wxCommandEvent& /*unused*/)
{
	wxFileDialog pick(this, _("Choose a Spring executable"),
			  wxPathOnly(TowxString(SlPaths::GetSpringBinary())),
			  wxFileName::FileName(TowxString(SlPaths::GetSpringBinary())).GetFullName(),
			  GetSpringFilter());
	if (pick.ShowModal() == wxID_OK)
		m_exec_edit->SetValue(pick.GetPath());
}
void DownloadOptionsPanel::OnNewDirectory(wxCommandEvent&)
{
	wxDirDialog pick(this, _("Choose a directory for downloading"),
			 wxPathOnly(TowxString(SlPaths::GetDownloadDir())), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);

	if (pick.ShowModal() == wxID_OK) {
		m_DownloadDirectoryTextCtrl->SetValue(pick.GetPath());
	}
}
Exemple #7
0
wxString GetMenuHtmlFile(const wxChar*file)
{
#ifdef __WXMSW__
  wxString dataroot(wxPathOnly(wxStandardPaths::Get().GetExecutablePath()));
#else
  const wxChar*dataroot = wxT(PREFIX_DATA);
#endif
  return BuildPath(dataroot, wxT("Menu"), file);
}
void ChooseOutputFile(bool force)
{
    wxChar extensionBuf[10];
    wxChar wildBuf[10];
    wxStrcpy(wildBuf, _T("*."));
    wxString path;
    if (!OutputFile.empty())
        path = wxPathOnly(OutputFile);
    else if (!InputFile.empty())
        path = wxPathOnly(InputFile);

    switch (convertMode)
    {
        case TEX_RTF:
        {
            wxStrcpy(extensionBuf, _T("rtf"));
            wxStrcat(wildBuf, _T("rtf"));
            break;
        }
        case TEX_XLP:
        {
            wxStrcpy(extensionBuf, _T("xlp"));
            wxStrcat(wildBuf, _T("xlp"));
            break;
        }
        case TEX_HTML:
        {
            wxStrcpy(extensionBuf, _T("html"));
            wxStrcat(wildBuf, _T("html"));
            break;
        }
    }
#if wxUSE_FILEDLG
    if (force || OutputFile.empty())
    {
        wxString s = wxFileSelector(_T("Choose output file"), path, wxFileNameFromPath(OutputFile),
                                    extensionBuf, wildBuf);
        if (!s.empty())
            OutputFile = s;
    }
#else
    wxUnusedVar(force);
#endif // wxUSE_FILEDLG
}
Exemple #9
0
const wxFileName wxExViMacros::GetFileName()
{
  return wxFileName(
#ifdef wxExUSE_PORTABLE
      wxPathOnly(wxStandardPaths::Get().GetExecutablePath())
#else
      wxStandardPaths::Get().GetUserDataDir()
#endif
      + wxFileName::GetPathSeparator() + "macros.xml");
}
bool ImageValueEditor::onLeftDClick(const RealPoint&, wxMouseEvent&) {
	String filename = wxFileSelector(_("Open image file"), settings.default_image_dir, _(""), _(""),
		                             _("All images|*.bmp;*.jpg;*.png;*.gif|Windows bitmaps (*.bmp)|*.bmp|JPEG images (*.jpg;*.jpeg)|*.jpg;*.jpeg|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif;*.tiff)|*.tif;*.tiff"),
		                             wxFD_OPEN, wxGetTopLevelParent(&editor()));
	if (!filename.empty()) {
		settings.default_image_dir = wxPathOnly(filename);
		sliceImage(wxImage(filename));
	}
	return true;
}
Exemple #11
0
wxString MakeReducedFileName( const wxString& fullfilename,
                              const wxString& default_path,
                              const wxString& default_ext )
{
    wxString reduced_filename = fullfilename;
    wxString Cwd, ext, path;

    Cwd  = default_path;
    ext  = default_ext;
    path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP;
    reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
    Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

    if( Cwd.Last() != '/' )
        Cwd += UNIX_STRING_DIR_SEP;

    path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

#ifdef __WINDOWS__

    // names are case insensitive under windows
    path.MakeLower();
    Cwd.MakeLower();
    ext.MakeLower();
#endif

    // if the path is "default_path" -> remove it
    wxString root_path = path.Left( Cwd.Length() );

    if( root_path == Cwd )
    {
        reduced_filename.Remove( 0, Cwd.Length() );
    }
    else    // if the path is the current path -> change path to ./
    {
        Cwd = wxGetCwd() + UNIX_STRING_DIR_SEP;
#ifdef __WINDOWS__
        Cwd.MakeLower();
#endif
        Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );

        if( path == Cwd )
        {   // the path is the current path -> path = "./"
            reduced_filename.Remove( 0, Cwd.Length() );
            wxString tmp = wxT( "./" ) + reduced_filename;
            reduced_filename = tmp;
        }
    }

    // remove extension if == default_ext:
    if( !ext.IsEmpty() && reduced_filename.Contains( ext ) )
        reduced_filename.Truncate( reduced_filename.Length() - ext.Length() );

    return reduced_filename;
}
Exemple #12
0
char *WavFileName(void)
{//====================
	static char f_speech[120];
	if(!wxDirExists(wxPathOnly(path_speech)))
	{
		path_speech = wxFileSelector(_T("Speech output file"),
			path_phsource,_T("speech.wav"),_T("*"),_T("*"),wxSAVE);
	}
	strcpy(f_speech,path_speech.mb_str(wxConvLocal));
	return(f_speech);
}
void HtmlExportWindow::onOk(wxCommandEvent&) {
	ExportTemplateP exp = list->getSelection<ExportTemplate>();
	// get filename
	String name = wxFileSelector(_TITLE_("save html"),settings.default_export_dir,_(""),_(""),exp->file_type, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
	if (name.empty()) return;
	settings.default_export_dir = wxPathOnly(name);
	// export
	export_set(set, getSelection(), exp, name);
	// Done
	EndModal(wxID_OK);
}
Exemple #14
0
bool EDA_APP::ReadProjectConfig( const wxString&  local_config_filename,
                                 const wxString&  GroupName,
                                 PARAM_CFG_BASE** List,
                                 bool             Load_Only_if_New )
{
    PARAM_CFG_BASE* pt_cfg;
    wxString        timestamp;

    ReCreatePrjConfig( local_config_filename, GroupName, false );

    m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
    timestamp = m_projectSettings->Read( wxT( "update" ) );

    if( Load_Only_if_New && ( !timestamp.IsEmpty() )
       && (timestamp == m_CurrentOptionFileDateAndTime) )
    {
        return false;
    }

    m_CurrentOptionFileDateAndTime = timestamp;

    if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
    {
        m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
    }
    else
    {
        if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
            m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
        else
            m_CurrentOptionFile = g_Prj_Config_LocalFilename;
    }

    for( ; List != NULL && *List != NULL; List++ )
    {
        pt_cfg = *List;

        if( pt_cfg->m_Group )
            m_projectSettings->SetPath( pt_cfg->m_Group );
        else
            m_projectSettings->SetPath( GroupName );

        if( pt_cfg->m_Setup )
            continue;

        pt_cfg->ReadParam( m_projectSettings );
    }

    delete m_projectSettings;
    m_projectSettings = NULL;

    return true;
}
Exemple #15
0
UpdaterApp::UpdaterApp():
	m_version( _T("-1") ),
	m_updater_window( 0 )
{
	SetAppName( _T("springlobby_updater") );

	const std::string filename = STD_STRING(wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("update.log") ).c_str();
	m_logstream_target = new std::ofstream(filename);
	if ( (!m_logstream_target->good()) || (!m_logstream_target->is_open() )) {
		printf("Error opening %s\n", filename.c_str());
	}
}
const wxString PROJECT::AbsolutePath( const wxString& aFileName ) const
{
    wxFileName fn = aFileName;

    if( !fn.IsAbsolute() )
    {
        wxString pro_dir = wxPathOnly( GetProjectFullName() );
        fn.Normalize( wxPATH_NORM_ALL, pro_dir );
    }

    return fn.GetFullPath();
}
Exemple #17
0
bool MyApp::OnInit()
{
    for (int i = 1; i < argc; i++)
    {
        wxHtmlHelpData data;
        wxPrintf(wxT("Processing %s...\n"), argv[i]);
        data.SetTempDir(wxPathOnly(argv[i]));
        data.AddBook(argv[i]);
    }

    return false;
}
Exemple #18
0
// {{{ wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size)
wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) {
#ifdef BUILTIN_IMAGES
	const Images::Image *img = Images::GetImage(id);
	if (img == NULL) {
		return wxNullBitmap;
	}

	wxMemoryInputStream mis(img->image, img->size);
	wxImage image(mis, wxBITMAP_TYPE_PNG);
#elif __WXMAC__
	wxString path(wxGetCwd());
	path << wxT("/Dubnium.app/Contents/Resources/") << id << wxT(".png");
	if (!wxFileExists(path)) {
		return wxNullBitmap;
	}

	wxImage image(path, wxBITMAP_TYPE_PNG);
#elif DUBNIUM_DEBUG
	wxString path(wxT(__FILE__));
	path = wxPathOnly(path);
	path << wxT("/../../images/") << id << wxT(".png");

	if (!wxFileExists(path)) {
		/* This is a debug message only, since for built-in IDs like
		 * wxART_DELETE this will just fall through to the wxWidgets
		 * default provider and isn't an error. */
		wxLogDebug(wxT("Requested image ID: %s; NOT FOUND as %s"), id.c_str(), path.c_str());
		return wxNullBitmap;
	}

	wxLogDebug(wxT("Requested image ID: %s; found as %s"), id.c_str(), path.c_str());

	wxImage image(path, wxBITMAP_TYPE_PNG);
#else
	wxString path;
	path << wxT(PREFIX) << wxT("/share/dubnium/") << id << wxT(".png");
	if (!wxFileExists(path)) {
		return wxNullBitmap;
	}

	wxImage image(path, wxBITMAP_TYPE_PNG);
#endif

	/* There seems to be a tendency for wxArtProvider to request images of
	 * size (-1, -1), so we need to avoid trying to rescale for them. */
	if (wxSize(image.GetWidth(), image.GetHeight()) != size && size.GetWidth() > 0 && size.GetHeight() > 0) {
		wxLogDebug(wxT("Requested width: %d; height: %d"), size.GetWidth(), size.GetHeight());
		image.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH);
	}

	return wxBitmap(image);
}
Exemple #19
0
void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
{
    flagGettext = cmdline.Found("g");
    flagVerbose = cmdline.Found("v");
    flagCPP = cmdline.Found("c");
    flagPython = cmdline.Found("p");
    flagH = flagCPP && cmdline.Found("e");
    flagValidateOnly = cmdline.Found("validate-only");
    flagValidate = flagValidateOnly || cmdline.Found("validate");

    cmdline.Found("xrc-schema", &parSchemaFile);

    if (!cmdline.Found("o", &parOutput))
    {
        if (flagGettext)
            parOutput = wxEmptyString;
        else
        {
            if (flagCPP)
                parOutput = wxT("resource.cpp");
            else if (flagPython)
                parOutput = wxT("resource.py");
            else
                parOutput = wxT("resource.xrs");
        }
    }
    if (!parOutput.empty())
    {
        wxFileName fn(parOutput);
        fn.Normalize();
        parOutput = fn.GetFullPath();
        parOutputPath = wxPathOnly(parOutput);
    }
    if (!parOutputPath) parOutputPath = wxT(".");

    if (!cmdline.Found("n", &parFuncname))
        parFuncname = wxT("InitXmlResource");

    for (size_t i = 0; i < cmdline.GetParamCount(); i++)
    {
#ifdef __WINDOWS__
        wxString fn=wxFindFirstFile(cmdline.GetParam(i), wxFILE);
        while (!fn.empty())
        {
            parFiles.Add(fn);
            fn=wxFindNextFile();
        }
#else
        parFiles.Add(cmdline.GetParam(i));
#endif
    }
}
void SpringOptionsTab::OnBrowseSync( wxCommandEvent& /*unused*/ )
{
	wxString filefilter = wxString( _( "Library" ) ) << _T( "(*" ) << GetLibExtension() << _T( ")|*" ) + GetLibExtension();
#ifdef __WXMAC__
	filefilter << _T( "|" ) << _( "Library" ) << _T( "(*.dylib)|*.dylib" );
#endif
	filefilter << _T( "|" )  << wxString( _( "Any File" ) ) << _T( " (*.*)|*.*" );
	wxFileDialog pick( this, _( "Choose UnitSync library" ),
	                   wxPathOnly( sett().GetCurrentUsedSpringBinary() ),
	                   _T( "unitsync" ) + GetLibExtension(),
	                   wxString( _( "Library" ) ) + _T( "(*" ) + GetLibExtension() + _T( ")|*" ) + GetLibExtension() + _T( "|" ) + wxString( _( "Any File" ) ) + _T( " (*.*)|*.*" )  );
	if ( pick.ShowModal() == wxID_OK ) m_sync_edit->SetValue( pick.GetPath() );
}
void MyFrame::OnLoadMacros(wxCommandEvent& WXUNUSED(event))
{
    textWindow->Clear();
#if wxUSE_FILEDLG
    wxString s = wxFileSelector(_T("Choose custom macro file"), wxPathOnly(MacroFile), wxFileNameFromPath(MacroFile), _T("ini"), _T("*.ini"));
    if (!s.empty() && wxFileExists(s))
    {
        MacroFile = copystring(s);
        ReadCustomMacros(s);
        ShowCustomMacros();
    }
#endif // wxUSE_FILEDLG
}
Exemple #22
0
wxString wxFindAppPath(const wxString& argv0, const wxString& cwd, const wxString& appVariableName)
{
    wxString str;

    // Try appVariableName
    if (!appVariableName.empty())
    {
        str = wxGetenv(appVariableName);
        if (!str.empty())
            return str;
    }

    if (wxIsAbsolutePath(argv0))
        return wxPathOnly(argv0);
    else
    {
        // Is it a relative path?
        wxString currentDir(cwd);
        if (!wxEndsWithPathSeparator(currentDir))
            currentDir += wxFILE_SEP_PATH;

        str = currentDir + argv0;
        if ( wxFile::Exists(str) )
            return wxPathOnly(str);
    }

    // OK, it's neither an absolute path nor a relative path.
    // Search PATH.

    wxPathList pathList;
    pathList.AddEnvList(wxT("PATH"));
    str = pathList.FindAbsoluteValidPath(argv0);
    if (!str.empty())
        return wxPathOnly(str);

    // Failed
    return wxEmptyString;
}
bool WinEDA_App::OnInit(void)
{
wxString FFileName;

	EDA_Appl = this;
	InitEDA_Appl( wxT("gerbview") );

	if(argc > 1) FFileName = MakeFileName(wxEmptyString, argv[1], g_PhotoFilenameExt);

	ScreenPcb = new PCB_SCREEN(NULL, m_GerberFrame, PCB_FRAME);
	ActiveScreen = ScreenPcb;
	GetSettings();
    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Gerbview is already running, Continue?") ) )
			return false;
    }


	g_DrawBgColor = BLACK;

	m_GerberFrame = new WinEDA_GerberFrame(NULL, this, wxT("GerbView"),
				 wxPoint(0,0), wxSize(600,400) );
	m_GerberFrame->SetTitle(Main_Title);
	ScreenPcb->SetParentFrame(m_GerberFrame);
	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);

	SetTopWindow(m_GerberFrame);
	m_GerberFrame->Show(TRUE);

	m_GerberFrame->m_Pcb = new BOARD(NULL, m_GerberFrame);
	m_GerberFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if( ! FFileName.IsEmpty() )
	{
		wxString path = wxPathOnly(FFileName);
		wxSetWorkingDirectory(path);
		Read_Config();
		if ( wxFileExists(FFileName) )
		{
			wxClientDC dc(m_GerberFrame->DrawPanel);
			m_GerberFrame->DrawPanel->PrepareGraphicContext(&dc);
			m_GerberFrame->LoadOneGerberFile(FFileName, &dc, FALSE);
		}
	}
	else Read_Config();

	return TRUE;
}
Exemple #24
0
void MainWindow::OnExecute(wxCommandEvent& WXUNUSED(event)) {
    wxFileDialog
    openFileDialog(this, _("Open Loglan file"), "", "",
            "log files (*.log)|*.log", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
    if (openFileDialog.ShowModal() == wxID_CANCEL)
        return; // the user changed idea...
    wxFileName executablesDir = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() );
    wxString wxString1 = wxString::Format("%s%s",
            executablesDir.GetFullPath(),
            wxFileName::GetPathSeparators());
    wxString execCommand = wxString::Format("%sloglanint %s", wxString1, openFileDialog.GetPath());
    wxExecute(execCommand, wxEXEC_ASYNC);
    wxLogMessage(execCommand);
}
Exemple #25
0
FB_Config::FB_Config(  )
{
    wxApp * App = wxGetApp();
    EditorPath = wxPathOnly(App->argv[0]);
    
    wxFileInputStream input( EditorPath + "/ide/history.ini" );
    wxFileConfig History(input);
    m_FileHistory = new wxFileHistory;
    m_FileHistory->Load( History );
    
    LoadConfig( EditorPath + "/ide/prefs.ini" );
    LoadFBTheme( EditorPath + "/ide/" + ThemeFile + ".fbt" );
    LoadKWFile( EditorPath + "/ide/" + SyntaxFile );
}
Exemple #26
0
SPECIALURLTYPE TransformUrl(wxString&Url)
{
  SPECIALURLTYPE ut = GetSpecialUrlType(Url);
  const wxString location = Url.Mid(ut & 0x0F);
  const wxString exePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath());

  if (SUT_BIN == ut)
  {
#ifdef __WXMSW__
    Url = BuildPath(exePath, location) + wxT(".exe");
    if (!PathExists(Url))
      Url = BuildPath(exePath, wxT("Bin"), location) + wxT(".exe");
#else
    Url = BuildPath(exePath, location);
#endif
  }
  else if (SUT_DOC == ut)
  {
#ifdef __WXMSW__
    wxString path = BuildPath(exePath, location);
#else
    wxString path = BuildPath(wxT(PREFIX_DOC), location);
#endif
    if ((!CanOpenChm() || !wxFileExists(path)) && 0 == location.CmpNoCase(wxT("NSIS.chm")))
    {
      path = BuildPath(wxPathOnly(path), wxT("Docs"), wxT("Manual.html")); // DOCTYPES=htmlsingle
      if (!wxFileExists(path))
        path = BuildPath(wxPathOnly(path), wxT("Contents.html")); // DOCTYPES=html (Not adding /Docs/ because it has already been appended)
    }
    Url = path;
  }
  else if (SUT_WEB == ut)
  {
    Url = location;
  }
  return ut;
}
bool WinEDA_App::OnInit(void)
{
wxString FFileName;
	EDA_Appl = this;

	g_DebugLevel = 0;	// Debug level */

	InitEDA_Appl( wxT("eeschema") );

    if ( m_Checker && m_Checker->IsAnotherRunning() )
    {
        if ( ! IsOK(NULL, _("Eeschema is already running, Continue?") ) )
			return false;
    }

	if(argc > 1 ) FFileName = argv[1];

	CreateScreens();

	/* init EESCHEMA */
	GetSettings();			// read current setup
	SeedLayers();

	// Create main frame (schematic frame) :
	SchematicFrame = new WinEDA_SchematicFrame(NULL, this,
					 wxT("EESchema"), wxPoint(0,0), wxSize(600,400) );
	ScreenSch->SetParentFrame(SchematicFrame);
	SchematicFrame->Show(TRUE);
	SetTopWindow(SchematicFrame);

	SchematicFrame->Zoom_Automatique(TRUE);

	/* Load file specified in the command line. */
	if( ! FFileName.IsEmpty() )
	{
		ChangeFileNameExt(FFileName, g_SchExtBuffer);
		wxSetWorkingDirectory( wxPathOnly(FFileName) );
		if ( SchematicFrame->LoadOneEEProject(FFileName, FALSE) <= 0 )
			SchematicFrame->DrawPanel->Refresh(TRUE);	// File not found or error
	}

	else
	{
		Read_Config(wxEmptyString, TRUE); // Read config file ici si pas de fichier a charger
		SchematicFrame->DrawPanel->Refresh(TRUE);
	}

	return TRUE;
}
Exemple #28
0
/*static*/ bool git::IsGitRepo(const wxString& project, ICommandExecuter& shellUtils)
{
    wxArrayString Output, Errors;
    const wxString shellCommand = _("git rev-parse --show-toplevel");

    shellUtils.pushd(wxPathOnly(project));
    if(!shellUtils.execute(shellCommand, Output, Errors))
    {
        // TODO: Error dialog
        return false;
    }
    shellUtils.popd();

    return Output.Count() != 0;
}
Exemple #29
0
// -------------------------------------------------------------------------------- //
void GetCoversFromSamePath( const wxString &path, wxArrayString &files, wxArrayString &paths, wxArrayInt &positions )
{
    int Index;
    int Count = files.Count();
    for( Index = 0; Index < Count; Index++ )
    {
        if( wxPathOnly( files[ Index ] ) == path )
        {
            paths.Add( files[ Index ] );
            positions.Add( Index );
        }
        else
            break;
    }
}
// -------------------------------------------------------------------------------- //
bool guMediaRecordCtrl::Start( const guTrack * track )
{
    //guLogDebug( wxT( "guMediaRecordCtrl::Start" ) );
    m_TrackInfo = * track;

    if( m_TrackInfo.m_SongName.IsEmpty() )
        m_TrackInfo.m_SongName = wxT( "Record" );

    m_FileName = GenerateRecordFileName();

    wxFileName::Mkdir( wxPathOnly( m_FileName ), 0770, wxPATH_MKDIR_FULL );

    m_Recording = m_MediaCtrl->EnableRecord( m_FileName, m_Format, m_Quality );

    return m_Recording;
}