NSIS Menu POSIX fixes (bug #1144)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6758 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2016-06-26 13:36:30 +00:00
parent 7fff5828ad
commit e922c1b182
6 changed files with 232 additions and 142 deletions

View file

@ -84,6 +84,8 @@ if env['PLATFORM'] != 'win32' and WhereIs('wx-config') or \
env.DistributeMenu(html, alias='install-utils')
env.DistributeMenu(images, path='images', alias='install-utils')
if env['PLATFORM'] != 'win32':
env.DistributeBin(resources);
else:

View file

@ -26,10 +26,92 @@
#include <wx/stdpaths.h>
#include <wx/utils.h>
#include <nsis-sconf.h>
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
#if !wxCHECK_VERSION(2, 9, 0) && !defined(wxLaunchDefaultApplication)
#define wxLaunchDefaultApplication wxLaunchDefaultBrowser
#endif
#ifdef __WXMSW__
#define CanOpenChm() true
#else
#define CanOpenChm() false
#endif
typedef enum { SUT_UNKNOWN = 0, SUT_BIN = 0x14, SUT_DOC = 0x24, SUT_WEB = 0x34 } SPECIALURLTYPE; // The low nibble contains the "protocol" length!
SPECIALURLTYPE GetSpecialUrlType(const wxString&Url)
{
const wxString l4 = Url.Left(4);
if (0 == l4.CmpNoCase(wxT("BIN:"))) return SUT_BIN;
if (0 == l4.CmpNoCase(wxT("DOC:"))) return SUT_DOC;
if (0 == l4.CmpNoCase(wxT("WEB:"))) return SUT_WEB;
return SUT_UNKNOWN;
}
static bool PathExists(const wxString&Path) { return wxFileExists(Path) || wxDirExists(Path); }
static wxString BuildPathWorker(const wxChar*a, const wxChar*b)
{
wxString path(a);
if (path.Last() != wxFileName::GetPathSeparator()) path.Append(wxFileName::GetPathSeparator());
return (path.Append(b), path);
}
static const wxChar*GetCStr(const wxString&t) { return t.c_str(); }
static const wxChar*GetCStr(const wxChar*t) { return t; }
template<class A, class B> wxString BuildPath(const A&a, const B&b) { return BuildPathWorker(GetCStr(a), GetCStr(b)); }
template<class A, class B, class C> wxString BuildPath(const A&a, const B&b, const C&c) { return BuildPath(BuildPath(GetCStr(a), GetCStr(b)), GetCStr(c)); }
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);
}
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;
}
// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
@ -123,18 +205,22 @@ private:
// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------
#ifdef NSISMENU_NOLINKTAGHANDLER
static wxHtmlWindow*g_pHtmlWindow = 0;
#endif
// frame constructor
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size, wxCLOSE_BOX | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION,
wxT("nsis_menu"))
{
m_Html = new wxHtmlWindow(this, HtmlControl);
m_Html = new wxHtmlWindow(this, HtmlControl, wxPoint(0, 0), wxSize(HTMLW, HTMLH), wxHW_SCROLLBAR_NEVER|wxHW_NO_SELECTION);
m_Html->SetRelatedFrame(this, wxT("%s")); // Dialog caption comes from the html title element or filename
m_Html->SetBorders(0);
m_Html->EnableScrolling(false, false);
m_Html->SetSize(HTMLW, HTMLH);
#ifdef NSISMENU_NOLINKTAGHANDLER
g_pHtmlWindow = m_Html;
#endif
// Set font size
wxSize DialogSize(1000, 1000);
@ -142,14 +228,14 @@ private:
int fonts[7] = {0, 0, 14000 / (DialogSize.GetWidth()), 19000 / (DialogSize.GetWidth()), 0, 0, 0};
m_Html->SetFonts(wxString(), wxString(), fonts);
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
wxString path = ::wxPathOnly(exePath);
m_Html->LoadPage(path + wxT("\\Menu\\index.html"));
this->Centre(wxBOTH);
#ifndef __WXGTK__
#ifdef __WXMSW__
this->SetIcon(wxICON(nsisicon));
#else
wxIcon icon(wxT("nsisicon.ico"), wxBITMAP_TYPE_ICO);
this->SetIcon(icon);
#endif
m_Html->LoadPage(GetMenuHtmlFile(wxT("index.html")));
this->Centre(wxBOTH);
}
// event handler
@ -159,27 +245,27 @@ void MyFrame::OnLink(wxHtmlLinkEvent& event)
const wxMouseEvent *e = event.GetLinkInfo().GetEvent();
if (e == NULL || e->LeftUp())
{
const wxString href = event.GetLinkInfo().GetHref();
if (href.Left(3).IsSameAs((const wxChar*) wxT("EX:"), false))
{
wxString url = href.Mid(3);
if (url.Left(7).IsSameAs((const wxChar*) wxT("http://"), false) || url.Left(6).IsSameAs((const wxChar*) wxT("irc://"), false))
{
::wxLaunchDefaultBrowser(url);
}
else
{
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
wxString path = ::wxPathOnly(exePath);
path.Append(wxFileName::GetPathSeparators()[0]);
path.Append(url);
::wxLaunchDefaultBrowser(path);
}
}
else
int notinstalled = false;
wxString href = event.GetLinkInfo().GetHref(), url = href;
SPECIALURLTYPE ut = TransformUrl(url);
switch(ut)
{
case SUT_BIN:
if (PathExists(url)) wxExecute(url); else ++notinstalled;
break;
case SUT_DOC:
if (PathExists(url)) wxLaunchDefaultApplication(url); else ++notinstalled;
break;
case SUT_WEB:
wxLaunchDefaultBrowser(url);
break;
default:
event.Skip();
}
#ifdef NSISMENU_NOLINKTAGHANDLER
if (notinstalled && g_pHtmlWindow)
g_pHtmlWindow->LoadPage(GetMenuHtmlFile(wxT("notinstalled.html")));
#endif
}
}

