Commit 3ae3e447 authored by Christian Hergert's avatar Christian Hergert
Browse files

meson-templates: add Gtk♯ template

parent 1f6e8d87
......@@ -27,9 +27,13 @@
<file compressed="true">resources/src/main.vala</file>
<file compressed="true">resources/src/hello.py.in</file>
<file compressed="true">resources/src/main.py</file>
<file compressed="true">resources/src/application.in</file>
<file compressed="true">resources/src/main.cs</file>
<file compressed="true">resources/src/meson-cs.build</file>
<file compressed="true">resources/build-aux/meson/postinstall.py</file>
<file compressed="true">resources/meson.build</file>
<file compressed="true">resources/flatpak.json</file>
<file compressed="true">resources/flatpak-gtksharp.json</file>
<file compressed="true">resources/data/meson.build</file>
<file compressed="true">resources/data/hello.gschema.xml</file>
<file compressed="true">resources/data/hello.desktop.in</file>
......
......@@ -102,7 +102,7 @@ class MesonTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
else:
self.language = 'c'
if self.language not in ('c', 'c++', 'javascript', 'python', 'vala'):
if self.language not in ('c', 'c♯', 'c++', 'javascript', 'python', 'vala'):
task.return_error(GLib.Error('Language %s not supported' % self.language))
return
......@@ -153,6 +153,8 @@ class MesonTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
# Just avoiding dealing with template bugs
if self.language in ('c', 'c++'):
ui_file = prefix + '-window.ui'
elif self.language in ('c♯',):
ui_file = ""
else:
ui_file = 'window.ui'
scope.get('ui_file').assign_string(ui_file)
......@@ -163,6 +165,7 @@ class MesonTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
modes = {
'resources/src/hello.js.in': 0o750,
'resources/src/hello.py.in': 0o750,
'resources/src/application.in': 0o750,
'resources/build-aux/meson/postinstall.py': 0o750,
}
......@@ -228,7 +231,7 @@ class GnomeProjectTemplate(MesonTemplate):
_('GNOME Application'),
'pattern-gnome',
_('Create a new GNOME application'),
['C', 'C++', 'Python', 'JavaScript', 'Vala']
['C', 'C++', 'C♯', 'Python', 'JavaScript', 'Vala']
)
def prepare_files(self, files):
......@@ -256,6 +259,13 @@ class GnomeProjectTemplate(MesonTemplate):
files['resources/src/window.cpp'] = 'src/%(prefix)s-window.cpp'
files['resources/src/window.hpp'] = 'src/%(prefix)s-window.h'
window_ui_name = 'src/%(prefix)s-window.ui'
elif self.language == 'c♯':
files['resources/src/main.cs'] = 'src/main.cs'
files['resources/src/application.in'] = 'src/%(exec_name)s.in'
files['resources/flatpak-gtksharp.json'] = '%(appid)s.json'
meson_file = 'resources/src/meson-cs.build'
resource_name = None
window_ui_name = None
elif self.language == 'vala':
files['resources/src/main.vala'] = 'src/main.vala'
files['resources/src/window.vala'] = 'src/window.vala'
......@@ -274,8 +284,11 @@ class GnomeProjectTemplate(MesonTemplate):
files['resources/src/main.py'] = 'src/main.py'
meson_file = 'resources/src/meson-py.build'
files['resources/src/hello.gresource.xml'] = resource_name
files['resources/src/window.ui'] = window_ui_name
if resource_name:
files['resources/src/hello.gresource.xml'] = resource_name
if window_ui_name:
files['resources/src/window.ui'] = window_ui_name
files[meson_file] = 'src/meson.build'
......@@ -308,3 +321,4 @@ class EmptyProjectTemplate(MesonTemplate):
def prepare_files(self, files):
files['resources/src/meson-empty.build'] = 'src/meson.build'
[Desktop Entry]
Name={{name}}
Exec={{exec_name}}
Terminal=false
Type=Application
Categories=GTK;
......
{
"app-id": "{{appid}}",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"command": "{{exec_name}}",
"sdk-extensions": ["org.freedesktop.Sdk.Extension.mono5"],
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"build-options" : {
"append-path": "/usr/lib/sdk/mono5/bin",
"append-ld-library-path": "/usr/lib/sdk/mono5/lib",
"env": {
"PKG_CONFIG_PATH": "/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/sdk/mono5/lib/pkgconfig"
}
},
"cleanup": [ "/lib/monodoc", "/lib/pkgconfig" ],
"modules": [
{
"name": "mono-runtime",
"buildsystem": "simple",
"build-commands": ["/usr/lib/sdk/mono5/install.sh "],
"build-options" : {
"no-debuginfo": true,
"strip": true
}
},
{
"name": "gtk-sharp3",
"buildsystem": "meson",
"builddir": true,
"sources": [
{
"type": "git",
"url": "https://github.com/gtk-sharp/gtk-sharp.git"
}
]
},
{
"name": "{{name}}",
"buildsystem": "meson",
"builddir": true,
"sources": [
{
"type": "git",
"url": "file://{{project_path}}"
}
]
}
]
}
project('{{name}}',{{if language == "c"}} 'c',{{else if language == "c++"}} 'cpp',{{else if language == "vala"}} 'c', 'vala',{{end}}
project('{{name}}', {{if language == "c"}}'c',{{else if language == "c++"}}['cpp', 'c'],{{else if language == "vala"}}['c', 'vala'],{{else if language == "c♯"}}'cs',{{end}}
version: '{{project_version}}',
meson_version: '>= 0.40.0',
)
......@@ -7,10 +7,6 @@ project('{{name}}',{{if language == "c"}} 'c',{{else if language == "c++"}} 'cpp
i18n = import('i18n')
{{end}}
{{if language == "c++"}}
add_languages('c')
{{end}}
{{if language == "c"}}
config_h = configuration_data()
{{if enable_i18n}}
......
data/{{appid}}.desktop.in
data/{{appid}}.appdata.xml.in
data/{{appid}}.gschema.xml
{{if ui_file}}
src/{{ui_file}}
{{end}}
{{if language == "c"}}src/main.c
src/{{prefix}}-window.c{{end}}
{{if language == "vala"}}src/main.vala
......
#!/bin/sh
mono "@libexecdir@/{{exec_name}}.exe"
using Gtk;
namespace Example
{
public class App
{
static void Main (string[] args)
{
Application.Init ();
var window = new Gtk.Window ("Example");
var label = new Gtk.Label ("Hello, World!");
window.Add (label);
label.Show ();
window.DeleteEvent += (win, ev) => {
Application.Quit ();
};
window.Present ();
Application.Run ();
}
}
}
\ No newline at end of file
gtk_sharp_dep = dependency('gtk-sharp-3.0')
{{name_}}_sources = [
'main.cs',
]
executable('{{exec_name}}', {{name_}}_sources,
dependencies: gtk_sharp_dep,
install: true,
install_dir: join_paths(get_option('prefix'), 'libexec'),
)
cdata = configuration_data()
cdata.set('libexecdir', join_paths(get_option('prefix'), 'libexec'))
configure_file(
input: '{{exec_name}}.in',
output: '{{exec_name}}',
configuration: cdata,
install: true,
install_dir: get_option('bindir'),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment