Connect template to the build system

This commit is contained in:
cra0zy 2017-10-29 01:35:22 +02:00
parent 1a416f3305
commit 4379eecdf3
11 changed files with 146 additions and 11 deletions

View file

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Gtk.Template.CSharp</id>
<id>GtkSharp.Template.CSharp</id>
<version>3.0.0</version>
<title>Gtk template for CSharp</title>
<summary>A simple C# template for your .Net Core Gtk Application.</summary>
<description>A simple C# template for your .Net Core Gtk Application.</description>
<authors>GLibSharp Team</authors>
<owners>GLibSharp Team</owners>
<projectUrl>https://github.com/GLibSharp/GtkSharp</projectUrl>
<authors>cra0zy</authors>
<owners>cra0zy</owners>
<projectUrl>https://github.com/cra0zy/GtkSharp</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes></releaseNotes>
<tags>gtk app dotnet new template</tags>
<tags>gtk gtksharp gtk-sharp app dotnet new template</tags>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
</package>
</package>

View file

@ -1,10 +1,12 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GLibSharp Team",
"classifications": [ "Console" ],
"author": "cra0zy",
"classifications": [
"Console"
],
"name": "Gtk Application",
"identity": "Gtk.Template.CSharp",
"groupIdentity": "Gtk.Template",
"identity": "GtkSharp.Template.CSharp",
"groupIdentity": "GtkSharp.Template",
"shortName": "gtkapp",
"tags": {
"language": "C#",
@ -12,4 +14,4 @@
},
"sourceName": "GtkNamespace",
"preferNameDirectory": true
}
}

View file

@ -0,0 +1,37 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace test
{
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("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

@ -0,0 +1,46 @@
<?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

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

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="MainWindow.glade">
<LogicalName>MainWindow.glade</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.2.0" />
</ItemGroup>
</Project>

View file

@ -106,6 +106,19 @@ Task("PackageNuGet")
DotNetCorePack(gassembly.Csproj, settings);
});
Task("PackageTemplates")
.IsDependentOn("Init")
.Does(() =>
{
var settings = new NuGetPackSettings
{
BasePath = "Source/Templates/NetCore/GtkSharp.Template.CSharp",
OutputDirectory = "BuildOutput/NugetPackages"
};
NuGetPack("Source/Templates/NetCore/GtkSharp.Template.CSharp/GtkSharp.Template.CSharp.nuspec", settings);
});
// TASK TARGETS
Task("Default")