Template and addin updates

This commit is contained in:
cra0zy 2017-11-12 00:38:48 +01:00
parent a09f751b10
commit 163c94354a
14 changed files with 95 additions and 257 deletions

View file

@ -1,30 +1,15 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.Text;
using Microsoft.Win32; using DBus;
using MonoDevelop.Ide.Commands;
using MonoDevelop.Ide.Desktop; using MonoDevelop.Ide.Desktop;
namespace MonoDevelop.GtkSharp.Addin namespace MonoDevelop.GtkSharp.Addin
{ {
public class GladeDesktopApplication : DesktopApplication 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; private readonly string _filename;
public GladeDesktopApplication(string filename) : base("GladeApp", "Glade", true) public GladeDesktopApplication(string filename) : base("GladeApp", "Glade", true)
@ -36,25 +21,28 @@ namespace MonoDevelop.GtkSharp.Addin
{ {
try try
{ {
var process = new Process(); if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
var bus = Bus.Session.GetObject<IFlatpak>("org.freedesktop.Flatpak", new ObjectPath("/org/freedesktop/Flatpak/Development"));
if (Environment.OSVersion.Platform == PlatformID.Win32NT) if (bus != null)
{ {
var location = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\GNOME Foundation Glade Interface Designer", "InstallLocation", ""); var pid = bus.HostCommand(
if (location != null) new byte[0],
{ new byte[][] {
process.StartInfo.FileName = Path.Combine(location.ToString(), "bin", "glade.exe"); Encoding.ASCII.GetBytes ("xdg-open\0"),
process.StartInfo.Arguments = _filename; Encoding.ASCII.GetBytes (_filename + "\0")
},
new Dictionary<UInt32, UnixFD> { },
new Dictionary<string, string> { },
0
);
return;
} }
} }
else
{
process.StartInfo.FileName = "bash";
process.StartInfo.Arguments = s_unixgladeapp.Replace("$@", _filename);
}
if (!string.IsNullOrEmpty(process.StartInfo.FileName)) Process.Start(_filename);
process.Start();
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\MonoDevelop.Addins.0.4.1\build\MonoDevelop.Addins.props" Condition="Exists('packages\MonoDevelop.Addins.0.4.1\build\MonoDevelop.Addins.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -36,19 +37,6 @@
<EmbeddedResource Include="Properties\Manifest.addin.xml" /> <EmbeddedResource Include="Properties\Manifest.addin.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" />
<None Include="Templates\Projects\GtkSharpProject.CS.xpt.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\Data\Program.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\Data\MainWindow.glade">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\Data\MainWindow.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\File\Window.CS.xft.xml"> <None Include="Templates\File\Window.CS.xft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
@ -76,21 +64,25 @@
<None Include="Templates\File\Widget.CS.xft.xml"> <None Include="Templates\File\Widget.CS.xft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Templates\Projects\GtkSharpProject.FS.xpt.xml"> <None Include="packages.config" />
<None Include="Templates\GtkSharp.Template.CSharp.nupkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="glade.sh"> <None Include="Templates\GtkSharp.Template.VBNet.nupkg">
<LogicalName>glade.sh</LogicalName>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Templates\" /> <Folder Include="Templates\" />
<Folder Include="Templates\Projects\" />
<Folder Include="Templates\Projects\Data\" />
<Folder Include="Templates\File\" /> <Folder Include="Templates\File\" />
<Folder Include="Templates\File\Data\" /> <Folder Include="Templates\File\Data\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="dbus-sharp">
<HintPath>References\dbus-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets')" /> <Import Project="..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets')" />
<Import Project="packages\MonoDevelop.Addins.0.4.1\build\MonoDevelop.Addins.targets" Condition="Exists('packages\MonoDevelop.Addins.0.4.1\build\MonoDevelop.Addins.targets')" />
</Project> </Project>

View file

@ -0,0 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GtkSharp.Addin", "MonoDevelop.GtkSharp.Addin.csproj", "{52AC8491-F6B7-4631-92BA-D5E95A091B74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52AC8491-F6B7-4631-92BA-D5E95A091B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52AC8491-F6B7-4631-92BA-D5E95A091B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52AC8491-F6B7-4631-92BA-D5E95A091B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52AC8491-F6B7-4631-92BA-D5E95A091B74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -7,4 +7,8 @@ using Mono.Addins.Description;
[assembly: AddinCategory("IDE extensions")] [assembly: AddinCategory("IDE extensions")]
[assembly: AddinDescription("Provides modern Gtk# file / project templates and glade file integration.")] [assembly: AddinDescription("Provides modern Gtk# file / project templates and glade file integration.")]
[assembly: AddinAuthor("cra0zy")] [assembly: AddinAuthor("cra0zy")]
[assembly: AddinUrl("https://github.com/gtk-sharp/gtk-sharp")] [assembly: AddinUrl("https://github.com/GtkSharp/GtkSharp")]
[assembly: AddinDependency("MonoDevelop.Core", MonoDevelop.BuildInfo.Version)]
[assembly: AddinDependency("MonoDevelop.Ide", MonoDevelop.BuildInfo.Version)]
[assembly: AddinDependency("MonoDevelop.DotNetCore", MonoDevelop.BuildInfo.Version)]

View file

@ -1,19 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ExtensionModel> <ExtensionModel>
<Dependencies>
<Addin id="MonoDevelop.Ide" version="7.1"/>
<Addin id="MonoDevelop.Core" version="7.1"/>
</Dependencies>
<Runtime> <Runtime>
<Import file="glade.sh" />
<!-- Project Templates --> <!-- Project Templates -->
<Import file="Templates/Projects/Data/MainWindow.cs" /> <Import file="Templates/GtkSharp.Template.CSharp.nupkg" />
<Import file="Templates/Projects/Data/MainWindow.glade" /> <Import file="Templates/GtkSharp.Template.VBNet.nupkg" />
<Import file="Templates/Projects/Data/Program.cs" />
<Import file="Templates/Projects/GtkSharpProject.CS.xpt.xml" />
<Import file="Templates/Projects/GtkSharpProject.FS.xpt.xml" />
<!-- File Templates --> <!-- File Templates -->
<Import file="Templates/File/Data/Dialog.cs" /> <Import file="Templates/File/Data/Dialog.cs" />
@ -35,14 +25,26 @@
</Extension> </Extension>
<Extension path="/MonoDevelop/Ide/ProjectTemplateCategories/multiplat/app"> <Extension path="/MonoDevelop/Ide/ProjectTemplateCategories/multiplat/app">
<Category id="gtk" name="Gtk#" /> <Category id="gtk" name="Gtk" />
</Extension> </Extension>
<Extension path="/MonoDevelop/Ide/ProjectTemplates"> <Extension path="/MonoDevelop/Ide/Templates">
<ProjectTemplate id="gtk-cs-project" file="Templates/Projects/GtkSharpProject.CS.xpt.xml" /> <Template
id="GtkSharp.Application.CSharp"
<!-- TODO: Implement fsharp template --> _overrideDescription="Creates a new Gtk multiplatform application."
<!--ProjectTemplate id="gtk-fs-project" file="Templates/Projects/GtkSharpProject.FS.xpt.xml" /--> path="Templates/GtkSharp.Template.CSharp.nupkg"
category="multiplat/app/gtk"
icon="md-gui-project"
imageId="md-gui-project"
defaultParameters="targetframework=net471" />
<Template
id="GtkSharp.Application.VBNet"
_overrideDescription="Creates a new Gtk multiplatform application."
path="Templates/GtkSharp.Template.VBNet.nupkg"
category="multiplat/app/gtk"
icon="md-gui-project"
imageId="md-gui-project"
defaultParameters="targetframework=net471" />
</Extension> </Extension>
<Extension path="/MonoDevelop/Ide/FileTemplates"> <Extension path="/MonoDevelop/Ide/FileTemplates">

View file

@ -1,37 +0,0 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace ${Namespace}
{
class MainWindow : Window
{
#pragma warning disable 0649
[UI] private Label _label1;
[UI] private Button _button1;
#pragma warning restore 0649
private int _counter;
public MainWindow() : this(new Builder("${Namespace}.MainWindow.glade")) { }
private MainWindow(Builder builder) : base(builder.GetObject("MainWindow").Handle)
{
builder.Autoconnect(this);
DeleteEvent += OnDeleteEvent;
_button1.Clicked += Button1_Clicked;
}
private void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
}
private void Button1_Clicked(object sender, EventArgs a)
{
_counter++;
_label1.Text = "Hello World! This button has been clicked " + _counter + " time(s).";
}
}
}

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="MainWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Example Window</property>
<property name="default_width">480</property>
<property name="default_height">240</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hello World!</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="_button1">
<property name="label" translatable="yes">Click me!</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -1,23 +0,0 @@
using System;
using Gtk;
namespace ${Namespace}
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
Application.Init();
var app = new Application("org.gnome.example", GLib.ApplicationFlags.None);
app.Register(GLib.Cancellable.Current);
var win = new MainWindow();
app.AddWindow(win);
win.Show();
Application.Run();
}
}
}

View file

@ -1,35 +0,0 @@
<?xml version="1.0"?>
<Template>
<TemplateConfiguration>
<_Name>Gtk# Application</_Name>
<Icon>md-gui-project</Icon>
<_Category>multiplat/app/gtk</_Category>
<LanguageName>C#</LanguageName>
<Image id="md-gui-project" />
<_Description>Creates a new Gtk# multiplatform application.</_Description>
<GroupId>gtk-project</GroupId>
</TemplateConfiguration>
<Actions>
<Open filename="MainWindow.cs" />
</Actions>
<Combine name="${ProjectName}" directory=".">
<Options>
<StartupProject>${ProjectName}</StartupProject>
</Options>
<Project name="${ProjectName}" directory=".">
<Options Target = "WinExe"/>
<References>
<Reference type="Gac" refto="System" />
</References>
<Packages>
<package id="gtk-sharp3" />
</Packages>
<Files>
<File name="Program.cs" src="Data/Program.cs" />
<File name="MainWindow.glade" src="Data/MainWindow.glade" BuildAction="EmbeddedResource" ResourceId="MainWindow.glade" />
<File name="MainWindow.cs" src="Data/MainWindow.cs" DependsOn="MainWindow.glade" />
<FileTemplateReference TemplateID="CSharpAssemblyInfo" name="AssemblyInfo.cs" />
</Files>
</Project>
</Combine>
</Template>

View file

@ -1,32 +0,0 @@
<?xml version="1.0"?>
<Template>
<TemplateConfiguration>
<_Name>Gtk# Application</_Name>
<Icon>md-gui-project</Icon>
<_Category>multiplat/app/gtk</_Category>
<LanguageName>F#</LanguageName>
<Image id="md-gui-project" />
<_Description>Creates a new Gtk# multiplatform application.</_Description>
<GroupId>gtk-project</GroupId>
</TemplateConfiguration>
<Actions>
<Open filename="MainWindow.cs" />
</Actions>
<Combine name="${ProjectName}" directory=".">
<Options>
<StartupProject>${ProjectName}</StartupProject>
</Options>
<Project name="${ProjectName}" directory=".">
<Options Target = "WinExe"/>
<References>
<Reference type="Gac" refto="System" />
</References>
<Packages>
<package id="gtk-sharp3" />
</Packages>
<Files>
<FileTemplateReference TemplateID="FSharpAssemblyInfo" name="AssemblyInfo.cs" />
</Files>
</Project>
</Combine>
</Template>

View file

@ -1,6 +0,0 @@
#!/bin/bash
if [ -x "$(which glade)" ]; then
glade "$@"
elif [ -x "$(which flatpak)" ] && [ ! -z "$(flatpak list | grep org.gnome.Glade)" ]; then
flatpak run org.gnome.Glade "$@"
fi

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MonoDevelop.Addins" version="0.3.3" targetFramework="net45" /> <package id="MonoDevelop.Addins" version="0.4.1" targetFramework="net45" />
</packages> </packages>

View file

@ -14,5 +14,12 @@
"type": "project" "type": "project"
}, },
"sourceName": "GtkNamespace", "sourceName": "GtkNamespace",
"preferNameDirectory": true "preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"defaultValue": "netcoreapp2.0",
"replaces": "netcoreapp2.0"
}
}
} }

View file

@ -14,5 +14,12 @@
"type": "project" "type": "project"
}, },
"sourceName": "GtkNamespace", "sourceName": "GtkNamespace",
"preferNameDirectory": true "preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"defaultValue": "netcoreapp2.0",
"replaces": "netcoreapp2.0"
}
}
} }