From 0c5590dd0e3f367064a6e4d52835a609adf11a06 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 4 May 2013 18:47:33 +0100 Subject: Batch converter stub. --- src/lib/util.cc | 2 +- src/lib/util.h | 2 +- src/tools/dvdomatic.cc | 46 +----------- src/tools/dvdomatic_batch.cc | 168 +++++++++++++++++++++++++++++++++++++++++++ src/tools/wscript | 2 +- src/wx/batch_view.cc | 33 +++++++++ src/wx/batch_view.h | 30 ++++++++ src/wx/wscript | 1 + src/wx/wx_util.cc | 38 ++++++++++ src/wx/wx_util.h | 1 + 10 files changed, 275 insertions(+), 48 deletions(-) create mode 100644 src/tools/dvdomatic_batch.cc create mode 100644 src/wx/batch_view.cc create mode 100644 src/wx/batch_view.h (limited to 'src') diff --git a/src/lib/util.cc b/src/lib/util.cc index 859aa6de7..be078a95f 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -274,7 +274,7 @@ mo_path () #endif void -dvdomatic_setup_i18n (string lang) +dvdomatic_setup_gettext_i18n (string lang) { #ifdef DVDOMATIC_POSIX lang += ".UTF8"; diff --git a/src/lib/util.h b/src/lib/util.h index 99670110e..d0c350a56 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -55,7 +55,7 @@ extern void stacktrace (std::ostream &, int); extern std::string dependency_version_summary (); extern double seconds (struct timeval); extern void dvdomatic_setup (); -extern void dvdomatic_setup_i18n (std::string); +extern void dvdomatic_setup_gettext_i18n (std::string); extern std::vector split_at_spaces_considering_quotes (std::string); extern std::string md5_digest (std::string); extern std::string md5_digest (void const *, int); diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index b161ac7e3..2740a0965 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -62,7 +62,6 @@ static shared_ptr film; static std::string log_level; static std::string film_to_load; static wxMenu* jobs_menu = 0; -static wxLocale* locale = 0; static void set_menu_sensitivity (); @@ -463,49 +462,6 @@ static const wxCmdLineEntryDesc command_line_description[] = { }; #endif -void -setup_i18n () -{ - int language = wxLANGUAGE_DEFAULT; - - ofstream f ("c:/users/carl hetherington/foo", std::ios::app); - f << "Hello.\n"; - - boost::optional config_lang = Config::instance()->language (); - if (config_lang && !config_lang->empty ()) { - f << "Configured language " << config_lang.get() << "\n"; - wxLanguageInfo const * li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ())); - f << "LanguageInfo " << li << "\n"; - if (li) { - language = li->Language; - f << "language=" << language << " cf " << wxLANGUAGE_DEFAULT << " " << wxLANGUAGE_ENGLISH << "\n"; - } - } - - if (wxLocale::IsAvailable (language)) { - f << "Language is available.\n"; - locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT); - -#ifdef DVDOMATIC_WINDOWS - locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); -#endif - - locale->AddCatalog (wxT ("libdvdomatic-wx")); - locale->AddCatalog (wxT ("dvdomatic")); - - if (!locale->IsOk()) { - f << "Locale is not ok.\n"; - delete locale; - locale = new wxLocale (wxLANGUAGE_ENGLISH); - language = wxLANGUAGE_ENGLISH; - } - } - - if (locale) { - dvdomatic_setup_i18n (wx_to_std (locale->GetCanonicalName ())); - } -} - class App : public wxApp { bool OnInit () @@ -526,7 +482,7 @@ class App : public wxApp hasn't yet been called and there aren't any scalers, filters etc. set up yet. */ - setup_i18n (); + dvdomatic_setup_i18n (); /* Set things up, including scalers / filters etc. which will now be internationalised correctly. diff --git a/src/tools/dvdomatic_batch.cc b/src/tools/dvdomatic_batch.cc new file mode 100644 index 000000000..102f29408 --- /dev/null +++ b/src/tools/dvdomatic_batch.cc @@ -0,0 +1,168 @@ +/* + Copyright (C) 2013 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include "lib/version.h" +#include "lib/compose.hpp" +#include "lib/config.h" +#include "lib/util.h" +#include "wx/wx_util.h" +#include "wx/wx_ui_signaller.h" +#include "wx/batch_view.h" + +enum { + ID_file_quit = 1, + ID_help_about +}; + +void +setup_menu (wxMenuBar* m) +{ + wxMenu* file = new wxMenu; + file->Append (ID_file_quit, _("&Quit")); + + wxMenu* help = new wxMenu; + help->Append (ID_help_about, _("About")); + + m->Append (file, _("&File")); + m->Append (help, _("&Help")); +} + +class Frame : public wxFrame +{ +public: + Frame (wxString const & title) + : wxFrame (NULL, -1, title) + { + wxMenuBar* bar = new wxMenuBar; + setup_menu (bar); + SetMenuBar (bar); + + Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit)); + Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about)); + + wxPanel* panel = new wxPanel (this); + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + s->Add (panel, 1, wxEXPAND); + SetSizer (s); + + wxSizer* sizer = new wxBoxSizer (wxVERTICAL); + + BatchView* batch_view = new BatchView (panel); + sizer->Add (batch_view, 1, wxALL | wxEXPAND, 6); + + wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL); + wxButton* add = new wxButton (panel, wxID_ANY, _("Add Film...")); + buttons->Add (add, 1, wxALL, 6); + wxButton* start = new wxButton (panel, wxID_ANY, _("Start...")); + buttons->Add (start, 1, wxALL, 6); + + sizer->Add (buttons, 0, wxALL, 6); + + panel->SetSizer (sizer); + } + +private: + void file_quit (wxCommandEvent &) + { + Close (true); + } + + void help_about (wxCommandEvent &) + { + wxAboutDialogInfo info; + info.SetName (_("DVD-o-matic Batch Converter")); + if (strcmp (dvdomatic_git_commit, "release") == 0) { + info.SetVersion (std_to_wx (String::compose ("version %1", dvdomatic_version))); + } else { + info.SetVersion (std_to_wx (String::compose ("version %1 git %2", dvdomatic_version, dvdomatic_git_commit))); + } + info.SetDescription (_("Free, open-source DCP generation from almost anything.")); + info.SetCopyright (_("(C) 2012-2013 Carl Hetherington, Terrence Meiczinger, Paul Davis, Ole Laursen")); + + wxArrayString authors; + authors.Add (wxT ("Carl Hetherington")); + authors.Add (wxT ("Terrence Meiczinger")); + authors.Add (wxT ("Paul Davis")); + authors.Add (wxT ("Ole Laursen")); + info.SetDevelopers (authors); + + wxArrayString translators; + translators.Add (wxT ("Olivier Perriere")); + translators.Add (wxT ("Lilian Lefranc")); + translators.Add (wxT ("Thierry Journet")); + translators.Add (wxT ("Massimiliano Broggi")); + translators.Add (wxT ("Manuel AC")); + translators.Add (wxT ("Adam Klotblixt")); + info.SetTranslators (translators); + + info.SetWebSite (wxT ("http://carlh.net/software/dvdomatic")); + wxAboutBox (info); + } +}; + +class App : public wxApp +{ + bool OnInit () + { + if (!wxApp::OnInit()) { + return false; + } + +#ifdef DVDOMATIC_POSIX + unsetenv ("UBUNTU_MENUPROXY"); +#endif + + /* Enable i18n; this will create a Config object + to look for a force-configured language. This Config + object will be wrong, however, because dvdomatic_setup + hasn't yet been called and there aren't any scalers, filters etc. + set up yet. + */ + dvdomatic_setup_i18n (); + + /* Set things up, including scalers / filters etc. + which will now be internationalised correctly. + */ + dvdomatic_setup (); + + /* Force the configuration to be re-loaded correctly next + time it is needed. + */ + Config::drop (); + + Frame* f = new Frame (_("DVD-o-matic Batch Converter")); + SetTopWindow (f); + f->Maximize (); + f->Show (); + + ui_signaller = new wxUISignaller (this); + this->Connect (-1, wxEVT_IDLE, wxIdleEventHandler (App::idle)); + + return true; + } + + void idle (wxIdleEvent &) + { + ui_signaller->ui_idle (); + } +}; + +IMPLEMENT_APP (App) diff --git a/src/tools/wscript b/src/tools/wscript index 9f0f52152..f36f0abef 100644 --- a/src/tools/wscript +++ b/src/tools/wscript @@ -13,7 +13,7 @@ def build(bld): obj.target = t if not bld.env.DISABLE_GUI: - for t in ['dvdomatic', 'servomatic_gui']: + for t in ['dvdomatic', 'dvdomatic_batch', 'servomatic_gui']: obj = bld(features = 'cxx cxxprogram') obj.uselib = 'DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC' obj.includes = ['..'] diff --git a/src/wx/batch_view.cc b/src/wx/batch_view.cc new file mode 100644 index 000000000..bfe30d8fb --- /dev/null +++ b/src/wx/batch_view.cc @@ -0,0 +1,33 @@ +/* + Copyright (C) 2013 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "batch_view.h" + +BatchView::BatchView (wxWindow* parent) + : wxScrolledWindow (parent) +{ + _panel = new wxPanel (this); + wxSizer* sizer = new wxBoxSizer (wxVERTICAL); + sizer->Add (_panel, 1, wxEXPAND); + SetSizer (sizer); + + _table = new wxFlexGridSizer (5, 6, 6); + _table->AddGrowableCol (1, 1); + _panel->SetSizer (_table); +} diff --git a/src/wx/batch_view.h b/src/wx/batch_view.h new file mode 100644 index 000000000..6316ac745 --- /dev/null +++ b/src/wx/batch_view.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2013 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include + +class BatchView : public wxScrolledWindow +{ +public: + BatchView (wxWindow *); + +private: + wxPanel* _panel; + wxFlexGridSizer* _table; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 42bb8ca88..f1c3d1a6a 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -6,6 +6,7 @@ import i18n sources = """ audio_dialog.cc audio_plot.cc + batch_view.cc config_dialog.cc dci_metadata_dialog.cc dir_picker_ctrl.cc diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 77f5da293..1a7b73faf 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -25,6 +25,8 @@ #include #include #include "wx_util.h" +#include "config.h" +#include "util.h" using namespace std; using namespace boost; @@ -211,3 +213,39 @@ checked_set (wxRadioButton* widget, bool value) widget->SetValue (value); } } + +void +dvdomatic_setup_i18n () +{ + int language = wxLANGUAGE_DEFAULT; + + boost::optional config_lang = Config::instance()->language (); + if (config_lang && !config_lang->empty ()) { + wxLanguageInfo const * li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ())); + if (li) { + language = li->Language; + } + } + + wxLocale* locale = 0; + if (wxLocale::IsAvailable (language)) { + locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT); + +#ifdef DVDOMATIC_WINDOWS + locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); +#endif + + locale->AddCatalog (wxT ("libdvdomatic-wx")); + locale->AddCatalog (wxT ("dvdomatic")); + + if (!locale->IsOk()) { + delete locale; + locale = new wxLocale (wxLANGUAGE_ENGLISH); + language = wxLANGUAGE_ENGLISH; + } + } + + if (locale) { + dvdomatic_setup_gettext_i18n (wx_to_std (locale->GetCanonicalName ())); + } +} diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index b3ab706df..00a625e1c 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -36,6 +36,7 @@ extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, wxString, int pr extern wxStaticText* add_label_to_grid_bag_sizer (wxGridBagSizer *, wxWindow *, wxString, wxGBPosition, wxGBSpan span = wxDefaultSpan); extern std::string wx_to_std (wxString); extern wxString std_to_wx (std::string); +extern void dvdomatic_setup_i18n (); /** @class ThreadedStaticText * -- cgit v1.2.3 From db0ad7242d39f0fbae04bb6983021c60d57fdcf5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 4 May 2013 20:58:31 +0100 Subject: Make batch converter basically work. --- src/lib/job.cc | 28 +++++++++++++++ src/lib/job.h | 4 +++ src/tools/dvdomatic.cc | 2 +- src/tools/dvdomatic_batch.cc | 85 ++++++++++++++++++++++++++++++++++++++++---- src/wx/batch_view.cc | 33 ----------------- src/wx/batch_view.h | 30 ---------------- src/wx/job_manager_view.cc | 50 ++++++++++++++++++++++---- src/wx/job_manager_view.h | 9 ++++- src/wx/wscript | 1 - 9 files changed, 162 insertions(+), 80 deletions(-) delete mode 100644 src/wx/batch_view.cc delete mode 100644 src/wx/batch_view.h (limited to 'src') diff --git a/src/lib/job.cc b/src/lib/job.cc index 1c66d87d3..9a5812fa7 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -26,6 +26,7 @@ #include #include "job.h" #include "util.h" +#include "cross.h" #include "i18n.h" @@ -155,6 +156,13 @@ Job::finished_cancelled () const return _state == FINISHED_CANCELLED; } +bool +Job::paused () const +{ + boost::mutex::scoped_lock lm (_state_mutex); + return _state == PAUSED; +} + /** Set the state of this job. * @param s New state. */ @@ -190,6 +198,10 @@ Job::set_progress (float p) _progress_unknown = false; _stack.back().normalised = p; boost::this_thread::interruption_point (); + + if (paused ()) { + dvdomatic_sleep (1); + } } /** @return fractional overall progress, or -1 if not known */ @@ -326,3 +338,19 @@ Job::cancel () _thread->interrupt (); _thread->join (); } + +void +Job::pause () +{ + if (running ()) { + set_state (PAUSED); + } +} + +void +Job::resume () +{ + if (paused ()) { + set_state (RUNNING); + } +} diff --git a/src/lib/job.h b/src/lib/job.h index fd036bce2..37fa56d20 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -47,6 +47,8 @@ public: virtual void run () = 0; void start (); + void pause (); + void resume (); void cancel (); bool is_new () const; @@ -55,6 +57,7 @@ public: bool finished_ok () const; bool finished_in_error () const; bool finished_cancelled () const; + bool paused () const; std::string error_summary () const; std::string error_details () const; @@ -79,6 +82,7 @@ protected: enum State { NEW, ///< the job hasn't been started yet RUNNING, ///< the job is running + PAUSED, ///< the job has been paused FINISHED_OK, ///< the job has finished successfully FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index 2740a0965..ff1560f0e 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -224,7 +224,7 @@ public: film_editor = new FilmEditor (film, panel); film_viewer = new FilmViewer (film, panel); - JobManagerView* job_manager_view = new JobManagerView (panel); + JobManagerView* job_manager_view = new JobManagerView (panel, static_cast (0)); _top_sizer = new wxBoxSizer (wxHORIZONTAL); _top_sizer->Add (film_editor, 0, wxALL, 6); diff --git a/src/tools/dvdomatic_batch.cc b/src/tools/dvdomatic_batch.cc index 102f29408..7a3d38d9c 100644 --- a/src/tools/dvdomatic_batch.cc +++ b/src/tools/dvdomatic_batch.cc @@ -18,17 +18,23 @@ */ #include +#include #include #include "lib/version.h" #include "lib/compose.hpp" #include "lib/config.h" #include "lib/util.h" +#include "lib/film.h" +#include "lib/job_manager.h" #include "wx/wx_util.h" #include "wx/wx_ui_signaller.h" -#include "wx/batch_view.h" +#include "wx/job_manager_view.h" + +using boost::shared_ptr; enum { - ID_file_quit = 1, + ID_file_add_film = 1, + ID_file_quit, ID_help_about }; @@ -36,6 +42,7 @@ void setup_menu (wxMenuBar* m) { wxMenu* file = new wxMenu; + file->Append (ID_file_add_film, _("&Add Film...")); file->Append (ID_file_quit, _("&Quit")); wxMenu* help = new wxMenu; @@ -55,6 +62,7 @@ public: setup_menu (bar); SetMenuBar (bar); + Connect (ID_file_add_film, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_add_film)); Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit)); Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about)); @@ -65,24 +73,60 @@ public: wxSizer* sizer = new wxBoxSizer (wxVERTICAL); - BatchView* batch_view = new BatchView (panel); - sizer->Add (batch_view, 1, wxALL | wxEXPAND, 6); + JobManagerView* job_manager_view = new JobManagerView (panel, JobManagerView::PAUSE); + sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6); wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL); wxButton* add = new wxButton (panel, wxID_ANY, _("Add Film...")); + add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (Frame::add_film)); buttons->Add (add, 1, wxALL, 6); - wxButton* start = new wxButton (panel, wxID_ANY, _("Start...")); - buttons->Add (start, 1, wxALL, 6); sizer->Add (buttons, 0, wxALL, 6); panel->SetSizer (sizer); + + Connect (wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler (Frame::close)); } private: + bool should_close () + { + if (!JobManager::instance()->work_to_do ()) { + return true; + } + + wxMessageDialog* d = new wxMessageDialog ( + 0, + _("There are unfinished jobs; are you sure you want to quit?"), + _("Unfinished jobs"), + wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION + ); + + bool const r = d->ShowModal() == wxID_YES; + d->Destroy (); + return r; + } + + void close (wxCloseEvent& ev) + { + if (!should_close ()) { + ev.Veto (); + return; + } + + ev.Skip (); + } + + void file_add_film (wxCommandEvent& ev) + { + add_film (ev); + } + void file_quit (wxCommandEvent &) { - Close (true); + if (should_close ()) { + Close (true); + } } void help_about (wxCommandEvent &) @@ -116,6 +160,33 @@ private: info.SetWebSite (wxT ("http://carlh.net/software/dvdomatic")); wxAboutBox (info); } + + void add_film (wxCommandEvent &) + { + wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + int r; + while (1) { + r = c->ShowModal (); + if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); + } else { + break; + } + } + + if (r == wxID_OK) { + try { + shared_ptr film (new Film (wx_to_std (c->GetPath ()))); + film->make_dcp (); + } catch (std::exception& e) { + wxString p = c->GetPath (); + wxCharBuffer b = p.ToUTF8 (); + error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data())); + } + } + + c->Destroy (); + } }; class App : public wxApp diff --git a/src/wx/batch_view.cc b/src/wx/batch_view.cc deleted file mode 100644 index bfe30d8fb..000000000 --- a/src/wx/batch_view.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2013 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "batch_view.h" - -BatchView::BatchView (wxWindow* parent) - : wxScrolledWindow (parent) -{ - _panel = new wxPanel (this); - wxSizer* sizer = new wxBoxSizer (wxVERTICAL); - sizer->Add (_panel, 1, wxEXPAND); - SetSizer (sizer); - - _table = new wxFlexGridSizer (5, 6, 6); - _table->AddGrowableCol (1, 1); - _panel->SetSizer (_table); -} diff --git a/src/wx/batch_view.h b/src/wx/batch_view.h deleted file mode 100644 index 6316ac745..000000000 --- a/src/wx/batch_view.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (C) 2013 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include - -class BatchView : public wxScrolledWindow -{ -public: - BatchView (wxWindow *); - -private: - wxPanel* _panel; - wxFlexGridSizer* _table; -}; diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index f7d2315cc..53be88ca7 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -34,15 +34,21 @@ using std::map; using boost::shared_ptr; /** Must be called in the GUI thread */ -JobManagerView::JobManagerView (wxWindow* parent) +JobManagerView::JobManagerView (wxWindow* parent, Buttons buttons) : wxScrolledWindow (parent) + , _buttons (buttons) { _panel = new wxPanel (this); wxSizer* sizer = new wxBoxSizer (wxVERTICAL); sizer->Add (_panel, 1, wxEXPAND); SetSizer (sizer); + + int N = 5; + if (buttons & PAUSE) { + ++N; + } - _table = new wxFlexGridSizer (5, 6, 6); + _table = new wxFlexGridSizer (N, 6, 6); _table->AddGrowableCol (1, 1); _panel->SetSizer (_table); @@ -78,21 +84,33 @@ JobManagerView::update () _table->Insert (index, m, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); JobRecord r; + int n = 1; r.finalised = false; r.gauge = new wxGauge (_panel, wxID_ANY, 100); - _table->Insert (index + 1, r.gauge, 1, wxEXPAND | wxLEFT | wxRIGHT); + _table->Insert (index + n, r.gauge, 1, wxEXPAND | wxLEFT | wxRIGHT); + ++n; r.message = new wxStaticText (_panel, wxID_ANY, std_to_wx ("")); - _table->Insert (index + 2, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + _table->Insert (index + n, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + ++n; r.cancel = new wxButton (_panel, wxID_ANY, _("Cancel")); r.cancel->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::cancel_clicked), 0, this); - _table->Insert (index + 3, r.cancel, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); - + _table->Insert (index + n, r.cancel, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + ++n; + + if (_buttons & PAUSE) { + r.pause = new wxButton (_panel, wxID_ANY, _("Pause")); + r.pause->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::pause_clicked), 0, this); + _table->Insert (index + n, r.pause, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + ++n; + } + r.details = new wxButton (_panel, wxID_ANY, _("Details...")); r.details->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::details_clicked), 0, this); r.details->Enable (false); - _table->Insert (index + 4, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + _table->Insert (index + n, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + ++n; _job_records[*i] = r; } @@ -155,3 +173,21 @@ JobManagerView::cancel_clicked (wxCommandEvent& ev) } } } + +void +JobManagerView::pause_clicked (wxCommandEvent& ev) +{ + wxObject* o = ev.GetEventObject (); + for (map, JobRecord>::iterator i = _job_records.begin(); i != _job_records.end(); ++i) { + if (i->second.pause == o) { + if (i->first->paused()) { + i->first->resume (); + i->second.pause->SetLabel (_("Pause")); + } else { + i->first->pause (); + i->second.pause->SetLabel (_("Resume")); + } + } + } +} + diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h index 72ac85c02..fc29eadb4 100644 --- a/src/wx/job_manager_view.h +++ b/src/wx/job_manager_view.h @@ -33,13 +33,18 @@ class Job; class JobManagerView : public wxScrolledWindow { public: - JobManagerView (wxWindow *); + enum Buttons { + PAUSE = 0x1, + }; + + JobManagerView (wxWindow *, Buttons); void update (); private: void periodic (wxTimerEvent &); void cancel_clicked (wxCommandEvent &); + void pause_clicked (wxCommandEvent &); void details_clicked (wxCommandEvent &); boost::shared_ptr _timer; @@ -49,9 +54,11 @@ private: wxGauge* gauge; wxStaticText* message; wxButton* cancel; + wxButton* pause; wxButton* details; bool finalised; }; std::map, JobRecord> _job_records; + Buttons _buttons; }; diff --git a/src/wx/wscript b/src/wx/wscript index f1c3d1a6a..42bb8ca88 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -6,7 +6,6 @@ import i18n sources = """ audio_dialog.cc audio_plot.cc - batch_view.cc config_dialog.cc dci_metadata_dialog.cc dir_picker_ctrl.cc -- cgit v1.2.3 From 8747970bc94161787d84d00835282ba8d3dc1135 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 5 May 2013 12:36:09 +0100 Subject: Fix broken layout with pause button. --- src/wx/job_manager_view.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index 53be88ca7..5cd9f2e15 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -142,6 +142,9 @@ JobManagerView::update () } index += 5; + if (_buttons & PAUSE) { + ++index; + } } _table->Layout (); -- cgit v1.2.3 From d8d14ced78729f6f1bee8347bd0adc4e68a9f5f7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 6 May 2013 16:12:49 +0100 Subject: Fix resizing/redraw problems on Windows. --- src/wx/audio_dialog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 39650d157..d12b5516f 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -29,7 +29,7 @@ using boost::bind; using boost::optional; AudioDialog::AudioDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE) , _plot (0) { wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL); -- cgit v1.2.3