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.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
using System.Text;
using DBus;
using MonoDevelop.Ide.Commands;
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)
@ -36,25 +21,28 @@ namespace MonoDevelop.GtkSharp.Addin
{
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", "");
if (location != null)
{
process.StartInfo.FileName = Path.Combine(location.ToString(), "bin", "glade.exe");
process.StartInfo.Arguments = _filename;
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;
}
}
else
{
process.StartInfo.FileName = "bash";
process.StartInfo.Arguments = s_unixgladeapp.Replace("$@", _filename);
}
if (!string.IsNullOrEmpty(process.StartInfo.FileName))
process.Start();
Process.Start(_filename);
}
catch (Exception ex)
{

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -36,19 +37,6 @@
<EmbeddedResource Include="Properties\Manifest.addin.xml" />
</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">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -76,21 +64,25 @@
<None Include="Templates\File\Widget.CS.xft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\Projects\GtkSharpProject.FS.xpt.xml">
<None Include="packages.config" />
<None Include="Templates\GtkSharp.Template.CSharp.nupkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="glade.sh">
<LogicalName>glade.sh</LogicalName>
<None Include="Templates\GtkSharp.Template.VBNet.nupkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Templates\" />
<Folder Include="Templates\Projects\" />
<Folder Include="Templates\Projects\Data\" />
<Folder Include="Templates\File\" />
<Folder Include="Templates\File\Data\" />
</ItemGroup>
<ItemGroup>
<Reference Include="dbus-sharp">
<HintPath>References\dbus-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<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.4.1\build\MonoDevelop.Addins.targets" Condition="Exists('packages\MonoDevelop.Addins.0.4.1\build\MonoDevelop.Addins.targets')" />
</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: AddinDescription("Provides modern Gtk# file / project templates and glade file integration.")]
[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"?>
<ExtensionModel>
<Dependencies>
<Addin id="MonoDevelop.Ide" version="7.1"/>
<Addin id="MonoDevelop.Core" version="7.1"/>
</Dependencies>
<Runtime>
<Import file="glade.sh" />
<!-- Project Templates -->
<Import file="Templates/Projects/Data/MainWindow.cs" />
<Import file="Templates/Projects/Data/MainWindow.glade" />
<Import file="Templates/Projects/Data/Program.cs" />
<Import file="Templates/Projects/GtkSharpProject.CS.xpt.xml" />
<Import file="Templates/Projects/GtkSharpProject.FS.xpt.xml" />
<Import file="Templates/GtkSharp.Template.CSharp.nupkg" />
<Import file="Templates/GtkSharp.Template.VBNet.nupkg" />
<!-- File Templates -->
<Import file="Templates/File/Data/Dialog.cs" />
@ -35,14 +25,26 @@
</Extension>
<Extension path="/MonoDevelop/Ide/ProjectTemplateCategories/multiplat/app">
<Category id="gtk" name="Gtk#" />
<Category id="gtk" name="Gtk" />
</Extension>
<Extension path="/MonoDevelop/Ide/ProjectTemplates">
<ProjectTemplate id="gtk-cs-project" file="Templates/Projects/GtkSharpProject.CS.xpt.xml" />
<!-- TODO: Implement fsharp template -->
<!--ProjectTemplate id="gtk-fs-project" file="Templates/Projects/GtkSharpProject.FS.xpt.xml" /-->
<Extension path="/MonoDevelop/Ide/Templates">
<Template
id="GtkSharp.Application.CSharp"
_overrideDescription="Creates a new Gtk multiplatform application."
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 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"?>
<packages>
<package id="MonoDevelop.Addins" version="0.3.3" targetFramework="net45" />
<package id="MonoDevelop.Addins" version="0.4.1" targetFramework="net45" />
</packages>

View File

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

View File

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