File: GladeDesktopApplication.cs

package info (click to toggle)
gnome-subtitles 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 103,144 kB
  • sloc: xml: 406,395; cs: 364,495; ansic: 3,104; perl: 1,477; sh: 769; python: 545; javascript: 500; makefile: 49
file content (65 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
using MonoDevelop.Ide.Desktop;

namespace MonoDevelop.GtkSharp.Addin
{
    public class GladeDesktopApplication : DesktopApplication
    {
        private static readonly string s_unixgladeapp;

        static GladeDesktopApplication()
        {
            try
            {
                var assembly = typeof(GladeDesktopApplication).Assembly.Location;
                var gladesh = Path.Combine(Path.GetDirectoryName(assembly), "glade.sh");

                s_unixgladeapp = "-c '" + File.ReadAllText(gladesh) + "'";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

        private readonly string _filename;

        public GladeDesktopApplication(string filename) : base("GladeApp", "Glade", true)
        {
            _filename = filename;
        }

        public override void Launch(params string[] files)
        {
            try
            {
                var process = new Process();

                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    var location = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\GNOME Foundation Glade Interface Designer", "InstallLocation", "");
                    if (location != null)
                    {
                        process.StartInfo.FileName = Path.Combine(location.ToString(), "bin", "glade.exe");
                        process.StartInfo.Arguments = _filename;
                    }
                }
                else
                {
                    process.StartInfo.FileName = "bash";
                    process.StartInfo.Arguments = s_unixgladeapp.Replace("$@", _filename);
                }

                if (!string.IsNullOrEmpty(process.StartInfo.FileName))
                    process.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}