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

@ -81,12 +81,14 @@ if env['PLATFORM'] != 'win32' and WhereIs('wx-config') or \
nsis_menu[0].env.ParseConfig('wx-config --cxxflags --libs') nsis_menu[0].env.ParseConfig('wx-config --cxxflags --libs')
# install menu files # install menu files
env.DistributeMenu(html, alias='install-utils') env.DistributeMenu(html, alias='install-utils')
env.DistributeMenu(images, path='images', alias='install-utils') env.DistributeMenu(images, path='images', alias='install-utils')
if env['PLATFORM'] != 'win32':
else: env.DistributeBin(resources);
else:
# no wxWidgets # no wxWidgets
def err(target, source, env): def err(target, source, env):
if env['PLATFORM'] == 'win32': if env['PLATFORM'] == 'win32':

View file

@ -23,12 +23,94 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/html/htmlproc.h> #include <wx/html/htmlproc.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/utils.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;
}
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// Define a new application type, each program should derive a class from wxApp // Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp class MyApp : public wxApp
@ -123,35 +205,39 @@ private:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// main frame // main frame
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef NSISMENU_NOLINKTAGHANDLER
static wxHtmlWindow*g_pHtmlWindow = 0;
#endif
// frame constructor // frame constructor
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) 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, : wxFrame((wxFrame *)NULL, -1, title, pos, size, wxCLOSE_BOX | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION,
wxT("nsis_menu")) 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->SetRelatedFrame(this, wxT("%s")); // Dialog caption comes from the html title element or filename
m_Html->SetBorders(0); m_Html->SetBorders(0);
m_Html->EnableScrolling(false, false); m_Html->EnableScrolling(false, false);
m_Html->SetSize(HTMLW, HTMLH); #ifdef NSISMENU_NOLINKTAGHANDLER
g_pHtmlWindow = m_Html;
// Set font size #endif
wxSize DialogSize(1000, 1000);
// Set font size
wxSize DialogSize(1000, 1000);
DialogSize = this->ConvertDialogToPixels(DialogSize); DialogSize = this->ConvertDialogToPixels(DialogSize);
int fonts[7] = {0, 0, 14000 / (DialogSize.GetWidth()), 19000 / (DialogSize.GetWidth()), 0, 0, 0}; int fonts[7] = {0, 0, 14000 / (DialogSize.GetWidth()), 19000 / (DialogSize.GetWidth()), 0, 0, 0};
m_Html->SetFonts(wxString(), wxString(), fonts); m_Html->SetFonts(wxString(), wxString(), fonts);
wxString exePath = wxStandardPaths::Get().GetExecutablePath(); #ifdef __WXMSW__
wxString path = ::wxPathOnly(exePath); this->SetIcon(wxICON(nsisicon));
m_Html->LoadPage(path + wxT("\\Menu\\index.html")); #else
wxIcon icon(wxT("nsisicon.ico"), wxBITMAP_TYPE_ICO);
this->Centre(wxBOTH); this->SetIcon(icon);
#ifndef __WXGTK__
this->SetIcon(wxICON(nsisicon));
#endif #endif
} m_Html->LoadPage(GetMenuHtmlFile(wxT("index.html")));
this->Centre(wxBOTH);
}
// event handler // event handler
void MyFrame::OnLink(wxHtmlLinkEvent& event) void MyFrame::OnLink(wxHtmlLinkEvent& event)
@ -159,27 +245,27 @@ void MyFrame::OnLink(wxHtmlLinkEvent& event)
const wxMouseEvent *e = event.GetLinkInfo().GetEvent(); const wxMouseEvent *e = event.GetLinkInfo().GetEvent();
if (e == NULL || e->LeftUp()) if (e == NULL || e->LeftUp())
{ {
const wxString href = event.GetLinkInfo().GetHref(); int notinstalled = false;
if (href.Left(3).IsSameAs((const wxChar*) wxT("EX:"), false)) wxString href = event.GetLinkInfo().GetHref(), url = href;
{ SPECIALURLTYPE ut = TransformUrl(url);
wxString url = href.Mid(3); switch(ut)
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
{ {
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(); 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 #pragma hdrstop
#endif #endif
#if wxUSE_HTML && wxUSE_STREAMS #if wxUSE_HTML && wxUSE_STREAMS && !defined(NSISMENU_NOLINKTAGHANDLER)
#ifndef WXPRECOMP #ifndef WXPRECOMP
#endif #endif
@ -24,12 +24,18 @@
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
#include <wx/filefn.h> #include <wx/filefn.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
FORCE_LINK_ME(nslinks) #include <nsis-sconf.h>
class wxHtmlAnchorCell : public wxHtmlCell 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: private:
wxString m_AnchorName; wxString m_AnchorName;
@ -44,45 +50,38 @@ public:
DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell) DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
}; };
TAG_HANDLER_BEGIN(A, "A") TAG_HANDLER_BEGIN(A, "A")
TAG_HANDLER_CONSTR(A) { } TAG_HANDLER_CONSTR(A) { }
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (tag.HasParam( wxT("HREF") )) if (tag.HasParam( wxT("HREF") ))
{ {
wxHtmlLinkInfo oldlnk = m_WParser->GetLink(); wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
wxColour oldclr = m_WParser->GetActualColor(); 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") ); if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
wxColour colour = m_WParser->GetLinkColor(); 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);
wxString url = name.Mid(3); if (ut == SUT_BIN || ut == SUT_DOC)
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); colour = wxColour(0x80, 0x80, 0x80);
path.Append(wxFileName::GetPathSeparators()[0]); linkInfo = wxHtmlLinkInfo(wxT("notinstalled.html"), target);
path.Append(url); }
}
if (!::wxFileExists(path) && !::wxDirExists(path))
{ m_WParser->SetActualColor(colour);
colour = wxColour(0x80, 0x80, 0x80); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(colour));
linkInfo = wxHtmlLinkInfo(wxT("notinstalled.html"), target);
}
}
}
m_WParser->SetActualColor(colour);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(colour));
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
m_WParser->SetLink(linkInfo); m_WParser->SetLink(linkInfo);
@ -95,18 +94,18 @@ TAG_HANDLER_BEGIN(A, "A")
return true; return true;
} }
else return false; else return false;
} }
TAG_HANDLER_END(A) TAG_HANDLER_END(A)
TAGS_MODULE_BEGIN(CustomLinks) TAGS_MODULE_BEGIN(Links)
TAGS_MODULE_ADD(A) TAGS_MODULE_ADD(A)
TAGS_MODULE_END(CustomLinks) TAGS_MODULE_END(Links)
#endif #endif

