Templates & Templates & Templates

This commit is contained in:
cra0zy 2017-10-26 19:49:21 +02:00
parent ccb48b505c
commit 77a12bc24f
30 changed files with 250 additions and 113 deletions

View file

@ -1,17 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GtkSharp.Addin", "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

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Gtk.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>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes></releaseNotes>
<tags>gtk app dotnet new template</tags>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
</package>

View file

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

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

@ -0,0 +1,37 @@
using System;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace GtkNamespace
{
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 GtkNamespace
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
Application.Init();
var app = new Application("org.GtkNamespace.GtkNamespace", GLib.ApplicationFlags.None);
app.Register(GLib.Cancellable.Current);
var win = new MainWindow();
app.AddWindow(win);
win.Show();
Application.Run();
}
}
}