enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / video_server_dialog.cc
index 6d9bb229781532b044cf6bdd503f326d5f3db4ef..29872fc975b7d2886f20e11ac9218a793199fd1e 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 "video_server_dialog.h"
 #include "utils_videotl.h"
-#include "i18n.h"
+#include "video_tool_paths.h"
+#include "pbd/i18n.h"
 
 #ifdef PLATFORM_WINDOWS
 #include <windows.h>
@@ -79,13 +74,10 @@ VideoServerDialog::VideoServerDialog (Session* s)
        HBox* docroot_hbox = manage (new HBox);
 
        path_entry.set_width_chars(38);
-       path_browse_button.set_name ("PaddedButton");
        path_entry.set_text("/usr/bin/harvid");
        docroot_entry.set_width_chars(38);
        docroot_entry.set_text(Config->get_video_server_docroot());
-       docroot_browse_button.set_name ("PaddedButton");
 
-       listenaddr_combo.set_name ("PaddedButton");
 #ifndef __APPLE__
        /* Note: on OSX icsd is not able to bind to IPv4 localhost */
        listenaddr_combo.append_text("127.0.0.1");
@@ -93,42 +85,22 @@ 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)) {
-               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 {
+       std::string harvid_exe;
+       if (ArdourVideoToolPaths::harvid_exe(harvid_exe)) {
+               path_entry.set_text(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;
        }
 
-
        if (docroot_entry.get_text().empty()) {
          std::string docroot =  Glib::path_get_dirname(_session->session_directory().root_path());
          if ((docroot.empty() || docroot.at(docroot.length()-1) != '/')) { docroot += "/"; }
@@ -176,7 +148,11 @@ VideoServerDialog::VideoServerDialog (Session* s)
        if (Config->get_video_advanced_setup()){
                vbox->pack_start (*docroot_hbox, false, false);
        } else {
+#ifndef PLATFORM_WINDOWS
                docroot_entry.set_text(X_("/"));
+#else
+               docroot_entry.set_text(X_("C:\\"));
+#endif
                listenport_spinner.set_sensitive(false);
        }
        vbox->pack_start (*options_box, false, true);