DVD-o-matic -> DCP-o-matic.
[dcpomatic.git] / src / tools / servomatic_gui.cc
index 1d95f498a7fb4697baf47e2a85771ea2cb0f0d9f..152e063c1e59104b78d5f280bdfa0a3973e4b3df 100644 (file)
 #include "wx_util.h"
 #include "lib/util.h"
 #include "lib/server.h"
+#include "lib/config.h"
 
-using namespace std;
-using namespace boost;
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+using boost::thread;
+using boost::bind;
 
 enum {
        ID_status = 1,
@@ -51,19 +55,19 @@ private:
        string _log;    
 };
 
-static MemoryLog memory_log;
+static shared_ptr<MemoryLog> memory_log (new MemoryLog);
 
 class StatusDialog : public wxDialog
 {
 public:
        StatusDialog ()
-               : wxDialog (0, wxID_ANY, _("DVD-o-matic encode server"), wxDefaultPosition, wxSize (600, 40), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+               : wxDialog (0, wxID_ANY, _("DCP-o-matic encode server"), wxDefaultPosition, wxSize (600, 80), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
                , _timer (this, ID_timer)
        {
                _sizer = new wxFlexGridSizer (1, 6, 6);
                _sizer->AddGrowableCol (0, 1);
 
-               _text = new wxTextCtrl (this, wxID_ANY);
+               _text = new wxTextCtrl (this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
                _sizer->Add (_text, 1, wxEXPAND);
 
                SetSizer (_sizer);
@@ -76,7 +80,7 @@ public:
 private:
        void update (wxTimerEvent &)
        {
-               _text->ChangeValue (std_to_wx (memory_log.get ()));
+               _text->ChangeValue (std_to_wx (memory_log->get ()));
                _sizer->Layout ();
        }
 
@@ -90,8 +94,16 @@ class TaskBarIcon : public wxTaskBarIcon
 public:
        TaskBarIcon ()
        {
+#ifdef __WXMSW__               
                wxIcon icon (std_to_wx ("taskbar_icon"));
-               SetIcon (icon, std_to_wx ("DVD-o-matic encode server"));
+#endif
+#ifdef __WXGTK__
+               wxInitAllImageHandlers();
+               wxBitmap bitmap (wxString::Format (wxT ("%s/taskbar_icon.png"), POSIX_ICON_PREFIX), wxBITMAP_TYPE_PNG);
+               wxIcon icon;
+               icon.CopyFromBitmap (bitmap);
+#endif         
+               SetIcon (icon, std_to_wx ("DCP-o-matic encode server"));
 
                Connect (ID_status, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::status));
                Connect (ID_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::quit));
@@ -124,27 +136,39 @@ public:
        App ()
                : wxApp ()
                , _thread (0)
+               , _icon (0)
        {}
 
 private:       
        
        bool OnInit ()
        {
-               dvdomatic_setup ();
-
-               new TaskBarIcon;
+               if (!wxApp::OnInit ()) {
+                       return false;
+               }
+               
+               dcpomatic_setup ();
 
+               _icon = new TaskBarIcon;
                _thread = new thread (bind (&App::main_thread, this));
+               
                return true;
        }
 
+       int OnExit ()
+       {
+               delete _icon;
+               return wxApp::OnExit ();
+       }
+
        void main_thread ()
        {
-               Server server (&memory_log);
-               server.run ();
+               Server server (memory_log);
+               server.run (Config::instance()->num_local_encoding_threads ());
        }
 
        boost::thread* _thread;
+       TaskBarIcon* _icon;
 };
 
 IMPLEMENT_APP (App)