Skip to content

Commit

Permalink
GUI: added Help/Cmdline help/Homepage/Check news commands
Browse files Browse the repository at this point in the history
git-svn-id: https://freearc.svn.sourceforge.net/svnroot/freearc@77 3a4f7f31-9599-433d-91b1-573e8b61252c
  • Loading branch information
bulatz committed Feb 14, 2009
1 parent 7266c45 commit b96e4da
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Compression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ finishCRC = xor aINIT_CRC
-- |Ïîñ÷èòàòü CRC äàííûõ â áóôåðå
calcCRC addr len = updateCRC addr len aINIT_CRC >>== finishCRC

-- |Ïîñ÷èòàòü CRC íå-unicode ñòðîêè (ñèìâîëû ñ êîäàìè 0..255)
crc32 str = unsafePerformIO$ withCStringLen str (uncurry calcCRC)

-- |Fast C routine for CRC-32 calculation
foreign import ccall safe "Environment.h UpdateCRC"
c_UpdateCRC :: Ptr CChar -> CUInt -> CRC -> IO CRC
Expand Down
7 changes: 6 additions & 1 deletion FileManPanel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ fmSetFilelist fm' files = do
-- |Âûâåñòè ñîîáùåíèå îá îøèáêå
fmErrorMsg fm' msg = do
fm <- val fm'
msgBox (fm_window fm) MessageError =<< i18n msg
msgBox (fm_window fm) MessageError msg

-- |Âûâåñòè èíôîðìàöèîííîå ñîîáùåíèå
fmInfoMsg fm' msg = do
fm <- val fm'
msgBox (fm_window fm) MessageInfo msg


----------------------------------------------------------------------------------------------------
Expand Down
64 changes: 61 additions & 3 deletions FileManager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Data.Char
import Data.IORef
import Data.List
import Data.Maybe
import Numeric hiding (readInt)
import System.IO.Unsafe
import System.Cmd
import System.Process
Expand Down Expand Up @@ -86,6 +87,10 @@ uiDef =
" <menuitem name=\"ClearLog\" action=\"ClearLogAction\" />"++
" </menu>"++
" <menu name=\"Help\" action=\"HelpAction\">"++
" <menuitem name=\"MainHelp\" action=\"MainHelpAction\" />"++
" <menuitem name=\"CmdlineHelp\" action=\"CmdlineHelpAction\" />"++
" <menuitem name=\"GotoHomepage\" action=\"GotoHomepageAction\" />"++
" <menuitem name=\"CheckForUpdate\" action=\"CheckForUpdateAction\" />"++
" <menuitem name=\"About\" action=\"AboutAction\" />"++
" </menu>"++
" </menubar>"++
Expand Down Expand Up @@ -148,11 +153,16 @@ myGUI run args = do
toSfxAct <- anew "9999 Convert to SFX" "9999 Convert archive to EXE" (Nothing) "<Alt>S"
encryptAct <- anew "9999 Encrypt" "9999 Encrypt archive contents" (Nothing) ""
addRrAct <- anew "9999 Protect" "9999 Add Recovery record to archive" (Nothing) "<Alt>P"
aboutAct <- anew "9999 About" "9999 About" (Nothing) ""
viewLogAct <- anew "9999 View log" "9999 Open logfile" (Nothing) ""
clearLogAct <- anew "9999 Clear log" "9999 Delete logfile" (Nothing) ""
openAct <- anew "9999 Open archive" "9999 Open archive" (Nothing) "<Alt>O"

helpAct <- anew "9999 Main help" "9999 Help on using FreeArc" (Nothing) "F1"
helpCmdAct <- anew "9999 Cmdline help" "9999 Help on FreeArc command line" (Nothing) ""
homepageAct <- anew "9999 Goto Homepage" "9999 Open program site" (Nothing) ""
whatsnewAct <- anew "9999 Check for update" "9999 Check for new program versions" (Nothing) ""
aboutAct <- anew "9999 About" "9999 About" (Nothing) ""

selectAllAct<- anew "9999 Select all" "9999 Select all files" (Nothing) "<Ctrl>A"
selectAct <- anew "0037 Select" "0047 Select files" (Just stockAdd) "KP_Add"
unselectAct <- anew "0038 Unselect" "0048 Unselect files" (Just stockRemove) "KP_Subtract"
Expand Down Expand Up @@ -385,19 +395,67 @@ myGUI run args = do
settingsAct `onActionActivate` do
settingsDialog fm'


-- Îòêðûòü URL
let openWebsite url = runFile url "." False

-- Îòêðûòü ôàéë ïîìîùè
let openHelp helpfile = do
exe <- getExeName
doc <- i18n helpfile
openWebsite (takeDirectory exe </> "../Documentation" </> doc)