View file

@ -8,7 +8,7 @@ Released on ???? ?nd, 2016
\S2{} Major Changes \S2{} Major Changes
\b Fixed LogicLib nested ${Select} bug \b Fixed LogicLib nested $\{Select\} bug
\S2{} Minor Changes \S2{} Minor Changes
@ -16,6 +16,8 @@ Released on ???? ?nd, 2016
\b Added LogicLib & operator \b Added LogicLib & operator
\b NSIS Menu POSIX fixes (\W{http://sf.net/p/nsis/bugs/1144}{bug #1144})
\S2{} Translations \S2{} Translations
\b Minor tweaks to Danish.nlf (scootergrisen) (\W{http://sf.net/p/nsis/bugs/1140}{bug #1140}) \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"> <td width="190" valign="top">
<p> <p>
<font size="+1" color="#333333"><b>Compiler</b></font><br> <font size="+1" color="#333333"><b>Compiler</b></font><br>
<a href="EX:makensisw.exe">Compile NSI scripts</a><br> <a href="BIN:makensisw">Compile NSI scripts</a><br>
<a href="EX:Bin\zip2exe.exe">Installer based on ZIP file</a><br> <a href="BIN:zip2exe">Installer based on ZIP file</a><br>
<br> <br>
<br> <br>
<br> <br>
@ -18,39 +18,39 @@
<p> <p>
<font size="+1" color="#333333"><b>Developer Center</b></font><br> <font size="+1" color="#333333"><b>Developer Center</b></font><br>
Many more examples, tutorials, plug-ins and NSIS-related software are available 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> </p>
</td> </td>
<td width="150" valign="top"> <td width="150" valign="top">
<p> <p>
<font size="+1" color="#333333"><b>Documentation</b></font><br> <font size="+1" color="#333333"><b>Documentation</b></font><br>
<a href="EX:NSIS.chm">NSIS Users Manual</a><br> <a href="DOC:NSIS.chm">NSIS Users Manual</a><br>
<a href="EX:Examples">Example scripts</a><br> <a href="DOC:Examples">Example scripts</a><br>
<a href="EX:Docs\Modern UI 2\Readme.html">Modern UI 2</a><br> <a href="DOC: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="DOC: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:Docs/StrFunc/StrFunc.txt">StrFunc Header File</a></p>
<p> <p>
<font size="+1" color="#333333"><b>On-line help</b></font><br> <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="WEB: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="WEB:http://nsis.sourceforge.net/FAQ">FAQ</a><br>
<a href="EX:irc://irc.landoleet.org/nsis">IRC Channel</a><br> <a href="WEB: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://sourceforge.net/tracker/?group_id=22049&atid=373085">Bug Tracker</a><br>
</td> </td>
<td valign="top"> <td valign="top">
<p> <p>
<font size="+1" color="#333333"><b>Plug-ins</b></font><br> <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="DOC: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="DOC: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="DOC:Docs/BgImage/BgImage.txt">BgImage</a> - background image<br>
<a href="EX:Docs\Dialer\Dialer.txt">Dialer</a> - internet connection<br> <a href="DOC:Docs/Dialer/Dialer.txt">Dialer</a> - internet connection<br>
<a href="EX:Docs\Math\Math.txt">Math</a> - math operations<br> <a href="DOC:Docs/Math/Math.txt">Math</a> - math operations<br>
<a href="EX:Docs\nsDialogs\Readme.html">nsDialogs</a> - custom wizard pages<br> <a href="DOC: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="DOC: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="DOC:Docs/NSISdl/ReadMe.txt">NSISdl</a> - download files<br>
<a href="EX:Docs\Splash\splash.txt">Splash</a> - splash screen<br> <a href="DOC: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="DOC: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="DOC: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/VPatch/Readme.html">VPatch</a> - update existing files</p>
</td> </td>
</tr> </tr>
</table> </table>
@ -58,7 +58,7 @@
<img src="images/line.gif" width="598" height="3"> <img src="images/line.gif" width="598" height="3">
</p> </p>
<div align="right"> <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> </div>
</body> </body>
</html> </html>

View file

@ -207,12 +207,13 @@ if defenv['DEBUG']:
defenv.Append(CPPDEFINES = ['DEBUG']) defenv.Append(CPPDEFINES = ['DEBUG'])
# add prefixes defines # add prefixes defines
if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: 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_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))])
defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))]) 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']: # Need this early for the config header files to be placed in
if defenv['UNICODE']:
if defenv['DEBUG']: if defenv['DEBUG']:
defenv.Replace(BUILD_PREFIX = 'build/udebug') defenv.Replace(BUILD_PREFIX = 'build/udebug')
else: else: