Basics of a tray-iconned GUI server.
authorCarl Hetherington <cth@carlh.net>
Mon, 17 Sep 2012 23:21:09 +0000 (00:21 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 17 Sep 2012 23:21:09 +0000 (00:21 +0100)
icons/16x16/dvdomatic.png [new file with mode: 0644]
run/servomatic [deleted file]
run/servomatic_cli [new file with mode: 0755]
run/servomatic_gui [new file with mode: 0755]
src/tools/servomatic_gui.cc [new file with mode: 0644]
src/tools/wscript
windows/dvdomatic.rc
windows/dvdomatic_taskbar.ico [new file with mode: 0644]
windows/installer.nsi.in

diff --git a/icons/16x16/dvdomatic.png b/icons/16x16/dvdomatic.png
new file mode 100644 (file)
index 0000000..3c5a10f
Binary files /dev/null and b/icons/16x16/dvdomatic.png differ
diff --git a/run/servomatic b/run/servomatic
deleted file mode 100755 (executable)
index 100d0a8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-export LD_LIBRARY_PATH=build/src/lib:$LD_LIBRARY_PATH
-if [ "$1" == "--debug" ]; then
-    gdb --args build/src/tools/servomatic
-elif [ "$1" == "--valgrind" ]; then
-    valgrind --tool="memcheck" build/src/tools/servomatic
-else
-    build/src/tools/servomatic
-fi
diff --git a/run/servomatic_cli b/run/servomatic_cli
new file mode 100755 (executable)
index 0000000..3dd67d2
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src/lib:$LD_LIBRARY_PATH
+if [ "$1" == "--debug" ]; then
+    gdb --args build/src/tools/servomatic_cli
+elif [ "$1" == "--valgrind" ]; then
+    valgrind --tool="memcheck" build/src/tools/servomatic_cli
+else
+    build/src/tools/servomatic_cli
+fi
diff --git a/run/servomatic_gui b/run/servomatic_gui
new file mode 100755 (executable)
index 0000000..4f1c617
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src/lib:$LD_LIBRARY_PATH
+if [ "$1" == "--debug" ]; then
+    gdb --args build/src/tools/servomatic_gui
+elif [ "$1" == "--valgrind" ]; then
+    valgrind --tool="memcheck" build/src/tools/servomatic_gui
+else
+    build/src/tools/servomatic_gui
+fi
diff --git a/src/tools/servomatic_gui.cc b/src/tools/servomatic_gui.cc
new file mode 100644 (file)
index 0000000..d89bd91
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+    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 <boost/thread.hpp>
+#include <wx/taskbar.h>
+#include <wx/icon.h>
+#include "wx_util.h"
+#include "lib/util.h"
+#include "lib/server.h"
+
+using namespace boost;
+
+enum {
+       ID_status = 1,
+       ID_quit
+};
+
+class StatusDialog : public wxDialog
+{
+public:
+       StatusDialog ()
+               : wxDialog (0, wxID_ANY, _("DVD-o-matic encode server"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
+       {
+               wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
+               table->AddGrowableCol (1, 1);
+
+               add_label_to_sizer (table, this, "Hello");
+
+               SetSizer (table);
+               table->Layout ();
+               table->SetSizeHints (this);
+       }
+};
+
+class TaskBarIcon : public wxTaskBarIcon
+{
+public:
+       TaskBarIcon ()
+       {
+               wxIcon icon (std_to_wx ("taskbar_icon"));
+               SetIcon (icon, std_to_wx ("DVD-o-matic encode server"));
+
+               Connect (ID_status, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::status));
+               Connect (ID_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::quit));
+       }
+       
+       wxMenu* CreatePopupMenu ()
+       {
+               wxMenu* menu = new wxMenu;
+               menu->Append (ID_status, std_to_wx ("Status..."));
+               menu->Append (ID_quit, std_to_wx ("Quit"));
+               return menu;
+       }
+
+private:
+       void status (wxCommandEvent &)
+       {
+               StatusDialog* d = new StatusDialog;
+               d->Show ();
+       }
+
+       void quit (wxCommandEvent &)
+       {
+               wxTheApp->ExitMainLoop ();
+       }
+};
+
+class App : public wxApp
+{
+public:
+       App ()
+               : wxApp ()
+               , _thread (0)
+       {}
+
+private:       
+       
+       bool OnInit ()
+       {
+               dvdomatic_setup ();
+
+               new TaskBarIcon;
+
+               _thread = new thread (bind (&App::main_thread, this));
+               return true;
+       }
+
+       void main_thread ()
+       {
+               Server server;
+               server.run ();
+       }
+
+       boost::thread* _thread;
+};
+
+IMPLEMENT_APP (App)
index ff7134d15ee96aa86fad62e77fc90e018632840f..048bdff076ec1dcec97f366d63bcdba15e957ac2 100644 (file)
@@ -9,7 +9,7 @@ def build(bld):
 
     if not bld.env.DISABLE_GUI:
 #        p = ['dvdomatic', 'alignomatic']
-        p = ['dvdomatic']
+        p = ['dvdomatic', 'servomatic_gui']
         if not bld.env.DISABLE_PLAYER:
             p.append('playomatic')
         for t in p:
index e6ce66597029e20b4a248af61b4ed17d7965da02..97bfac229fcbbf8c5ebbac02ef3096f75b639879 100644 (file)
@@ -1,2 +1,3 @@
-#include "wx-2.8/wx/msw/wx.rc"
 id ICON "dvdomatic.ico"
+taskbar_icon ICON "dvdomatic_taskbar.ico"
+#include "wx-2.8/wx/msw/wx.rc"
diff --git a/windows/dvdomatic_taskbar.ico b/windows/dvdomatic_taskbar.ico
new file mode 100644 (file)
index 0000000..f4489fa
Binary files /dev/null and b/windows/dvdomatic_taskbar.ico differ
index d342587993ff93bf88c907d5742d6b1859411bf9..3fb2ae4579bbb5eaada17f8e13e8795736ff459c 100644 (file)
@@ -84,7 +84,8 @@ File "%deps%/bin/libxml2-2.dll"
 File "%binaries%/src/wx/dvdomatic-wx.dll"
 File "%binaries%/src/lib/dvdomatic.dll"
 File "%binaries%/src/tools/dvdomatic.exe"
-File "%binaries%/src/tools/servomatic.exe"
+File "%binaries%/src/tools/servomatic_cli.exe"
+File "%binaries%/src/tools/servomatic_gui.exe"
 
 CreateShortCut "$DESKTOP\DVD-o-matic.lnk" "$INSTDIR\bin\dvdomatic.exe" ""