2013-04-17 21:43:35 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-03-20 13:12:04 -06:00
|
|
|
|
2009-02-24 12:31:32 -07:00
|
|
|
#include "Common.h"
|
2009-03-20 13:12:04 -06:00
|
|
|
|
2009-02-24 12:31:32 -07:00
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/string.h>
|
2009-03-20 13:12:04 -06:00
|
|
|
|
2013-02-27 21:37:38 -07:00
|
|
|
#include "WxUtils.h"
|
|
|
|
|
2009-02-24 12:31:32 -07:00
|
|
|
namespace WxUtils {
|
|
|
|
|
2009-03-20 13:12:04 -06:00
|
|
|
// Launch a file according to its mime type
|
|
|
|
void Launch(const char *filename)
|
|
|
|
{
|
2013-02-27 21:37:38 -07:00
|
|
|
if (! ::wxLaunchDefaultBrowser(StrToWxStr(filename)))
|
2010-01-12 23:34:34 -07:00
|
|
|
{
|
2009-03-20 13:12:04 -06:00
|
|
|
// WARN_LOG
|
2009-02-24 12:31:32 -07:00
|
|
|
}
|
2009-03-20 13:12:04 -06:00
|
|
|
}
|
2009-02-24 12:31:32 -07:00
|
|
|
|
2009-03-20 13:12:04 -06:00
|
|
|
// Launch an file explorer window on a certain path
|
|
|
|
void Explore(const char *path)
|
|
|
|
{
|
2013-02-27 21:37:38 -07:00
|
|
|
wxString wxPath = StrToWxStr(path);
|
2009-03-20 13:12:04 -06:00
|
|
|
// Default to file
|
2010-01-12 23:34:34 -07:00
|
|
|
if (! wxPath.Contains(wxT("://")))
|
|
|
|
{
|
2009-03-20 13:12:04 -06:00
|
|
|
wxPath = wxT("file://") + wxPath;
|
|
|
|
}
|
|
|
|
|
2011-04-17 15:39:58 -06:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
wxPath.Replace(wxT(" "), wxT("\\ "));
|
|
|
|
#endif
|
|
|
|
|
2010-01-12 23:34:34 -07:00
|
|
|
if (! ::wxLaunchDefaultBrowser(wxPath))
|
2009-08-07 02:52:04 -06:00
|
|
|
{
|
2010-01-12 23:34:34 -07:00
|
|
|
// WARN_LOG
|
2009-08-07 02:52:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-20 13:12:04 -06:00
|
|
|
} // namespace
|
2013-02-27 21:37:38 -07:00
|
|
|
|
|
|
|
std::string WxStrToStr(const wxString& str)
|
|
|
|
{
|
2013-02-28 02:11:10 -07:00
|
|
|
return str.ToUTF8().data();
|
2013-02-27 21:37:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString StrToWxStr(const std::string& str)
|
|
|
|
{
|
2013-02-28 02:11:10 -07:00
|
|
|
//return wxString::FromUTF8Unchecked(str.c_str());
|
2013-02-27 21:37:38 -07:00
|
|
|
return wxString::FromUTF8(str.c_str());
|
|
|
|
}
|