-- Ïîìîùü ïî èñïîëüçîâàíèþ GUI
helpAct `onActionActivate` do
openHelp "0256 FreeArc-GUI-Eng.htm"

-- Ïîìîùü ïî èñïîëüçîâàíèþ êîìàíäíîé ñòðîêè
helpCmdAct `onActionActivate` do
openHelp "0257 FreeArc036-eng.htm"

-- Homepage/news page for the current locale
homeURL <- (aARC_WEBSITE ++) ==<< i18n"0254 /"
newsURL <- (aARC_WEBSITE ++) ==<< i18n"0255 /News.aspx"

-- Äîìàøíÿÿ ñòðàíèöà ïðîãðàììû
homepageAct `onActionActivate` do
openWebsite homeURL

-- Ïðîâåðêà îáíîâëåíèé íà ñàéòå
whatsnewAct `onActionActivate` do
handleErrors
-- Âûïîëíÿåòñÿ ïðè íåäîñòóïíîñòè URL íîâîñòåé
(do msg <- i18n"9999 Cannot open %1. Do you want to check URL manually?"
whenM (askOkCancel window (format msg newsURL)) $ do
openWebsite newsURL)
-- Ïîïûòêà ïðî÷èòàòü URL íîâîñòåé
(fileGetBinary newsURL >>== (`showHex` "").crc32) $ \new_crc -> do
old_crc <- fmGetHistory1 fm' "news_crc" ""
if (new_crc == old_crc) then do
fmInfoMsg fm' "9999 There are no news on the site."
else do
fmReplaceHistory fm' "news_crc" new_crc
whenM (askOkCancel window "9999 There are news. Open website?") $ do
openWebsite newsURL

-- Äèàëîã About
aboutAct `onActionActivate` do
bracketCtrlBreak aboutDialogNew widgetDestroy $ \dialog -> do
dialog `set` [aboutDialogName := aARC_NAME
dialog `set` [windowTransientFor := window
,aboutDialogName := aARC_NAME
,aboutDialogVersion := aARC_VERSION
,aboutDialogCopyright := "(c) "++aARC_EMAIL
,aboutDialogComments := "High-performance archiver"
,aboutDialogWebsite := aARC_WEBSITE
,aboutDialogWebsite := homeURL
-- ,aboutDialogAuthors := [aARC_EMAIL]
]
dialogRun dialog
return ()

-- Âêëþ÷èòü ïîääåðæêó URL â äèàëîãå About
aboutDialogSetUrlHook openWebsite


-- Ïðè íàæàòèè çàãîëîâêà ñòîëáöà â ñïèñêå ôàéëîâ - ñîðòèðîâàòü ïî ýòîìó ñòîëáöó
-- (ïðè ïîâòîðíîì íàæàòèè - ñîðòèðîâàòü â îáðàòíîì ïîðÿäêå)
onColumnTitleClicked =: \column -> do
Expand Down
7 changes: 7 additions & 0 deletions Installer/arc.languages/arc.russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Language name in english and mother tongue
0000 Language=Russian (Русский)
0159 Copyright=Bulat Ziganshin

URLs and helpfiles
0254 Homepage=/ru
0255 News page=/ru/News.aspx
0256 Helpfile=FreeArc-GUI-Rus.htm
0257 Command-line help=FreeArc040-rus.htm


=== Menu ========================================================================
Main menu
0050 File=Файл
Expand Down
2 changes: 1 addition & 1 deletion Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ aARCHIVE_VERSION = make4byte 0 0 4 9
-- |Краткое наименование программы, выводимое в начале работы
aARC_HEADER = aARC_NAME++" "++aARC_VERSION++" "
aARC_VERSION = "0.50 alpha ("++aARC_DATE++")"
aARC_DATE = "Feb 8 2009"
aARC_DATE = "Feb 14 2009"
aARC_NAME = "FreeArc"
aARC_AUTHOR = "Bulat Ziganshin"
aARC_EMAIL = "Bulat.Ziganshin@gmail.com"
Expand Down
7 changes: 7 additions & 0 deletions Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ on = flip (&&&)
-- |Óäîáíûé ñïîñîá çàïèñàòü ñíà÷àëà òî, ÷òî äîëæíî îáÿçàòåëüíî áûòü âûïîëíåíî â êîíöå :)
doFinally = flip finally

-- |Âûïîëíèòü onError ïðè îøèáêå â acquire, è action â ïðîòèâíîì ñëó÷àå
handleErrors onError acquire action = do
x <- try acquire
case x of
Left err -> onError
Right res -> action res

-- |Çàïèñàòü â íà÷àëå òî, ÷òî íóæíî âûïîëíèòü â êîíöå
atExit a b = (b>>a)

Expand Down

0 comments on commit b96e4da

Please sign in to comment.