Fix servomatic_gui start-up on Linux (#98).
authorCarl Hetherington <cth@carlh.net>
Sun, 7 Apr 2013 15:22:04 +0000 (16:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 7 Apr 2013 15:22:04 +0000 (16:22 +0100)
icons/taskbar_icon.png [new file with mode: 0644]
src/tools/servomatic_gui.cc
wscript

diff --git a/icons/taskbar_icon.png b/icons/taskbar_icon.png
new file mode 100644 (file)
index 0000000..fd6b6e9
Binary files /dev/null and b/icons/taskbar_icon.png differ
index dd169725f988f7f96669afd03378145702390542..52ec0a3a326339d7bb02bda0103f365834407099 100644 (file)
@@ -94,7 +94,15 @@ class TaskBarIcon : public wxTaskBarIcon
 public:
        TaskBarIcon ()
        {
+#ifdef __WXMSW__               
                wxIcon icon (std_to_wx ("taskbar_icon"));
+#endif
+#ifdef __WXGTK__
+               wxInitAllImageHandlers();
+               wxBitmap bitmap (wxString::Format ("%s/taskbar_icon.png", POSIX_ICON_PREFIX), wxBITMAP_TYPE_PNG);
+               wxIcon icon;
+               icon.CopyFromBitmap (bitmap);
+#endif         
                SetIcon (icon, std_to_wx ("DVD-o-matic encode server"));
 
                Connect (ID_status, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (TaskBarIcon::status));
@@ -128,20 +136,31 @@ public:
        App ()
                : wxApp ()
                , _thread (0)
+               , _icon (0)
        {}
 
 private:       
        
        bool OnInit ()
        {
+               if (!wxApp::OnInit ()) {
+                       return false;
+               }
+               
                dvdomatic_setup ();
 
-               new TaskBarIcon;
-
+               _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);
@@ -149,6 +168,7 @@ private:
        }
 
        boost::thread* _thread;
+       TaskBarIcon* _icon;
 };
 
 IMPLEMENT_APP (App)
diff --git a/wscript b/wscript
index 7ee3899e7097f33604a216eb9690c44d809953ab..f7c6964335052cc10eed37819899d86dcbefd0a2 100644 (file)
--- a/wscript
+++ b/wscript
@@ -37,6 +37,7 @@ def configure(conf):
     else:
         conf.env.append_value('CXXFLAGS', '-DDVDOMATIC_POSIX')
         conf.env.append_value('CXXFLAGS', '-DPOSIX_LOCALE_PREFIX="%s/share/locale"' % conf.env['PREFIX'])
+        conf.env.append_value('CXXFLAGS', '-DPOSIX_ICON_PREFIX="%s/share/dvdomatic"' % conf.env['PREFIX'])
         boost_lib_suffix = ''
         boost_thread = 'boost_thread'
         conf.env.append_value('LINKFLAGS', '-pthread')
@@ -231,6 +232,9 @@ def build(bld):
     for r in ['22x22', '32x32', '48x48', '64x64', '128x128']:
         bld.install_files('${PREFIX}/share/icons/hicolor/%s/apps' % r, 'icons/%s/dvdomatic.png' % r)
 
+    if not bld.env.TARGET_WINDOWS:
+        bld.install_files('${PREFIX}/share/dvdomatic', 'icons/taskbar_icon.png')
+
     bld.add_post_fun(post)
 
 def dist(ctx):