correct msg in fatal error
[ardour.git] / gtk2_ardour / video_server_dialog.cc
index ce0633b6c3af382caafba860f3b8f932146d3a6c..de6af96f0463af4b011f9741f999a15eeec20723 100644 (file)
 #include "ardour/template_utils.h"
 #include "ardour/session.h"
 
+#ifdef PLATFORM_WINDOWS
+#include <windows.h>
+#include <shlobj.h> // CSIDL_*
+#include "pbd/windows_special_dirs.h"
+#endif
+
 #ifdef interface
 #undef interface
 #endif
 #include "utils_videotl.h"
 #include "i18n.h"
 
-#ifdef SearchPath
-#undef SearchPath
+#ifdef PLATFORM_WINDOWS
+#include <windows.h>
 #endif
 
 using namespace Gtk;
 using namespace std;
 using namespace PBD;
 using namespace ARDOUR;
+using namespace VideoUtils;
 
 VideoServerDialog::VideoServerDialog (Session* s)
        : ArdourDialog (_("Launch Video Server"))
@@ -86,18 +93,43 @@ VideoServerDialog::VideoServerDialog (Session* s)
        listenaddr_combo.append_text("0.0.0.0");
        listenaddr_combo.set_active(0);
 
+#ifdef PLATFORM_WINDOWS
+       HKEY key;
+       DWORD size = PATH_MAX;
+       char tmp[PATH_MAX+1];
+       const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
+#endif
+
        std::string icsd_file_path;
-       if (find_file_in_search_path (PBD::SearchPath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
+       if (find_file (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
                path_entry.set_text(icsd_file_path);
        }
+#ifdef PLATFORM_WINDOWS
+       else if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\RSS\\harvid", 0, KEY_READ, &key))
+                       &&  (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
+                       )
+       {
+               path_entry.set_text(g_build_filename(Glib::locale_to_utf8(tmp).c_str(), "harvid.exe", 0));
+       }
+       else if (program_files && Glib::file_test(g_build_filename(program_files, "harvid", "harvid.exe", 0), Glib::FILE_TEST_EXISTS))
+       {
+               path_entry.set_text(g_build_filename(program_files, "harvid", "harvid.exe", 0));
+       }
+#endif
+       /* generic fallbacks to try */
        else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) {
                path_entry.set_text(X_("C:\\Program Files\\harvid\\harvid.exe"));
        }
        else {
                PBD::warning <<
                        string_compose(
-                       _("The external video server 'harvid' can not be found. The tool is included with the %1 releases from ardour.org, "
-                         "alternatively you can download it from http://x42.github.com/harvid/ or acquire it from your distribution."), PROGRAM_NAME)
+                                       _("The external video server 'harvid' can not be found.\n"
+                                               "The tool is included with the %1 releases from ardour.org, "
+                                               "alternatively you can download it from http://x42.github.com/harvid/ "
+                                               "or acquire it from your distribution.\n"
+                                               "\n"
+                                               "see also http://manual.ardour.org/video-timeline/setup/"
+                                        ), PROGRAM_NAME)
                        << endmsg;
        }
 
@@ -140,7 +172,7 @@ VideoServerDialog::VideoServerDialog (Session* s)
        t->attach (cachesize_spinner, 1, 2, 2, 3);
 
        l = manage (new Label (string_compose(
-                                       _("%1 relies on an external Video Server for the videotimeline.\nThe server configured in Edit -> Prefereces -> Video is not reachable.\nDo you want ardour to launch 'harvid' on this machine?"), PROGRAM_NAME)
+                                       _("%1 relies on an external video server for the videotimeline.\nThe server configured in Edit -> Preferences -> Video is not reachable.\nDo you want %1 to launch 'harvid' on this machine?"), PROGRAM_NAME)
                                , Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
        l->set_max_width_chars(80);
        l->set_line_wrap();