OSDN Git Service

ダイアログで最後に開いていたパスを、ダイアログを閉じるたびに設定ファイルに書き込むよう変更。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 23 Oct 2009 12:32:25 +0000 (12:32 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Fri, 23 Oct 2009 12:32:25 +0000 (12:32 +0000)
格納ファイルを開く際にファイルの種類を取得できない場合に、特定の拡張子とみなすDefaultExtを設定に追加。

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@75 9df91469-1e22-0410-86e7-ea8537beb833

src/frontend/frm_main.cpp
src/frontend/frm_main.h

index f15745e..c312427 100644 (file)
@@ -66,7 +66,6 @@ MainFrame::~MainFrame()
                this->conf.Write(wxT("Window-Y"), b);
        }
        this->conf.Write(wxT("Splitter-Pos"), this->window_splitter->GetSashPosition());
-       this->conf.Write(wxT("LastOpenPath"), this->fnLastOpenPath.GetFullPath());
 
        // \83c\81[\83\8b\83o\81[/\83X\83e\81[\83^\83X\83o\81[\8aÖ\98A\81B
        this->conf.Write(wxT("StatusBar-Show"), this->statusbar->IsShown());
@@ -144,7 +143,6 @@ void MainFrame::OnInit(wxInitDialogEvent&)
 
        // \90Ý\92è\82ð\93Ç\82Ý\8d\9e\82Ý\81B
        this->SetSize(this->conf.Read(wxT("Window-X"), 0l), this->conf.Read(wxT("Window-Y"), 0l), this->conf.Read(wxT("Window-Width"), 800), this->conf.Read(wxT("Window-Height"), 400));
-       this->fnLastOpenPath = wxFileName::DirName(this->conf.Read(wxT("LastOpenPath"), ::wxGetCwd()));
        wxTheMimeTypesManager->Initialize(wxMAILCAP_ALL);
 
        // \8f\89\8aú\92l\90Ý\92è\81B
@@ -237,7 +235,7 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        if (e.GetClientData() == NULL)
        {
                // \8f\88\97\9d\91Î\8fÛ\82Ì\83t\83@\83C\83\8b\82ð\91I\91ð\81B
-               wxFileDialog fd(this, wxT("Choose files to compress"), this->fnLastOpenPath.GetFullPath());
+               wxFileDialog fd(this, wxT("Choose files to compress"), this->conf.Read(wxT("LastOpenPath"), ::wxGetCwd()));
                fd.SetWindowStyleFlag(wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
                if (fd.ShowModal() == wxID_CANCEL)
                {
@@ -245,8 +243,8 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
                }
                // \82±\82±\82ÅwxFileName::FileName\82ð\97p\82¢\82Ä\82¢\82é\82Ì\82Í\81A\8cã\82Å\83f\83B\83\8c\83N\83g\83\8a\96¼\82ð\95K\97v\82Æ\82·\82é\8fê\8d\87\82ª\82 \82é\82½\82ß\81B
                // \82 \82Ü\82è\82æ\82¢\8ed\97l\82Å\82Í\82È\82¢\82ª\93®\82­\82Ì\82Å\82Æ\82è\82 \82¦\82¸\95ú\92u\81B
-               this->fnLastOpenPath = wxFileName::FileName(fd.GetDirectory());
-               swInfo.fnDestinationDirectory = wxFileName::DirName(this->fnLastOpenPath.GetFullPath());
+               swInfo.fnDestinationDirectory = wxFileName::DirName(fd.GetDirectory());
+               this->conf.Write(wxT("LastOpenPath"), fd.GetDirectory());
                this->statusbar->SetStatusText(swInfo.fnDestinationDirectory.GetFullPath(), 4);
 
                fd.GetFilenames(mkDlg.files);
@@ -355,13 +353,13 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        if (szFileName.IsEmpty())
        {
                wxFileDialog fd(this);
-               fd.SetDirectory(this->fnLastOpenPath.GetFullPath());
+               fd.SetDirectory(this->conf.Read(wxT("LastOpenPath"), ::wxGetCwd()));
                fd.SetWindowStyleFlag(wxFD_OPEN | wxFD_FILE_MUST_EXIST);
                if (fd.ShowModal() == wxID_CANCEL)
                {
                        return;
                }
-               this->fnLastOpenPath = wxFileName::DirName(fd.GetDirectory());
+               this->conf.Write(wxT("LastOpenPath"), fd.GetDirectory());
                szFileName = fd.GetPath();
        }
        this->OnArcClose(e);
@@ -553,13 +551,14 @@ void MainFrame::OnArcAdd(wxCommandEvent& e)
 {
        // \8f\88\97\9d\91Î\8fÛ\82Ì\83t\83@\83C\83\8b\82ð\91I\91ð\81B
        wxArrayString files;
-       wxFileDialog fd(this, wxT("Choose files to add"), this->fnLastOpenPath.GetFullPath());
+       wxFileDialog fd(this, wxT("Choose files to add"), this->conf.Read(wxT("LastOpenPath"), ::wxGetCwd()));
        fd.SetWindowStyleFlag(wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
        if (fd.ShowModal() == wxID_CANCEL)
        {
                return;
        }
        fd.GetFilenames(files);
+       this->conf.Write(wxT("LastOpenPath"), fd.GetDirectory());
 
        // \8ae\8eí\90Ý\92è\81B
        TPI_SWITCHES swInfo;
@@ -593,7 +592,7 @@ void MainFrame::OnArcConvert(wxCommandEvent& e)
                return;
        }
        swInfo.fnDestinationDirectory = wxFileName::DirName(fd.GetDirectory());
-       this->fnLastOpenPath = swInfo.fnDestinationDirectory;
+       this->conf.Write(wxT("LastOpenPath"), fd.GetDirectory());
 
        wxArrayString files;
        files.Add(fd.GetPath());
@@ -630,8 +629,8 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                        ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(wxFileName::FileName(mkDlg.files[0]).GetExt());
                        if (! ftFile)
                        {
-                               // \8eí\97Þ\82ª\8eæ\93¾\82Å\82«\82È\82¢\82Æ\82«\82Í\83e\83L\83X\83g\82Æ\82Ý\82È\82·\81B
-                               ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("txt"));
+                               // \8eí\97Þ\82ª\8eæ\93¾\82Å\82«\82È\82¢\82Æ\82«\82Í\90Ý\92è\82ð\93Ç\82Ý\8d\9e\82Þ\81B\8f\89\8aú\90Ý\92è\82Å\82Í\83e\83L\83X\83g\82Æ\82Ý\82È\82·\81B
+                               ftFile = wxTheMimeTypesManager->GetFileTypeFromExtension(this->conf.Read(wxT("DefaultExt"), wxT("txt")));
                                if (! ftFile)
                                {
                                        ::ErrDlg(wxT("Unable to get the file type!"), this);
index 72cbd31..d107019 100644 (file)
@@ -1,85 +1,84 @@
-/*******************************************************************************\r
-  TPI - flexible but useless plug-in framework.\r
-  Copyright (C) 2002-2009 Silky\r
-\r
-  This library is free software; you can redistribute it and/or modify it under\r
-  the terms of the GNU Lesser General Public License as published by the Free\r
-  Software Foundation; either version 2.1 of the License, or (at your option)\r
-  any later version.\r
-\r
-  This library is distributed in the hope that it will be useful, but WITHOUT\r
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or \r
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License\r
-  for more details.\r
-\r
-  You should have received a copy of the GNU Lesser General Public License along\r
-  with this library; if not, write to the Free Software Foundation, Inc.,\r
-  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
-\r
-  $Id: frm_main.h,v 1.10 2009/08/30 09:28:27 sirakaba Exp $\r
-*******************************************************************************/\r
-\r
-#include <wx/cmdline.h>\r
-#include <wx/splitter.h>\r
+/*******************************************************************************
+  TPI - flexible but useless plug-in framework.
+  Copyright (C) 2002-2009 Silky
+
+  This library is free software; you can redistribute it and/or modify it under
+  the terms of the GNU Lesser General Public License as published by the Free
+  Software Foundation; either version 2.1 of the License, or (at your option)
+  any later version.
+
+  This library is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+  for more details.
+
+  You should have received a copy of the GNU Lesser General Public License along
+  with this library; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+  $Id: frm_main.h,v 1.10 2009/08/30 09:28:27 sirakaba Exp $
+*******************************************************************************/
+
+#include <wx/cmdline.h>
+#include <wx/splitter.h>
 #include <wx/fileconf.h>
-\r
-#ifndef H_LOADED_FRM_MAIN\r
-#define H_LOADED_FRM_MAIN\r
-\r
-class MainFrame: public wxFrame {\r
-public:\r
-    wxStatusBar* statusbar;\r
-    wxTreeCtrl* tree_ctrl;\r
-    myListCtrl* list_ctrl;\r
-       ArrayTPI_FILEINFO fileinfo;\r
-       TPIHandle tpi;\r
-       wxString szCurrentPath;\r
-       wxFileName fnLastOpenPath;\r
-       wxCmdLineParser cmdLine;\r
-\r
-    // Event handler.\r
-    void OnInit(    wxInitDialogEvent&);\r
-\r
-       void OnExit(       wxCommandEvent&);\r
-    void OnArcCreate(  wxCommandEvent&);\r
-    void OnArcOpen(    wxCommandEvent&);\r
-    void OnArcClose(   wxCommandEvent&);\r
-    void OnArcAdd(     wxCommandEvent&);\r
-    void OnArcConvert( wxCommandEvent&);\r
-\r
-       void OnArcExtract( wxCommandEvent&);\r
-    void OnArcDelete(  wxCommandEvent&);\r
-    void OnArcTest(    wxCommandEvent&);\r
-    void OnArcRepair(  wxCommandEvent&);\r
-\r
-       void OnViewMode(wxCommandEvent&);\r
-\r
-       void OnShowToolBar(  wxCommandEvent&);\r
-       void OnShowStatusBar(wxCommandEvent&);\r
-\r
-       void OnSelectAll(wxCommandEvent&);\r
-\r
-       void OnTreeChanged(wxTreeEvent&);\r
-       void OnTreeBeginDrag(wxTreeEvent&);\r
-\r
-       void OnListItemDClick(wxListEvent&);\r
-    void OnListBeginDrag( wxListEvent&);\r
-\r
-       void OnFilter(wxCommandEvent&);\r
-\r
-       int LoadTPI(wxString &);\r
-       int ErrorCheck(int);\r
-\r
-       MainFrame();\r
-       ~MainFrame();\r
-\r
-protected:\r
-    wxMenuBar* menubar;\r
-    wxToolBar* toolbar;\r
-    wxSplitterWindow* window_splitter;\r
-    wxTextCtrl * tcFilter;\r
-       wxFileConfig conf;\r
-    DECLARE_EVENT_TABLE()\r
-};\r
-\r
-#endif\r
+
+#ifndef H_LOADED_FRM_MAIN
+#define H_LOADED_FRM_MAIN
+
+class MainFrame: public wxFrame {
+public:
+    wxStatusBar* statusbar;
+    wxTreeCtrl* tree_ctrl;
+    myListCtrl* list_ctrl;
+       ArrayTPI_FILEINFO fileinfo;
+       TPIHandle tpi;
+       wxString szCurrentPath;
+       wxCmdLineParser cmdLine;
+
+    // Event handler.
+    void OnInit(    wxInitDialogEvent&);
+
+       void OnExit(       wxCommandEvent&);
+    void OnArcCreate(  wxCommandEvent&);
+    void OnArcOpen(    wxCommandEvent&);
+    void OnArcClose(   wxCommandEvent&);
+    void OnArcAdd(     wxCommandEvent&);
+    void OnArcConvert( wxCommandEvent&);
+
+       void OnArcExtract( wxCommandEvent&);
+    void OnArcDelete(  wxCommandEvent&);
+    void OnArcTest(    wxCommandEvent&);
+    void OnArcRepair(  wxCommandEvent&);
+
+       void OnViewMode(wxCommandEvent&);
+
+       void OnShowToolBar(  wxCommandEvent&);
+       void OnShowStatusBar(wxCommandEvent&);
+
+       void OnSelectAll(wxCommandEvent&);
+
+       void OnTreeChanged(wxTreeEvent&);
+       void OnTreeBeginDrag(wxTreeEvent&);
+
+       void OnListItemDClick(wxListEvent&);
+    void OnListBeginDrag( wxListEvent&);
+
+       void OnFilter(wxCommandEvent&);
+
+       int LoadTPI(wxString &);
+       int ErrorCheck(int);
+
+       MainFrame();
+       ~MainFrame();
+
+protected:
+    wxMenuBar* menubar;
+    wxToolBar* toolbar;
+    wxSplitterWindow* window_splitter;
+    wxTextCtrl * tcFilter;
+       wxFileConfig conf;
+    DECLARE_EVENT_TABLE()
+};
+
+#endif