2017-09-23 14:38:43 +00:00
|
|
|
using System;
|
2017-11-11 23:38:48 +00:00
|
|
|
using System.Collections.Generic;
|
2017-09-23 14:38:43 +00:00
|
|
|
using System.Diagnostics;
|
2017-11-11 23:38:48 +00:00
|
|
|
using System.Text;
|
|
|
|
using DBus;
|
|
|
|
using MonoDevelop.Ide.Commands;
|
2017-09-23 14:38:43 +00:00
|
|
|
using MonoDevelop.Ide.Desktop;
|
|
|
|
|
|
|
|
namespace MonoDevelop.GtkSharp.Addin
|
|
|
|
{
|
|
|
|
public class GladeDesktopApplication : DesktopApplication
|
|
|
|
{
|
|
|
|
private readonly string _filename;
|
|
|
|
|
|
|
|
public GladeDesktopApplication(string filename) : base("GladeApp", "Glade", true)
|
|
|
|
{
|
|
|
|
_filename = filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Launch(params string[] files)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2017-11-11 23:38:48 +00:00
|
|
|
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
|
2017-09-23 14:38:43 +00:00
|
|
|
{
|
2017-11-11 23:38:48 +00:00
|
|
|
var bus = Bus.Session.GetObject<IFlatpak>("org.freedesktop.Flatpak", new ObjectPath("/org/freedesktop/Flatpak/Development"));
|
|
|
|
|
|
|
|
if (bus != null)
|
2017-09-23 14:38:43 +00:00
|
|
|
{
|
2017-11-11 23:38:48 +00:00
|
|
|
var pid = bus.HostCommand(
|
|
|
|
new byte[0],
|
|
|
|
new byte[][] {
|
|
|
|
Encoding.ASCII.GetBytes ("xdg-open\0"),
|
|
|
|
Encoding.ASCII.GetBytes (_filename + "\0")
|
|
|
|
},
|
|
|
|
new Dictionary<UInt32, UnixFD> { },
|
|
|
|
new Dictionary<string, string> { },
|
|
|
|
0
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
2017-09-23 14:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-11 23:38:48 +00:00
|
|
|
Process.Start(_filename);
|
2017-09-23 14:38:43 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Console.WriteLine(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|