1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
20 *******************************************************************************/
\r
23 #include "frm_main.h"
\r
24 #include <wx/cmdline.h>
\r
26 //******************************************************************************
\r
28 //******************************************************************************
\r
30 IMPLEMENT_APP(Lychee)
\r
32 bool Lychee::OnInit()
\r
34 wxInitAllImageHandlers();
\r
35 ::wxXmlResource::Get()->InitAllHandlers();
\r
40 wxChar cSep = wxFileName::GetPathSeparator();
\r
41 szCwd = ::wxGetCwd() + cSep;
\r
43 ::wxSetWorkingDirectory(::wxPathOnly(p.GetExecutablePath()) + cSep);
\r
47 this->lc.AddCatalogLookupPathPrefix(L_DIR_S_LOC);
\r
48 this->lc.AddCatalog(wxT("lychee"));
\r
50 MainFrame * frm_main = new MainFrame();
\r
51 if (! ::wxXmlResource::Get()->Load(L_DIR_S_XRC wxT("frm_main.xrc")))
\r
53 wxLogError(_("Unable to find XRC!"));
\r
57 ::wxXmlResource::Get()->LoadFrame(frm_main, NULL, wxT("frame_main"));
\r
58 ::wxXmlResource::Get()->Unload(L_DIR_S_XRC wxT("frm_main.xrc"));
\r
59 frm_main->InitDialog();
\r
62 wxCmdLineParser cmdLine(this->argc, this->argv);
\r
63 cmdLine.SetSwitchChars(wxT("-"));
\r
64 cmdLine.AddSwitch(wxT("a"), wxEmptyString, _("(command) Add to archive."));
\r
65 cmdLine.AddSwitch(wxT("x"), wxEmptyString, _("(command) Extract archive."));
\r
66 cmdLine.AddSwitch(wxT("t"), wxEmptyString, _("(command) Test archive."));
\r
67 cmdLine.AddSwitch(wxT("l"), wxEmptyString, _("(command) List archive(default)."));
\r
68 cmdLine.AddParam(_("archive"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
\r
69 cmdLine.AddParam(_("filenames"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE);
\r
70 if (cmdLine.Parse() != 0)
\r
72 frm_main->Close(true);
\r
76 if (cmdLine.GetParamCount() == 0)
\r
78 // コマンドラインがなければウインドウを表示。
\r
85 frm_main->fnArchive = wxFileName(cmdLine.GetParam(0));
\r
86 frm_main->fnArchive.Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_LONG, szCwd);
\r
87 frm_main->OnArcOpen(e);
\r
88 if (cmdLine.Found(wxT("a")))
\r
91 frm_main->OnArcAdd(e);
\r
93 else if (cmdLine.Found(wxT("t")))
\r
96 frm_main->OnArcTest(e);
\r
98 else if (cmdLine.Found(wxT("x")))
\r
101 frm_main->OnArcExtract(e);
\r
107 // スプリッター設定(OnInitでは効かないことがあるため)。
\r
108 frm_main->window_splitter->SetSashPosition(frm_main->conf.ReadId(CONF_WINDOW_SPLITTER_POS, 200l));
\r
112 // 何かコマンドを実行していればこのまま終了。
\r
113 frm_main->Close(true);
\r