diff options
author | Staszek Wawrykiewicz <staw@gust.org.pl> | 2009-09-30 19:40:25 +0000 |
---|---|---|
committer | Staszek Wawrykiewicz <staw@gust.org.pl> | 2009-09-30 19:40:25 +0000 |
commit | 3d3a73217f3dc5f9eda59d6c4a35a86992609693 (patch) | |
tree | 14a1c0c6aaae0105dbd0d7e2e6f8f9bb96c716bc /Master/tlpkg/tlpsv/psv.wx.lua | |
parent | 0ebb67b0754bebe853fd30c35217dbceccb7aa6e (diff) |
ps_view 5.12 update
git-svn-id: svn://tug.org/texlive/trunk@15578 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlpsv/psv.wx.lua')
-rw-r--r-- | Master/tlpkg/tlpsv/psv.wx.lua | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/Master/tlpkg/tlpsv/psv.wx.lua b/Master/tlpkg/tlpsv/psv.wx.lua index 476d11d5a65..85f857030bd 100644 --- a/Master/tlpkg/tlpsv/psv.wx.lua +++ b/Master/tlpkg/tlpsv/psv.wx.lua @@ -3,9 +3,9 @@ -- Authors: P. Strzelczyk, P. Pianowski. Created: 15.06.1993; Lua part 26.10.2007 -- Address: BOP s.c. Gen. T. Bora-Komorowskiego 24, 80-377 Gda\'nsk, Poland -- bop@bop.com.pl --- Copyright: (c) 2008 BOP s.c. +-- Copyright: (c) 2009 BOP s.c. -- Licence: GPL --- Current version: 5.11; 06.07.2009 +-- Current version: 5.12; 07.10.2009 -- -- 4.95 -- first working version of Lua engine -- 4.96 -- mouse interface added (and many other changes) @@ -26,10 +26,11 @@ -- 5.09 -- LaTeX/HTML help added -- 5.10 -- bug in DSC reading corrected -- 5.11 -- some changes to compatibility with GS 8.64, and builtin inits +-- 5.12 -- changes for Windows Vista and wxWidgets 2.8.10, TL2009 release ------------------------------------------------------------------------------]] local PS_VIEW_NAME="PS_View" -local PS_VIEW_VERSION=5.11 +local PS_VIEW_VERSION=5.12 local PS_VIEW_VERSION_STRING -- defined later, after locale loading local PSV_DftGsPars = {"-dNOPAUSE","-dDELAYBIND","-dNOEPS"} @@ -565,8 +566,6 @@ function MakeHelpWindow(l,a) local fname=wx.wxFileName(arg[0]):GetPath(wx.wxPATH_GET_VOLUME) fname=wx.wxFileName(fname,a) gsobj.helpctrl:AddBook(fname,false) --- gsobj.helpctrl=wx.wxHelpController(frame) --- gsobj.helpctrl:Initialize(a) elseif l=="S" then gsobj.helpctrl:DisplayContents() elseif l=="C" then @@ -1573,9 +1572,7 @@ function ClosePSV () if trans then trans:close() end -- for locale text extraction if wx.wxIsBusy() then wx.wxEndBusyCursor() end if gswin.gswindow then gswin.gswindow:Destroy() gswin.gswindow=nil end - if gsobj.instancechecker then gsobj.instancechecker:Destroy() end --- if gsobj.helparch then gsobj.helparch:Destroy() end --- if gsobj.helpctrl then gsobj.helpctrl:Destroy() end + if gsobj.instancechecker then gsobj.instancechecker:Destroy(true) end -- ConfigSavePaths(gsargs) ConfigSaveFramePosition(frame, "MainWindow") if console then @@ -1604,7 +1601,7 @@ function ExitPSV (err_code) gsobj.ghostscript:Terminate(err_code) end if wx.wxIsBusy() then wx.wxEndBusyCursor() end - if gsobj.instancechecker then gsobj.instancechecker:Destroy() end + if gsobj.instancechecker then gsobj.instancechecker:Destroy(true) end if console then console:Show() frame:Hide() console:Connect(wx.wxEVT_CLOSE_WINDOW, function (event) @@ -1620,7 +1617,7 @@ function ExitPSV_init () gsobj.ghostscript:Terminate(gsobj.ghostscript:GetExitCode()) end if wx.wxIsBusy() then wx.wxEndBusyCursor() end - if gsobj.instancechecker then gsobj.instancechecker:Destroy() end + if gsobj.instancechecker then gsobj.instancechecker:Destroy(true) end if console then wxapp:SetTopWindow(console) end if frame then frame:Destroy() end end @@ -1732,10 +1729,12 @@ function PSFName(name) end function SetPSFile(fdir,fname) - gsargs.psf_dir, gsargs.psf_name = fdir,fname - SetPSTitle(fname) - if gsobj.instancechecker then gsobj.instancechecker:Destroy() end - gsobj.instancechecker = CreateInstanceChecker() + if gsargs.psf_dir ~= fdir or gsargs.psf_name ~= fname then + gsargs.psf_dir, gsargs.psf_name = fdir,fname + SetPSTitle(fname) + if gsobj.instancechecker then gsobj.instancechecker:Destroy(false) end + gsobj.instancechecker = CreateInstanceChecker() + end gsobj.instancechecker:IsAnotherInstance() end @@ -2028,15 +2027,22 @@ function CreateInstanceChecker() function checker:CheckTime() local ok,modtime=self.fname:GetTimes() if modtime:IsLaterThan(self.time) then - self.time=modtime return true + if self.fname:GetSize():ToULong()<2 then + -- signal active instance + self:CreateLock() + else self.time=modtime end + return true else return false end end function checker:CreateLock() + self:MakeLock(tostring(wx.wxGetProcessId())) + self:SetTime() self.created=true + end + function checker:MakeLock(cont) local file=wx.wxFile(self.fname:GetFullPath(),wx.wxFile.write) if file:IsOpened() then - file:Write(tostring(wx.wxGetProcessId())) file:Close() + file:Write(cont) file:Close() end - self:SetTime() self.created=true end function checker:UpdateLock() self.fname:Touch() @@ -2047,6 +2053,11 @@ function CreateInstanceChecker() if not self.dname or not self.fname then return false end if not self.dname:DirExists() then self.dname:Mkdir() end if self.fname:FileExists() then + print_debug("SIZE: ", self.fname:GetSize():ToULong()) + if self.fname:GetSize():ToULong()<2 then + -- unactive instance found (= no active instance) + self:CreateLock() return false + end self:UpdateLock() return true else self:CreateLock() return false @@ -2063,7 +2074,7 @@ function CreateInstanceChecker() end end -- - function checker:Destroy() + function checker:Destroy(quit) if not self.dname or not self.fname then return false end if not self.dname:DirExists() then return false end if self.created and self.fname:FileExists() then @@ -2079,7 +2090,7 @@ function CreateInstanceChecker() if mod:IsEarlierThan(old) then wx.wxRemoveFile(fname:GetFullPath()) end f,filen=dir:GetNext() fname:SetFullName(filen) end - if not dir:HasFiles() then wx.wxRmdir(dir:GetName()) end + if quit and not dir:HasFiles() then wx.wxRmdir(dir:GetName()) end self.dname=nil self.fname=nil self.time=nil return true end @@ -2185,9 +2196,10 @@ function Main() end if gsobj.instancechecker:IsAnotherInstance() and not force_open then print_message(_T("Another instance of PS_View is running -- quiting.\n")) + gsobj.instancechecker:MakeLock('0') -- try if instance is dead gsobj.instancechecker:Destroy() return true - elseif force_open then gsobj.instancechecker.created=true end + elseif force_open then gsobj.instancechecker:CreateLock() end ConfigGetPaths(gsargs) |