Merge pull request #21 from cra0zy/fsharp

F# templates + minor template fixes
This commit is contained in:
Harry 2018-02-26 22:42:30 +01:00 committed by GitHub
commit a69b4d98b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 373 additions and 2 deletions

View File

@ -4,6 +4,7 @@
<id>GtkSharp.Template.CSharp</id>
<version>3.0.0</version>
<title>Gtk templates for CSharp</title>
<iconUrl>https://raw.githubusercontent.com/GtkSharp/GtkSharp/develop/Source/Libs/GtkSharp/Icon.png</iconUrl>
<summary>A set of C# templates for your .Net Core Gtk Application.</summary>
<description>A set of C# templates for your .Net Core Gtk Application.</description>
<authors>GtkSharp Contributors</authors>
@ -16,4 +17,4 @@
<packageType name="Template" />
</packageTypes>
</metadata>
</package>
</package>

View File

@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.24.*" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>GtkSharp.Template.FSharp</id>
<version>3.0.0</version>
<title>Gtk templates for FSharp</title>
<iconUrl>https://raw.githubusercontent.com/GtkSharp/GtkSharp/develop/Source/Libs/GtkSharp/Icon.png</iconUrl>
<summary>A set of F# templates for your .Net Core Gtk Application.</summary>
<description>A set of F# templates for your .Net Core Gtk Application.</description>
<authors>GtkSharp Contributors</authors>
<owners>GtkSharp Contributors</owners>
<projectUrl>https://github.com/GtkSharp/GtkSharp</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes></releaseNotes>
<tags>gtk gtksharp gtk-sharp app dotnet new template f# fsharp</tags>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
</package>

View File

@ -0,0 +1,25 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"GUI App"
],
"name": "Gtk Application",
"identity": "GtkSharp.Application.FSharp",
"groupIdentity": "GtkSharp.Application",
"shortName": "gtkapp",
"tags": {
"language": "F#",
"type": "project"
},
"sourceName": "GtkNamespace",
"preferNameDirectory": true,
"symbols": {
"targetframework": {
"type": "parameter",
"defaultValue": "netcoreapp2.0",
"replaces": "netcoreapp2.0"
}
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="MainWindow.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.24.*" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,24 @@
namespace GtkNamespace
open Gtk
type MainWindow (builder : Builder) as this =
inherit Window(builder.GetObject("MainWindow").Handle)
let mutable _label1 : Label = null
let mutable _button1 : Button = null
let mutable _counter = 0;
do
_label1 <- builder.GetObject("_label1") :?> Label
_button1 <- builder.GetObject("_button1") :?> Button
this.DeleteEvent.Add(fun _ ->
Application.Quit()
)
_button1.Clicked.Add(fun _ ->
_counter <- _counter + 1
_label1.Text <- "Hello World! This button has been clicked " + _counter.ToString() + " time(s)."
)
new() = new MainWindow(new Builder("MainWindow.glade"))

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,18 @@
namespace GtkNamespace
module Program =
open Gtk
[<EntryPoint>]
let main argv =
Application.Init()
let app = new Application("org.GtkNamespace.GtkNamespace", GLib.ApplicationFlags.None)
app.Register(GLib.Cancellable.Current) |> ignore;
let win = new MainWindow()
app.AddWindow(win)
win.Show()
Application.Run()
0

View File

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Dialog",
"identity": "GtkSharp.Dialog.FSharp",
"groupIdentity": "GtkSharp.Dialog",
"shortName": "gtkdialog",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Dialog",
"primaryOutputs": [
{
"path": "Gtk_Dialog.fs"
},
{
"path": "Gtk_Dialog.glade"
}
],
"defaultName": "Gtk_Dialog",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View File

@ -0,0 +1,13 @@
namespace GtkNamespace
open Gtk
type Gtk_Dialog (builder : Builder) as this =
inherit Dialog(builder.GetObject("Gtk_Dialog").Handle)
do
this.DefaultResponse <- ResponseType.Cancel;
this.Response.Add(fun _ ->
this.Hide();
)
new() = new Gtk_Dialog(new Builder("Gtk_Dialog.glade"))

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="Gtk_Dialog">
<property name="can_focus">False</property>
<property name="default_width">320</property>
<property name="default_height">260</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
</interface>

View File

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Widget",
"identity": "GtkSharp.Widget.FSharp",
"groupIdentity": "GtkSharp.Widget",
"shortName": "gtkwidget",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Widget",
"primaryOutputs": [
{
"path": "Gtk_Widget.fs"
},
{
"path": "Gtk_Widget.glade"
}
],
"defaultName": "Gtk_Widget",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View File

@ -0,0 +1,8 @@
namespace GtkNamespace
open Gtk
type Gtk_Widget (builder : Builder) =
inherit Box(builder.GetObject("Gtk_Widget").Handle)
new() = new Gtk_Widget(new Builder("Gtk_Widget.glade"))

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="${EscapedIdentifier}">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -0,0 +1,33 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "GtkSharp Contributors",
"classifications": [
"Gtk",
"UI"
],
"name": "Gtk Window",
"identity": "GtkSharp.Window.FSharp",
"groupIdentity": "GtkSharp.Window",
"shortName": "gtkwindow",
"tags": {
"language": "F#",
"type": "item"
},
"sourceName": "Gtk_Window",
"primaryOutputs": [
{
"path": "Gtk_Window.fs"
},
{
"path": "Gtk_Window.glade"
}
],
"defaultName": "Gtk_Window",
"symbols": {
"namespace": {
"description": "Namespace for the generated files",
"replaces": "GtkNamespace",
"type": "parameter"
}
}
}

View File

@ -0,0 +1,8 @@
namespace GtkNamespace
open Gtk
type Gtk_Window (builder : Builder) =
inherit Window(builder.GetObject("Gtk_Window").Handle)
new() = new Gtk_Window(new Builder("Gtk_Window.glade"))

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="Gtk_Window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Gtk_Window</property>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -4,6 +4,7 @@
<id>GtkSharp.Template.VBNet</id>
<version>3.0.0</version>
<title>Gtk templates for VBNet</title>
<iconUrl>https://raw.githubusercontent.com/GtkSharp/GtkSharp/develop/Source/Libs/GtkSharp/Icon.png</iconUrl>
<summary>A set of VB templates for your .Net Core Gtk Application.</summary>
<description>A set of VB templates for your .Net Core Gtk Application.</description>
<authors>GtkSharp Contributors</authors>
@ -16,4 +17,4 @@
<packageType name="Template" />
</packageTypes>
</metadata>
</package>
</package>

View File

@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="**\*.glade" />
<EmbeddedResource Include="**\*.glade">
<LogicalName>%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.22.24.*" />
</ItemGroup>
</Project>

View File

@ -125,6 +125,9 @@ Task("PackageTemplates")
settings.BasePath = "Source/Templates/GtkSharp.Template.CSharp";
NuGetPack("Source/Templates/GtkSharp.Template.CSharp/GtkSharp.Template.CSharp.nuspec", settings);
settings.BasePath = "Source/Templates/GtkSharp.Template.FSharp";
NuGetPack("Source/Templates/GtkSharp.Template.FSharp/GtkSharp.Template.FSharp.nuspec", settings);
settings.BasePath = "Source/Templates/GtkSharp.Template.VBNet";
NuGetPack("Source/Templates/GtkSharp.Template.VBNet/GtkSharp.Template.VBNet.nuspec", settings);
});