2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/thread.hpp>
21 #include <wx/taskbar.h>
25 #include "lib/server.h"
28 using namespace boost;
36 class MemoryLog : public Log
41 boost::mutex::scoped_lock (_mutex);
46 void do_log (string m)
54 static MemoryLog memory_log;
56 class StatusDialog : public wxDialog
60 : wxDialog (0, wxID_ANY, _("DVD-o-matic encode server"), wxDefaultPosition, wxSize (600, 40), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
61 , _timer (this, ID_timer)
63 _sizer = new wxFlexGridSizer (1, 6, 6);
64 _sizer->AddGrowableCol (0, 1);
66 _text = new wxTextCtrl (this, wxID_ANY);
67 _sizer->Add (_text, 1, wxEXPAND);
72 Connect (ID_timer, wxEVT_TIMER, wxTimerEventHandler (StatusDialog::update));
77 void update (wxTimerEvent &)
79 _text->ChangeValue (std_to_wx (memory_log.get ()));
83 wxFlexGridSizer* _sizer;
88 class TaskBarIcon : public wxTaskBarIcon
93 wxIcon icon (std_to_wx ("taskbar_icon"));
94 SetIcon (icon, std_to_wx ("DVD-o-matic encode server"));
96 Connect (ID_status, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::status));
97 Connect (ID_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::quit));
100 wxMenu* CreatePopupMenu ()
102 wxMenu* menu = new wxMenu;
103 menu->Append (ID_status, std_to_wx ("Status..."));
104 menu->Append (ID_quit, std_to_wx ("Quit"));
109 void status (wxCommandEvent &)
111 StatusDialog* d = new StatusDialog;
115 void quit (wxCommandEvent &)
117 wxTheApp->ExitMainLoop ();
121 class App : public wxApp
137 _thread = new thread (bind (&App::main_thread, this));
143 Server server (&memory_log);
147 boost::thread* _thread;