Ejemplo n.º 1
0
        /// <summary>
        /// Return the root directory to search under for translations, documentation, etc.
        /// </summary>
        public static string GetDataRootDirectory()
        {
            string app_dir = SystemManager.GetExecutableDirectory();

            // If Pinta is located at $prefix/lib/pinta, we want to use $prefix/share.
            if (GetOperatingSystem() == OS.X11)
            {
                var lib_dir = Directory.GetParent(app_dir);
                if (lib_dir?.Name == "lib")
                {
                    var prefix = lib_dir.Parent;
                    if (prefix is not null)
                    {
                        return(Path.Combine(prefix.FullName, "share"));
                    }
                }
            }

            // If Pinta is in Pinta.app/Contents/MacOS, we want Pinta.app/Contents/Resources/share.
            if (GetOperatingSystem() == OS.Mac && IsExecutableInMacBundle())
            {
                var contents_dir = Directory.GetParent(app_dir);
                return(Path.Combine(contents_dir !.FullName, "Resources", "share"));
            }

            // Otherwise, translations etc are contained under the executable's folder.
            return(app_dir);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if Pinta is executing in a .app bundle (macOS).
        /// This requires some differents paths to locate resources, GTK libraries, etc
        /// </summary>
        public static bool IsExecutableInMacBundle()
        {
            if (GetOperatingSystem() != OS.Mac)
            {
                return(false);
            }

            string app_dir = SystemManager.GetExecutableDirectory();

            // For a bundle, the executable would be Pinta.app/Contents/MacOS/Pinta
            var contents_dir = Directory.GetParent(app_dir);

            return(contents_dir?.Name == "Contents");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return the root directory to search under for translations, documentation, etc.
        /// </summary>
        public static string GetDataRootDirectory()
        {
            string app_dir    = SystemManager.GetExecutableDirectory();
            bool   devel_mode = File.Exists(Path.Combine(Path.Combine(app_dir, ".."), "Pinta.sln"));

            if (GetOperatingSystem() != OS.X11 || devel_mode)
            {
                return(app_dir);
            }
            else
            {
                // From MonoDevelop:
                // Pinta is located at $prefix/lib/pinta
                // adding "../.." should give us $prefix
                string prefix = Path.Combine(Path.Combine(app_dir, ".."), "..");
                //normalise it
                prefix = Path.GetFullPath(prefix);
                return(Path.Combine(prefix, "share"));
            }
        }