示例#1
0
void CUpdateDialog::OnInstall(wxCommandEvent&)
{
	wxString f = updater_.DownloadedFile();
	if( f.empty() ) {
		return;
	}
#ifdef __WXMSW__
	wxExecute(_T("\"") + f +  _T("\" /update"));
	wxWindow* p = parent_;
	while( p->GetParent() ) {
		p = p->GetParent();
	}
	p->Close();
#else
	bool program_exists = false;
	wxString cmd = GetSystemOpenCommand(f, program_exists);
	if( program_exists && !cmd.empty() ) {
		if (wxExecute(cmd))
			return;
	}

	wxFileName fn(f);
	OpenInFileManager(fn.GetPath());
#endif
}
示例#2
0
void CLocalListView::OnMenuOpen(wxCommandEvent& event)
{
	long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	if (item == -1) {
		OpenInFileManager(m_dir);
		return;
	}

	std::list<CLocalFileData> selected_item_list;

	item = -1;
	while ((item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1)
	{
		if (!item && m_hasParent)
		{
			wxBell();
			return;
		}

		const CLocalFileData *data = GetData(item);
		if (!data)
			continue;

		if (data->flags == fill)
			continue;

		selected_item_list.push_back(*data);
	}

	CEditHandler* pEditHandler = CEditHandler::Get();
	if (!pEditHandler)
	{
		wxBell();
		return;
	}

	if (selected_item_list.empty())
	{
		wxBell();
		return;
	}

	if (selected_item_list.size() > 10)
	{

		CConditionalDialog dlg(this, CConditionalDialog::many_selected_for_edit, CConditionalDialog::yesno);
		dlg.SetTitle(_("Confirmation needed"));
		dlg.AddText(_("You have selected more than 10 files or directories to open, do you really want to continue?"));

		if (!dlg.Run())
			return;
	}

	for (std::list<CLocalFileData>::const_iterator data = selected_item_list.begin(); data != selected_item_list.end(); ++data)
	{
		if (data->dir)
		{
			CLocalPath path(m_dir);
			if (!path.ChangePath(data->name)) {
				wxBell();
				continue;
			}

			OpenInFileManager(path.GetPath());
			continue;
		}

		wxFileName fn(m_dir, data->name);

		bool program_exists = false;
		wxString cmd = GetSystemOpenCommand(fn.GetFullPath(), program_exists);
		if (cmd == _T(""))
		{
			int pos = data->name.Find('.') == -1;
			if (pos == -1 || (pos == 0 && data->name.Mid(1).Find('.') == -1))
				cmd = pEditHandler->GetOpenCommand(fn.GetFullPath(), program_exists);
		}
		if (cmd == _T(""))
		{
			wxMessageBoxEx(wxString::Format(_("The file '%s' could not be opened:\nNo program has been associated on your system with this file type."), fn.GetFullPath().c_str()), _("Opening failed"), wxICON_EXCLAMATION);
			continue;
		}
		if (!program_exists)
		{
			wxString msg = wxString::Format(_("The file '%s' cannot be opened:\nThe associated program (%s) could not be found.\nPlease check your filetype associations."), fn.GetFullPath().c_str(), cmd.c_str());
			wxMessageBoxEx(msg, _("Cannot edit file"), wxICON_EXCLAMATION);
			continue;
		}

		if (wxExecute(cmd))
			continue;

		wxMessageBoxEx(wxString::Format(_("The file '%s' could not be opened:\nThe associated command failed"), fn.GetFullPath().c_str()), _("Opening failed"), wxICON_EXCLAMATION);
	}
}