Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added blueprint template #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions templates/blueprint/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# taken from gitg
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.vala]
indent_size = 4
indent_style = tab
insert_final_newline = true
max_line_length = 100

[*.{c,h}]
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 100

[*.css]
indent_size = 2
indent_style = space

[*.{ui,xml,xml.in}]
indent_size = 2
indent_style = space

[*.py]
indent_size = 4
indent_style = space

[*.json]
indent_style = space
indent_size = 4

[meson.build]
indent_size = 2
indent_style = space

1 change: 1 addition & 0 deletions templates/blueprint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# ${APP_NAME}
7 changes: 7 additions & 0 deletions templates/blueprint/data/${APP_NAME}.gresource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="${APP_PATH}">
<!-- Interface -->
<file preprocess="xml-stripblanks">ui/window.ui</file>
</gresource>
</gresources>
17 changes: 17 additions & 0 deletions templates/blueprint/data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
blueprints = files(
'ui/window.blp',
)

blp_target = custom_target(
'blueprints',

input: blueprints,
output: '.',
command: [ find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@' ],
)

project_resources = gnome.compile_resources(
project_name + '-resources',
project_name + '.gresource.xml',
dependencies: blp_target
)
28 changes: 28 additions & 0 deletions templates/blueprint/data/ui/window.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Gtk 4.0;
using Adw 1;

template ${APP_NAMESPACE}MainWindow : Adw.ApplicationWindow {
title: "${PROJECT_NAME}";
default-width: 400;
default-height: 350;

Gtk.Box {
orientation: vertical;

Adw.HeaderBar {}

Gtk.Box {
orientation: vertical;
halign: center;
valign: center;
hexpand: true;
vexpand: true;

Gtk.Label {
styles ["title-1"]
label: "Hello, world!";
}
}
}
}

14 changes: 14 additions & 0 deletions templates/blueprint/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project(
'${PROJECT_NAME}',

['c', 'vala'],
version: '${PROJECT_VERSION}'
)

pkg = import('pkgconfig')
gnome = import('gnome')

project_name = meson.project_name()

subdir('data')
subdir('src')
20 changes: 20 additions & 0 deletions templates/blueprint/src/core/application.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ${APP_NAMESPACE} {

public class Application : Adw.Application {

public Application() {
Object(
application_id: "${APP_ID}",
flags: ApplicationFlags.FLAGS_NONE
);
}

public override void activate() {
base.activate();
var win = active_window ?? new MainWindow(this);

win.present();
}
}
}

4 changes: 4 additions & 0 deletions templates/blueprint/src/main.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main(string[] args) {
var app = new ${APP_NAMESPACE}.Application();
return app.run(args);
}
21 changes: 21 additions & 0 deletions templates/blueprint/src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project_deps = [
dependency('gtk4'),
dependency('libadwaita-1'),
]

project_sources = files(
'main.vala',

'core/application.vala',
'ui/main-window.vala',
)

executable(
project_name,

project_resources,
project_sources,
vala_args: [ '--gresourcesdir=data/' ],
dependencies: project_deps,
install: true,
)
10 changes: 10 additions & 0 deletions templates/blueprint/src/ui/main-window.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ${APP_NAMESPACE} {

[GtkTemplate (ui = "${APP_PATH}ui/window.ui")]
public class MainWindow : Adw.ApplicationWindow {

public MainWindow(Gtk.Application app) {
Object(application: app);
}
}
}
35 changes: 35 additions & 0 deletions templates/blueprint/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"description": "a starter libadwaita app with blueprint",
"variables": {
"APP_NAME": {
"auto": true,
"default": "/${PROJECT_NAME}/\\s+//"
},
"APP_ID": {
"summary": "application ID",
"pattern": "^\\w+(\\.\\w+)*$",
"default": "io.github.${USERNAME}.${APP_NAME}"
},
"APP_NAMESPACE": {
"summary": "application namespace",
"pattern": "[A-Z]\\w{2,}",
"default": "/${PROJECT_NAME}/\\s+//"
},
"APP_PATH": {
"auto": true,
"default": "/${APP_ID}/(\\.|^|$)/\\//"
}
},
"templates": [
"data/ui/window.blp",
"data/${APP_NAME}.gresource.xml",
"data/meson.build",
"src/core/application.vala",
"src/ui/main-window.vala",
"src/main.vala",
"src/meson.build",
".editorconfig",
"meson.build",
"README.md"
]
}
1 change: 1 addition & 0 deletions templates/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
install_subdir('blueprint', install_dir: templates_dir)
install_subdir('eos', install_dir: templates_dir)
install_subdir('gnome', install_dir: templates_dir)
install_subdir('gtk', install_dir: templates_dir)
Expand Down