diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-09 15:14:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-09 15:14:08 +0100 |
| commit | 92cafb6fc686a041354da2eabde6bcb2f6846e1d (patch) | |
| tree | cdc26dde96d8c9ed1e9c60056a404ca3df2dcfac /src | |
| parent | fd040c2bd27fde35424a384174ecb56c643764cd (diff) | |
| parent | 6e5c4e570f26e05124ab0ef67e39c07bab9cb4d5 (diff) | |
Merge master.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/job.cc | 28 | ||||
| -rw-r--r-- | src/lib/job.h | 4 | ||||
| -rw-r--r-- | src/lib/util.cc | 2 | ||||
| -rw-r--r-- | src/lib/util.h | 2 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 48 | ||||
| -rw-r--r-- | src/tools/wscript | 2 | ||||
| -rw-r--r-- | src/wx/job_manager_view.cc | 53 | ||||
| -rw-r--r-- | src/wx/job_manager_view.h | 9 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 40 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 1 |
10 files changed, 131 insertions, 58 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index 812380594..2e6385d62 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -26,6 +26,7 @@ #include <libdcp/exceptions.h> #include "job.h" #include "util.h" +#include "cross.h" #include "i18n.h" @@ -153,6 +154,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. */ @@ -188,6 +196,10 @@ Job::set_progress (float p) _progress_unknown = false; _stack.back().normalised = p; boost::this_thread::interruption_point (); + + if (paused ()) { + dcpomatic_sleep (1); + } } /** @return fractional overall progress, or -1 if not known */ @@ -324,3 +336,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 2119db2f3..40e90b73c 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/lib/util.cc b/src/lib/util.cc index ec1fd47bd..6c8166143 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -280,7 +280,7 @@ mo_path () #endif void -dcpomatic_setup_i18n (string lang) +dcpomatic_setup_gettext_i18n (string lang) { #ifdef DCPOMATIC_POSIX lang += ".UTF8"; diff --git a/src/lib/util.h b/src/lib/util.h index 0edfe2076..51ccbba99 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -56,7 +56,7 @@ extern void stacktrace (std::ostream &, int); extern std::string dependency_version_summary (); extern double seconds (struct timeval); extern void dcpomatic_setup (); -extern void dcpomatic_setup_i18n (std::string); +extern void dcpomatic_setup_gettext_i18n (std::string); extern std::vector<std::string> split_at_spaces_considering_quotes (std::string); extern std::string md5_digest (boost::filesystem::path); extern std::string md5_digest (void const *, int); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 4312139f1..71c29072f 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -63,7 +63,6 @@ static std::string log_level; static std::string film_to_load; static std::string film_to_create; static wxMenu* jobs_menu = 0; -static wxLocale* locale = 0; static void set_menu_sensitivity (); @@ -226,7 +225,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<JobManagerView::Buttons> (0)); _top_sizer = new wxBoxSizer (wxHORIZONTAL); _top_sizer->Add (film_editor, 0, wxALL, 6); @@ -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<string> 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 DCPOMATIC_WINDOWS - locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); -#endif - - locale->AddCatalog (wxT ("libdcpomatic-wx")); - locale->AddCatalog (wxT ("dcpomatic")); - - if (!locale->IsOk()) { - f << "Locale is not ok.\n"; - delete locale; - locale = new wxLocale (wxLANGUAGE_ENGLISH); - language = wxLANGUAGE_ENGLISH; - } - } - - if (locale) { - dcpomatic_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 (); + dcpomatic_setup_i18n (); /* Set things up, including scalers / filters etc. which will now be internationalised correctly. diff --git a/src/tools/wscript b/src/tools/wscript index 466f29031..cddd07b7d 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 ['dcpomatic', 'dcpomatic_server']: + for t in ['dcpomatic', 'dcpomatic_batch', 'dcpomatic_server']: obj = bld(features = 'cxx cxxprogram') obj.uselib = 'DCP CXML OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC' obj.includes = ['..'] diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index c339d26bb..1594dfc91 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,22 +84,34 @@ JobManagerView::update () _table->Insert (index, m, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); JobRecord r; + int n = 1; r.finalised = false; r.scroll_nudged = 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; @@ -143,6 +161,9 @@ JobManagerView::update () } index += 5; + if (_buttons & PAUSE) { + ++index; + } } _table->Layout (); @@ -174,3 +195,21 @@ JobManagerView::cancel_clicked (wxCommandEvent& ev) } } } + +void +JobManagerView::pause_clicked (wxCommandEvent& ev) +{ + wxObject* o = ev.GetEventObject (); + for (map<boost::shared_ptr<Job>, 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 6343d78af..3d1ad30c0 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<wxTimer> _timer; @@ -49,10 +54,12 @@ private: wxGauge* gauge; wxStaticText* message; wxButton* cancel; + wxButton* pause; wxButton* details; bool finalised; bool scroll_nudged; }; std::map<boost::shared_ptr<Job>, JobRecord> _job_records; + Buttons _buttons; }; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index e0d7d843f..5691d341a 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -25,6 +25,8 @@ #include <wx/filepicker.h> #include <wx/spinctrl.h> #include "wx_util.h" +#include "config.h" +#include "util.h" using namespace std; using namespace boost; @@ -66,7 +68,7 @@ error_dialog (wxWindow* parent, wxString m) bool confirm_dialog (wxWindow* parent, wxString m) { - wxMessageDialog* d = new wxMessageDialog (parent, m, _("DVD-o-matic"), wxYES_NO | wxICON_QUESTION); + wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); int const r = d->ShowModal (); d->Destroy (); return r == wxID_YES; @@ -211,3 +213,39 @@ checked_set (wxRadioButton* widget, bool value) widget->SetValue (value); } } + +void +dcpomatic_setup_i18n () +{ + int language = wxLANGUAGE_DEFAULT; + + boost::optional<string> 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 DCPOMATIC_WINDOWS + locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); +#endif + + locale->AddCatalog (wxT ("libdcpomatic-wx")); + locale->AddCatalog (wxT ("dcpomatic")); + + if (!locale->IsOk()) { + delete locale; + locale = new wxLocale (wxLANGUAGE_ENGLISH); + language = wxLANGUAGE_ENGLISH; + } + } + + if (locale) { + dcpomatic_setup_gettext_i18n (wx_to_std (locale->GetCanonicalName ())); + } +} diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index b3ab706df..bff11647e 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 dcpomatic_setup_i18n (); /** @class ThreadedStaticText * |