View file

@ -16,7 +16,7 @@
#pragma hdrstop
#endif
#if wxUSE_HTML && wxUSE_STREAMS
#if wxUSE_HTML && wxUSE_STREAMS && !defined(NSISMENU_NOLINKTAGHANDLER)
#ifndef WXPRECOMP
#endif
@ -27,8 +27,14 @@
#include <wx/filefn.h>
#include <wx/stdpaths.h>
#include <nsis-sconf.h>
FORCE_LINK_ME(nslinks)
// TODO: These helper function declarations should be in a header file
typedef enum { SUT_UNKNOWN = 0, SUT_BIN = 0x14, SUT_DOC = 0x24, SUT_WEB = 0x34 } SPECIALURLTYPE;
SPECIALURLTYPE TransformUrl(wxString&Url);
class wxHtmlAnchorCell : public wxHtmlCell
{
private:
@ -56,28 +62,21 @@ TAG_HANDLER_BEGIN(A, "A")
{
wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
wxColour oldclr = m_WParser->GetActualColor();
wxString name(tag.GetParam( wxT("HREF") )), target;
wxString href(tag.GetParam( wxT("HREF") )), target;
if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
wxColour colour = m_WParser->GetLinkColor();
wxHtmlLinkInfo linkInfo(name, target);
wxHtmlLinkInfo linkInfo(href, target);
if (name.Left(3).IsSameAs((const wxChar*) wxT("EX:"), false))
wxString location = href;
SPECIALURLTYPE ut = TransformUrl(location);
if (ut == SUT_BIN || ut == SUT_DOC)
{
wxString url = name.Mid(3);
if (!url.Left(7).IsSameAs((const wxChar*) wxT("http://"), false) && !url.Left(6).IsSameAs((const wxChar*) wxT("irc://"), false))
if (!wxFileExists(location) && !wxDirExists(location))
{
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
wxString path = ::wxPathOnly(exePath);
path.Append(wxFileName::GetPathSeparators()[0]);
path.Append(url);
if (!::wxFileExists(path) && !::wxDirExists(path))
{
colour = wxColour(0x80, 0x80, 0x80);
linkInfo = wxHtmlLinkInfo(wxT("notinstalled.html"), target);
}
colour = wxColour(0x80, 0x80, 0x80);
linkInfo = wxHtmlLinkInfo(wxT("notinstalled.html"), target);
}
}
@ -102,11 +101,11 @@ TAG_HANDLER_END(A)
TAGS_MODULE_BEGIN(CustomLinks)
TAGS_MODULE_BEGIN(Links)
TAGS_MODULE_ADD(A)
TAGS_MODULE_END(CustomLinks)
TAGS_MODULE_END(Links)
#endif

View file

@ -8,7 +8,7 @@ Released on ???? ?nd, 2016
\S2{} Major Changes
\b Fixed LogicLib nested ${Select} bug
\b Fixed LogicLib nested $\{Select\} bug
\S2{} Minor Changes
@ -16,6 +16,8 @@ Released on ???? ?nd, 2016
\b Added LogicLib & operator
\b NSIS Menu POSIX fixes (\W{http://sf.net/p/nsis/bugs/1144}{bug #1144})
\S2{} Translations
\b Minor tweaks to Danish.nlf (scootergrisen) (\W{http://sf.net/p/nsis/bugs/1140}{bug #1140})

View file

@ -9,8 +9,8 @@
<td width="190" valign="top">
<p>
<font size="+1" color="#333333"><b>Compiler</b></font><br>
<a href="EX:makensisw.exe">Compile NSI scripts</a><br>
<a href="EX:Bin\zip2exe.exe">Installer based on ZIP file</a><br>
<a href="BIN:makensisw">Compile NSI scripts</a><br>
<a href="BIN:zip2exe">Installer based on ZIP file</a><br>
<br>
<br>
<br>
@ -18,39 +18,39 @@
<p>
<font size="+1" color="#333333"><b>Developer Center</b></font><br>
Many more examples, tutorials, plug-ins and NSIS-related software are available
at the on-line <a href="EX:http://nsis.sourceforge.net/Developer_Center">Developer Center</a>.
at the on-line <a href="WEB:http://nsis.sourceforge.net/Developer_Center">Developer Center</a>.
</p>
</td>
<td width="150" valign="top">
<p>
<font size="+1" color="#333333"><b>Documentation</b></font><br>
<a href="EX:NSIS.chm">NSIS Users Manual</a><br>
<a href="EX:Examples">Example scripts</a><br>
<a href="EX:Docs\Modern UI 2\Readme.html">Modern UI 2</a><br>
<a href="EX:Docs\MultiUser\Readme.html">Multi-User Header File</a><br>
<a href="EX:Docs\StrFunc\StrFunc.txt">StrFunc Header File</a></p>
<a href="DOC:NSIS.chm">NSIS Users Manual</a><br>
<a href="DOC:Examples">Example scripts</a><br>
<a href="DOC:Docs/Modern UI 2/Readme.html">Modern UI 2</a><br>
<a href="DOC:Docs/MultiUser/Readme.html">Multi-User Header File</a><br>
<a href="DOC:Docs/StrFunc/StrFunc.txt">StrFunc Header File</a></p>
<p>
<font size="+1" color="#333333"><b>On-line help</b></font><br>
<a href="EX:http://forums.winamp.com/forumdisplay.php?s=&forumid=65">Forum</a><br>
<a href="EX:http://nsis.sourceforge.net/FAQ">FAQ</a><br>
<a href="EX:irc://irc.landoleet.org/nsis">IRC Channel</a><br>
<a href="EX:http://sourceforge.net/tracker/?group_id=22049&atid=373085">Bug Tracker</a><br>
<a href="WEB:http://forums.winamp.com/forumdisplay.php?s=&forumid=65">Forum</a><br>
<a href="WEB:http://nsis.sourceforge.net/FAQ">FAQ</a><br>
<a href="WEB:irc://irc.landoleet.org/nsis">IRC Channel</a><br>
<a href="WEB:http://sourceforge.net/tracker/?group_id=22049&atid=373085">Bug Tracker</a><br>
</td>
<td valign="top">
<p>
<font size="+1" color="#333333"><b>Plug-ins</b></font><br>
<a href="EX:Docs\AdvSplash\advsplash.txt">AdvSplash</a> - splash with fade in/out<br>
<a href="EX:Docs\Banner\Readme.txt">Banner</a> - banner with custom text<br>
<a href="EX:Docs\BgImage\BgImage.txt">BgImage</a> - background image<br>
<a href="EX:Docs\Dialer\Dialer.txt">Dialer</a> - internet connection<br>
<a href="EX:Docs\Math\Math.txt">Math</a> - math operations<br>
<a href="EX:Docs\nsDialogs\Readme.html">nsDialogs</a> - custom wizard pages<br>
<a href="EX:Docs\nsExec\nsExec.txt">nsExec</a> - launch command line tools<br>
<a href="EX:Docs\NSISdl\Readme.txt">NSISdl</a> - download files<br>
<a href="EX:Docs\Splash\splash.txt">Splash</a> - splash screen<br>
<a href="EX:Docs\StartMenu\Readme.txt">StartMenu</a> - Start Menu folder selection<br>
<a href="EX:Docs\System\System.html">System</a> - Windows API calls<br>
<a href="EX:Docs\VPatch\Readme.html">VPatch</a> - update existing files</p>
<a href="DOC:Docs/AdvSplash/advsplash.txt">AdvSplash</a> - splash with fade in/out<br>
<a href="DOC:Docs/Banner/Readme.txt">Banner</a> - banner with custom text<br>
<a href="DOC:Docs/BgImage/BgImage.txt">BgImage</a> - background image<br>
<a href="DOC:Docs/Dialer/Dialer.txt">Dialer</a> - internet connection<br>
<a href="DOC:Docs/Math/Math.txt">Math</a> - math operations<br>
<a href="DOC:Docs/nsDialogs/Readme.html">nsDialogs</a> - custom wizard pages<br>
<a href="DOC:Docs/nsExec/nsExec.txt">nsExec</a> - launch command line tools<br>
<a href="DOC:Docs/NSISdl/ReadMe.txt">NSISdl</a> - download files<br>
<a href="DOC:Docs/Splash/splash.txt">Splash</a> - splash screen<br>
<a href="DOC:Docs/StartMenu/Readme.txt">StartMenu</a> - Start Menu folder selection<br>
<a href="DOC:Docs/System/System.html">System</a> - Windows API calls<br>
<a href="DOC:Docs/VPatch/Readme.html">VPatch</a> - update existing files</p>
</td>
</tr>
</table>
@ -58,7 +58,7 @@
<img src="images/line.gif" width="598" height="3">
</p>
<div align="right">
<a href="EX:http://nsis.sourceforge.net/"><img src="images/site.gif" width="200" height="25"></a>
<a href="WEB:http://nsis.sourceforge.net/"><img src="images/site.gif" width="200" height="25"></a>
</div>
</body>
</html>

View file

@ -210,6 +210,7 @@ if defenv['DEBUG']:
if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']:
defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))])
defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))])
defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DOC', '"%s"' % defenv.subst('$PREFIX_DOC'))])
# Need this early for the config header files to be placed in
if defenv['UNICODE']: