[Scummvm-cvs-logs] SF.net SVN: scummvm:[42569] tools/branches/gsoc2009-gui/gui
Remere at users.sourceforge.net
Remere at users.sourceforge.net
Fri Jul 17 21:09:22 CEST 2009
Revision: 42569
http://scummvm.svn.sourceforge.net/scummvm/?rev=42569&view=rev
Author: Remere
Date: 2009-07-17 19:09:22 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
*"Next" is now disabled if you haven't filled in the output / input fields.
*Fixed bug with paths not loading when going back in the wizard.
*Fixed bug with paths being cleared each time the guide was run.
Modified Paths:
--------------
tools/branches/gsoc2009-gui/gui/pages.cpp
tools/branches/gsoc2009-gui/gui/pages.h
tools/branches/gsoc2009-gui/gui/tools.cpp
Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp 2009-07-17 16:10:56 UTC (rev 42568)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp 2009-07-17 19:09:22 UTC (rev 42569)
@@ -96,7 +96,7 @@
// Introduction page
-IntroPage::IntroPage(ScummToolsFrame* frame)
+IntroPage::IntroPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -162,7 +162,7 @@
// Page to choose the tool to use
-ChooseToolPage::ChooseToolPage(ScummToolsFrame* frame, const wxArrayString &options)
+ChooseToolPage::ChooseToolPage(ScummToolsFrame *frame, const wxArrayString &options)
: WizardPage(frame),
_options(options)
{
@@ -216,13 +216,55 @@
switchPage(new ChooseOutPage(_topframe));
}
-// Page to choose input directory or file
+// Common base class for the IO pages
-ChooseInPage::ChooseInPage(ScummToolsFrame* frame)
+ChooseIOPage::ChooseIOPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
+void ChooseIOPage::onSelectFile(wxFileDirPickerEvent &evt) {
+ wxWindow *win = dynamic_cast<wxWindow *>(evt.GetEventObject());
+ wxPanel *panel = dynamic_cast<wxPanel *>(win->GetParent());
+
+ updateButtons(panel, _topframe->_buttons);
+}
+
+void ChooseIOPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
+ wxWindow *picker = NULL;
+ if(!picker)
+ picker = panel->FindWindowByName(wxT("InputPicker"));
+
+ const ToolGUI *tool = _topframe->_configuration.selectedTool;
+ if(tool && !picker) {
+ for(size_t i = 1; i < tool->getInputList().size(); ++i) {
+ wxString name(wxT("InputPicker"));
+ name << i;
+ picker = panel->FindWindowByName(name);
+ if(picker)
+ break;
+ }
+ }
+
+ if(!picker)
+ picker = panel->FindWindowByName(wxT("OutputPicker"));
+
+
+ wxDirPickerCtrl *inDirWindow = dynamic_cast<wxDirPickerCtrl *>(picker);
+ wxFilePickerCtrl *inFileWindow = dynamic_cast<wxFilePickerCtrl *>(picker);
+
+ _topframe->_buttons->enableNext(
+ (inDirWindow && inDirWindow->GetPath().size() > 0) ||
+ (inFileWindow && inFileWindow->GetPath().size() > 0));
+}
+
+// Page to choose input directory or file
+
+ChooseInPage::ChooseInPage(ScummToolsFrame *frame)
+ : ChooseIOPage(frame)
+{
+}
+
wxWindow *ChooseInPage::CreatePanel(wxWindow *parent) {
wxWindow *panel = WizardPage::CreatePanel(parent);
@@ -242,12 +284,16 @@
//if (input._file) {
- sizer->Add(new wxFilePickerCtrl(
+ wxFilePickerCtrl *picker = new wxFilePickerCtrl(
panel, wxID_ANY, wxEmptyString, wxT("Select a file"),
wxT("*.*"),
wxDefaultPosition, wxSize(300, -1),
wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator,
- wxT("InputPicker")));
+ wxT("InputPicker"));
+ sizer->Add(picker);
+ panel->Connect(wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler(ChooseIOPage::onSelectFile), NULL, this);
+ if(_topframe->_configuration.inputFilePaths.size() > 0)
+ picker->SetPath(_topframe->_configuration.inputFilePaths[0]);
sizer->AddSpacer(30);
/*
@@ -307,8 +353,8 @@
// Page to choose input and output directory or file
-ChooseExtraInPage::ChooseExtraInPage(ScummToolsFrame* frame)
- : WizardPage(frame)
+ChooseExtraInPage::ChooseExtraInPage(ScummToolsFrame *frame)
+ : ChooseIOPage(frame)
{
}
@@ -339,20 +385,26 @@
wxString windowName = wxT("InputPicker");
windowName << i;
+ wxString inputFile;
+ if(_topframe->_configuration.inputFilePaths.size() > (size_t)i)
+ inputFile = _topframe->_configuration.inputFilePaths[i];
+
if (input.file) {
inputbox->Add(new wxFilePickerCtrl(
- panel, wxID_ANY, wxEmptyString, wxT("Select a file"),
+ panel, wxID_ANY, inputFile, wxT("Select a file"),
wxString(input.format.c_str(), wxConvUTF8),
wxDefaultPosition, wxDefaultSize,
wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator,
windowName));
+ panel->Connect(wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler(ChooseIOPage::onSelectFile), NULL, this);
} else {
inputbox->Add(new wxDirPickerCtrl(
- panel, wxID_ANY, wxEmptyString, wxT("Select a folder"),
+ panel, wxID_ANY, inputFile, wxT("Select a folder"),
wxDefaultPosition, wxDefaultSize,
wxFLP_USE_TEXTCTRL | wxFLP_OPEN, wxDefaultValidator,
windowName));
+ panel->Connect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(ChooseIOPage::onSelectFile), NULL, this);
}
++i;
@@ -405,8 +457,8 @@
// Page to choose input and output directory or file
-ChooseOutPage::ChooseOutPage(ScummToolsFrame* frame)
- : WizardPage(frame)
+ChooseOutPage::ChooseOutPage(ScummToolsFrame *frame)
+ : ChooseIOPage(frame)
{
}
@@ -436,22 +488,30 @@
if (tool.outputToDirectory()) {
wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination folder"));
- box->Add(new wxDirPickerCtrl(
+ wxDirPickerCtrl *picker = new wxDirPickerCtrl(
panel, wxID_ANY, _configuration.outputPath, wxT("Select a folder"),
wxDefaultPosition, wxSize(300, -1),
wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator,
- wxT("OutputPicker")));
+ wxT("OutputPicker"));
+ box->Add(picker);
+ panel->Connect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(ChooseIOPage::onSelectFile), NULL, this);
+ picker->SetPath(_topframe->_configuration.outputPath);
+
sizer->Add(box);
} else {
wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination file"));
- box->Add(new wxFilePickerCtrl(
+ wxFilePickerCtrl *picker = new wxFilePickerCtrl(
panel, wxID_ANY, _configuration.outputPath, wxT("Select a file"),
wxT("*.*"),
wxDefaultPosition, wxSize(300, -1),
wxFLP_USE_TEXTCTRL | wxFLP_OVERWRITE_PROMPT | wxFLP_SAVE, wxDefaultValidator,
- wxT("OutputPicker")));
+ wxT("OutputPicker"));
+ box->Add(picker);
+
+ panel->Connect(wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler(ChooseIOPage::onSelectFile), NULL, this);
+ picker->SetPath(_topframe->_configuration.outputPath);
sizer->Add(box);
}
@@ -481,7 +541,7 @@
// Page to choose input and output directory or file
-ChooseAudioFormatPage::ChooseAudioFormatPage(ScummToolsFrame* frame)
+ChooseAudioFormatPage::ChooseAudioFormatPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -564,7 +624,7 @@
// Page to choose Mp3 compression options
-ChooseAudioOptionsMp3Page::ChooseAudioOptionsMp3Page(ScummToolsFrame* frame)
+ChooseAudioOptionsMp3Page::ChooseAudioOptionsMp3Page(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -727,7 +787,7 @@
// Page to choose Flac compression options
-ChooseAudioOptionsFlacPage::ChooseAudioOptionsFlacPage(ScummToolsFrame* frame)
+ChooseAudioOptionsFlacPage::ChooseAudioOptionsFlacPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -815,7 +875,7 @@
// Page to choose Vorbis compression options
-ChooseAudioOptionsVorbisPage::ChooseAudioOptionsVorbisPage(ScummToolsFrame* frame)
+ChooseAudioOptionsVorbisPage::ChooseAudioOptionsVorbisPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -911,7 +971,7 @@
// Page to choose ANY tool to use
-ProcessPage::ProcessPage(ScummToolsFrame* frame)
+ProcessPage::ProcessPage(ScummToolsFrame *frame)
: WizardPage(frame),
_finished(false),
_success(false)
@@ -1001,7 +1061,7 @@
// Only windows needs this
// It hides the process window, on unix it doesn't appear to work very well
wxProcess proc(wxPROCESS_REDIRECT);
- _output.retval = wxExecute(wxString(_output.cmd, ), wxEXEC_SYNC, &proc);
+ _output.retval = wxExecute(wxString(_output.cmd, wxConvUTF8), wxEXEC_SYNC, &proc);
#else
// Process windows are hidden by default under other OSes, so we don't need any special code
_output.retval = system(_output.cmd);
@@ -1140,7 +1200,7 @@
// Last page of the wizard, offers the option to open the output directory
-FinishPage::FinishPage(ScummToolsFrame* frame)
+FinishPage::FinishPage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
@@ -1191,7 +1251,7 @@
// If the tool fails, this page is shown instead of the last page
-FailurePage::FailurePage(ScummToolsFrame* frame)
+FailurePage::FailurePage(ScummToolsFrame *frame)
: WizardPage(frame)
{
}
Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h 2009-07-17 16:10:56 UTC (rev 42568)
+++ tools/branches/gsoc2009-gui/gui/pages.h 2009-07-17 19:09:22 UTC (rev 42569)
@@ -26,6 +26,7 @@
#include "configuration.h"
class Tool;
+class wxFileDirPickerEvent;
/**
* A backend of a page in the wizard
@@ -35,13 +36,10 @@
* in a default config window, for example.
*/
-class WizardPage : public wxEvtHandler
-{
+class WizardPage : public wxEvtHandler {
public:
- WizardPage(ScummToolsFrame* frame);
- ~WizardPage() {
-;
- }
+ WizardPage(ScummToolsFrame *frame);
+ ~WizardPage() {}
/**
* Creates a visual representation of this page as a child problem of the supplied parent
@@ -121,7 +119,7 @@
*/
void SetAlignedSizer(wxWindow *panel, wxSizer *sizer);
- ScummToolsFrame* _topframe;
+ ScummToolsFrame *_topframe;
Configuration &_configuration;
DECLARE_EVENT_TABLE()
@@ -133,10 +131,9 @@
* @todo Add the ability to drag & drop files onto this window, to automatically detect whether to compress or extract
*/
-class IntroPage : public WizardPage
-{
+class IntroPage : public WizardPage {
public:
- IntroPage(ScummToolsFrame* frame);
+ IntroPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -154,10 +151,9 @@
* "multiple tools matched that input file..."
*/
-class ChooseToolPage : public WizardPage
-{
+class ChooseToolPage : public WizardPage {
public:
- ChooseToolPage(ScummToolsFrame* frame, const wxArrayString &options = wxArrayString());
+ ChooseToolPage(ScummToolsFrame *frame, const wxArrayString &options = wxArrayString());
wxWindow *CreatePanel(wxWindow *parent);
@@ -170,13 +166,25 @@
};
/**
+ * Common class for the pages that display input selection
+ */
+
+class ChooseIOPage : public WizardPage {
+public:
+ ChooseIOPage(ScummToolsFrame *frame);
+
+ void onSelectFile(wxFileDirPickerEvent &evt);
+
+ void updateButtons(wxWindow *panel, WizardButtons *buttons);
+};
+
+/**
* Offers the user to input a file or directory
*/
-class ChooseInPage : public WizardPage
-{
+class ChooseInPage : public ChooseIOPage {
public:
- ChooseInPage(ScummToolsFrame* frame);
+ ChooseInPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -189,10 +197,9 @@
* If the tool requires more than one input, the additional will be presented here
*/
-class ChooseExtraInPage : public WizardPage
-{
+class ChooseExtraInPage : public ChooseIOPage {
public:
- ChooseExtraInPage(ScummToolsFrame* frame);
+ ChooseExtraInPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -208,10 +215,9 @@
* @todo Make it look better and save state
*/
-class ChooseOutPage : public WizardPage
-{
+class ChooseOutPage : public ChooseIOPage {
public:
- ChooseOutPage(ScummToolsFrame* frame);
+ ChooseOutPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -228,10 +234,9 @@
* only support one method of compression.
*/
-class ChooseAudioFormatPage : public WizardPage
-{
+class ChooseAudioFormatPage : public WizardPage {
public:
- ChooseAudioFormatPage(ScummToolsFrame* frame);
+ ChooseAudioFormatPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -245,10 +250,9 @@
*
*/
-class ChooseAudioOptionsMp3Page : public WizardPage
-{
+class ChooseAudioOptionsMp3Page : public WizardPage {
public:
- ChooseAudioOptionsMp3Page(ScummToolsFrame* frame);
+ ChooseAudioOptionsMp3Page(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -274,10 +278,9 @@
*
*/
-class ChooseAudioOptionsFlacPage : public WizardPage
-{
+class ChooseAudioOptionsFlacPage : public WizardPage {
public:
- ChooseAudioOptionsFlacPage(ScummToolsFrame* frame);
+ ChooseAudioOptionsFlacPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -291,10 +294,9 @@
*
*/
-class ChooseAudioOptionsVorbisPage : public WizardPage
-{
+class ChooseAudioOptionsVorbisPage : public WizardPage {
public:
- ChooseAudioOptionsVorbisPage(ScummToolsFrame* frame);
+ ChooseAudioOptionsVorbisPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -383,8 +385,8 @@
* as the class keeps internal state
*/
-class ProcessPage : public WizardPage
-{
+class ProcessPage : public WizardPage {
+
/** True if the tool exited with success */
bool _success;
/** True if the tool has exited */
@@ -399,7 +401,7 @@
ThreadCommunicationBuffer _output;
public:
- ProcessPage(ScummToolsFrame* frame);
+ ProcessPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -424,10 +426,9 @@
*
*/
-class FinishPage : public WizardPage
-{
+class FinishPage : public WizardPage {
public:
- FinishPage(ScummToolsFrame* frame);
+ FinishPage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
@@ -441,10 +442,9 @@
*
*/
-class FailurePage : public WizardPage
-{
+class FailurePage : public WizardPage {
public:
- FailurePage(ScummToolsFrame* frame);
+ FailurePage(ScummToolsFrame *frame);
wxWindow *CreatePanel(wxWindow *parent);
Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp 2009-07-17 16:10:56 UTC (rev 42568)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp 2009-07-17 19:09:22 UTC (rev 42569)
@@ -304,7 +304,6 @@
}
void ToolGUI::run(const Configuration &conf) const {
- _backend->_inputPaths.clear();
size_t i = 0;
for (wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter, ++i)
_backend->_inputPaths[i].path = (const char *)iter->mb_str();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list