diff --git a/templates/eos/${APP_ID}.yml b/templates/eos/${APP_ID}.yml
new file mode 100644
index 0000000..61cba39
--- /dev/null
+++ b/templates/eos/${APP_ID}.yml
@@ -0,0 +1,36 @@
+# This is the same ID that you've used in meson.build and other files
+app-id: ${APP_ID}
+
+# Instead of manually specifying a long list of build and runtime dependencies,
+# we can use a convenient pre-made runtime and SDK. For this example, we'll be
+# using the runtime and SDK provided by elementary.
+runtime: io.elementary.Platform
+runtime-version: "7.2"
+sdk: io.elementary.Sdk
+sdk-extensions:
+ - org.freedesktop.Sdk.Extension.vala
+build-options:
+ prepend-path: /usr/lib/sdk/vala/bin
+ prepend-ld-library-path: /usr/lib/sdk/vala/lib
+
+# This should match the exec line in your .desktop file and usually is the same
+# as your app ID
+command: ${APP_ID}
+
+# Here we can specify the kinds of permissions our app needs to run. Since we're
+# not using hardware like webcams, making sound, or reading external files, we
+# only need permission to draw our app on screen using either X11 or Wayland.
+finish-args:
+ - "--share=ipc"
+ - "--socket=fallback-x11"
+ - "--socket=wayland"
+
+# This section is where you list all the source code required to build your app.
+# If we had external dependencies that weren't included in our SDK, we would list
+# them here.
+modules:
+ - name: ${APP_NAME}
+ buildsystem: meson
+ sources:
+ - type: dir
+ path: .
diff --git a/templates/eos/.github/workflows/main.yml b/templates/eos/.github/workflows/main.yml
new file mode 100644
index 0000000..b51422c
--- /dev/null
+++ b/templates/eos/.github/workflows/main.yml
@@ -0,0 +1,66 @@
+name: CI
+
+# This workflow will run for any pull request or pushed commit
+# on: [push, pull_request]
+
+on:
+ push:
+ branches:
+ - main
+
+ pull_request:
+ branches:
+ - main
+ types:
+ - opened
+ - reopened
+ - synchronize
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ # This workflow contains a single job called "flatpak"
+ flatpak:
+ # The type of runner that the job will run on
+ runs-on: ubuntu-latest
+
+ # This job runs in a special container designed for building Flatpaks for AppCenter
+ container:
+ image: ghcr.io/elementary/flatpak-platform/runtime:7.2
+ options: --privileged
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it
+ - uses: actions/checkout@v3
+
+ - name: "Install Vala Freedesktop Extension SDK"
+ run: "flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo && flatpak install -y runtime/org.freedesktop.Sdk.Extension.vala/x86_64/22.08"
+
+ # Builds your flatpak manifest using the Flatpak Builder action
+ - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
+ with:
+ # This is the name of the Bundle file we're building and can be anything you like
+ bundle: ${APP_NAME}.flatpak
+ # This uses your app's RDNN ID
+ manifest-path: ${APP_ID}.yml
+
+ # You can automatically run any of the tests you've created as part of this workflow
+ run-tests: true
+
+ # These lines specify the location of the elementary Runtime and Sdk
+ repository-name: appcenter
+ repository-url: https://flatpak.elementary.io/repo.flatpakrepo
+ cache-key: "flatpak-builder-${{ github.sha }}"
+
+ lint:
+ runs-on: ubuntu-latest
+
+ container:
+ image: valalang/lint
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Lint
+ run: io.elementary.vala-lint .
diff --git a/templates/eos/.gitignore b/templates/eos/.gitignore
new file mode 100644
index 0000000..3d5c747
--- /dev/null
+++ b/templates/eos/.gitignore
@@ -0,0 +1,6 @@
+/_build
+/build
+/app
+/.flatpak
+/.flatpak-builder
+/subprojects/**/
diff --git a/templates/eos/README.md b/templates/eos/README.md
index 2c899d1..3d4e50e 100644
--- a/templates/eos/README.md
+++ b/templates/eos/README.md
@@ -1,22 +1,52 @@
-# ${PROJECT_NAME}
+# ${APP_TITLE}
-${PROJECT_SUMMARY}
+${APP_SUMMARY}
-## Building, Testing, and Installation
+## Build Instructions
-You'll need the following dependencies to build:
-* libgtk-3-dev
-* meson
-* valac
+### Flatpak (Recommended)
-Run `meson build` to configure the build environment and run `ninja` to build
-```Bash
- meson build --prefix=/usr
- cd build
- ninja
+Either:
+
+- Use Visual Studio Code with [Flatpak extension](https://marketplace.visualstudio.com/items?itemName=bilelmoussaoui.flatpak-vscode
+- Use [GNOME Builder](https://apps.gnome.org/en-GB/app/org.gnome.Builder/)
+- Flatpak integrations for of your preferred IDE/Code Editor
+- Or use the [flatpak and flatpak-builder](https://docs.flatpak.org/en/latest/first-build.htm) commands.
+
+### Meson
+
+#### Dependencies
+
+- glib-2.0
+- gobject-2.0
+- gee-0.8
+- gtk4
+- granite-7
+
+#### Build Commands
+
+To build:
+
+```sh
+meson build --prefix=/usr
+cd build
+ninja
```
-To install, use `ninja install`, then execute with `com.${USERNAME}.${PROGRAM_NAME}`
-```Bash
- sudo ninja install
- com.github.${USERNAME}.${PROGRAM_NAME}
+
+To test:
+
+(Assuming you're in the project root and have already built the app)
+
+```sh
+cd build
+meson test
+```
+
+To install:
+
+(Assuming you're in project root)
+
+```sh
+cd build
+sudo ninja install
```
diff --git a/templates/eos/data/${APP_NAME}.desktop.in.in b/templates/eos/data/${APP_NAME}.desktop.in.in
new file mode 100644
index 0000000..21f02f1
--- /dev/null
+++ b/templates/eos/data/${APP_NAME}.desktop.in.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+
+Name=@APP_TITLE@
+Comment=@APP_SUMMARY@
+Categories=${APP_CATEGORIES}
+
+Icon=@APP_ID@
+Exec=@APP_ID@
+Terminal=false
\ No newline at end of file
diff --git a/templates/eos/data/${APP_NAME}.gresource.xml.in b/templates/eos/data/${APP_NAME}.gresource.xml.in
new file mode 100644
index 0000000..1f04192
--- /dev/null
+++ b/templates/eos/data/${APP_NAME}.gresource.xml.in
@@ -0,0 +1,6 @@
+
+
+
+ style.css
+
+
\ No newline at end of file
diff --git a/templates/eos/data/${APP_NAME}.gschema.xml.in b/templates/eos/data/${APP_NAME}.gschema.xml.in
new file mode 100644
index 0000000..31834cc
--- /dev/null
+++ b/templates/eos/data/${APP_NAME}.gschema.xml.in
@@ -0,0 +1,20 @@
+
+
+
+
+ 640
+ Most recent window width
+ Most recent window width
+
+
+ 480
+ Most recent window height
+ Most recent window height
+
+
+ false
+ Open window maximized.
+ Whether the main window of the application should open maximized or not.
+
+
+
\ No newline at end of file
diff --git a/templates/eos/data/${APP_NAME}.metainfo.xml.in.in b/templates/eos/data/${APP_NAME}.metainfo.xml.in.in
new file mode 100644
index 0000000..22b32fd
--- /dev/null
+++ b/templates/eos/data/${APP_NAME}.metainfo.xml.in.in
@@ -0,0 +1,32 @@
+
+
+ @APP_ID@
+ @APP_ID@.desktop
+ CC0-1.0
+ @APP_LICENSE_TYPE@
+
+ @APP_TITLE@
+ @APP_SUMMARY@
+
+
@APP_SUMMARY@
+
+
+ @APP_HOMEPAGE_URL@
+ @APP_BUG_TRACKER_URL@
+
+ @APP_DEVELOPER_NAME@
+
+
+
+
+ @APP_ID@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/eos/data/128.svg b/templates/eos/data/icons/128.svg
similarity index 100%
rename from templates/eos/data/128.svg
rename to templates/eos/data/icons/128.svg
diff --git a/templates/eos/data/16.svg b/templates/eos/data/icons/16.svg
similarity index 100%
rename from templates/eos/data/16.svg
rename to templates/eos/data/icons/16.svg
diff --git a/templates/eos/data/24.svg b/templates/eos/data/icons/24.svg
similarity index 100%
rename from templates/eos/data/24.svg
rename to templates/eos/data/icons/24.svg
diff --git a/templates/eos/data/32.svg b/templates/eos/data/icons/32.svg
similarity index 100%
rename from templates/eos/data/32.svg
rename to templates/eos/data/icons/32.svg
diff --git a/templates/eos/data/48.svg b/templates/eos/data/icons/48.svg
similarity index 100%
rename from templates/eos/data/48.svg
rename to templates/eos/data/icons/48.svg
diff --git a/templates/eos/data/64.svg b/templates/eos/data/icons/64.svg
similarity index 100%
rename from templates/eos/data/64.svg
rename to templates/eos/data/icons/64.svg
diff --git a/templates/eos/data/meson.build b/templates/eos/data/meson.build
new file mode 100644
index 0000000..50c26b9
--- /dev/null
+++ b/templates/eos/data/meson.build
@@ -0,0 +1,88 @@
+# Tell meson where to find our resources file and to compile it as a GResource
+gresource = gnome.compile_resources(
+ 'gresource',
+ configure_file(
+ input: app_name + '.gresource.xml.in',
+ output: app_name + '.gresource.xml',
+ configuration: config_data,
+ ),
+ source_dir: join_paths(meson.source_root(), 'data'),
+)
+
+#Translate and install our .desktop file
+desktop_file = i18n.merge_file(
+ input: configure_file(
+ input: app_name + '.desktop.in.in',
+ output: app_name + '.desktop.in',
+ configuration: config_data,
+ ),
+ output: app_id + '.desktop',
+ po_dir: meson.source_root() / 'po',
+ type: 'desktop',
+ install: true,
+ install_dir: get_option('datadir') / 'applications',
+)
+
+desktop_utils = find_program('desktop-file-validate', required: false)
+if desktop_utils.found()
+ test('Validate desktop file', desktop_utils, args: [desktop_file])
+endif
+
+# Translate and install our .metainfo file
+appstream_file = i18n.merge_file(
+ input: configure_file(
+ input: app_name + '.metainfo.xml.in.in',
+ output: app_name + '.metainfo.xml.in',
+ configuration: config_data,
+ ),
+ output: app_id + '.metainfo.xml',
+ po_dir: meson.source_root() / 'po',
+ install: true,
+ install_dir: get_option('datadir') / 'metainfo',
+)
+
+appstream_util = find_program('appstream-util', required: false)
+if appstream_util.found()
+ test(
+ 'Validate appstream file',
+ appstream_util,
+ args: ['validate', appstream_file],
+ )
+endif
+
+# Install gschema (settings) file
+gschema_file = configure_file(
+ input: app_name + '.gschema.xml.in',
+ output: app_id + '.gschema.xml',
+ configuration: config_data,
+ install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
+)
+
+compile_schemas = find_program('glib-compile-schemas', required: false)
+if compile_schemas.found()
+ test(
+ 'Validate schema file',
+ compile_schemas,
+ args: ['--strict', '--dry-run', meson.current_build_dir()],
+ )
+endif
+
+# Install our icons in all the required sizes
+icon_sizes = ['16', '24', '32', '48', '64', '128']
+
+foreach i : icon_sizes
+ install_data(
+ 'icons' / i + '.svg',
+ install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i /
+ 'apps',
+ rename: app_id + '.svg',
+ )
+ install_data(
+ 'icons' / i + '.svg',
+ install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i +
+ '@2' / 'apps',
+ rename: app_id + '.svg',
+ )
+endforeach
+
+
diff --git a/templates/eos/data/style.css b/templates/eos/data/style.css
new file mode 100644
index 0000000..e69de29
diff --git a/templates/eos/meson.build b/templates/eos/meson.build
index 7ee9a53..62b6730 100644
--- a/templates/eos/meson.build
+++ b/templates/eos/meson.build
@@ -1,43 +1,83 @@
# project name and programming language
-project('com.github.${USERNAME}.${PROGRAM_NAME}', 'vala', 'c')
+project(
+ '${APP_ID}',
+ 'vala',
+ 'c',
+ version: '${PROJECT_VERSION}',
+)
-# Create a new executable, list the files we want to compile, list the dependencies we need, and install
-executable(
- meson.project_name(),
- 'src' / 'Application.vala',
- dependencies: [
- dependency('gtk+-3.0'),
- dependency('granite')
- ],
- install: true
+app_id = '${APP_ID}'
+app_title = '${APP_TITLE}'
+app_name = '${APP_NAME}'
+app_developer_name = '${AUTHOR}'
+app_summary = '${APP_SUMMARY}'
+app_homepage_url = '${APP_HOMEPAGE_URL}'
+app_bug_tracker_url = '${APP_BUG_TRACKER_URL}'
+
+# Feel free to change it to whatever you prefer
+# Don't forget to create your LICENSE.md or COPYING file!
+app_license_type = 'GPL-3.0-or-later'
+
+# Import modules
+gnome = import('gnome')
+i18n = import('i18n')
+
+add_global_arguments(
+ '-DGETTEXT_PACKAGE="@0@"'.format(app_id),
+ language: 'c',
+)
+
+config_data = configuration_data()
+config_data.set(
+ 'LOCALEDIR',
+ join_paths(get_option('prefix'), get_option('localedir')),
+)
+
+config_data.set('APP_ID', app_id)
+config_data.set('APP_PATH', '/' + app_id.replace('.', '/') + '/')
+config_data.set('APP_NAME', app_name)
+config_data.set('APP_TITLE', app_title)
+config_data.set('APP_SUMMARY', app_summary)
+config_data.set('APP_LICENSE_TYPE', app_license_type)
+config_data.set('APP_DEVELOPER_NAME', app_developer_name)
+config_data.set('APP_HOMEPAGE_URL', app_homepage_url)
+config_data.set('APP_BUG_TRACKER_URL', app_bug_tracker_url)
+config_data.set('APP_VERSION', meson.project_version())
+config_data.set('GETTEXT_PACKAGE', app_id)
+config_file = configure_file(
+ input: 'src/Config.vala.in',
+ output: '@BASENAME@',
+ configuration: config_data,
)
-# Install our .desktop file so the Applications Menu will see it
-install_data(
- 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.desktop',
- install_dir: get_option('datadir') / 'applications',
- rename: meson.project_name() + '.desktop'
+# Define common dependencies used in all targets
+global_dependencies = [
+ dependency('gee-0.8'),
+ dependency('glib-2.0'),
+ dependency('gobject-2.0'),
+]
+
+# Read meson.build files in specified sub directories
+subdir('src')
+subdir('tests')
+subdir('data')
+subdir('po')
+
+# Create a new executable, list the files we want to compile, list the dependencies we need, and install
+executable(
+ app_id,
+ app_sources,
+ gresource,
+ dependencies: app_dependencies,
+ install: true,
)
-# Install our .appdata.xml file so AppCenter will see it
-install_data(
- 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml',
- install_dir: get_option('datadir') / 'metainfo',
- rename: meson.project_name() + '.appdata.xml'
+# Create executable for unit tests
+test_exe = executable(
+ app_name + '-unit-tests',
+ unit_test_sources,
+ dependencies: unit_test_dependencies,
)
+test(app_name + '-unit-tests', test_exe)
-# Install our icons in all the required sizes
-icon_sizes = ['16', '24', '32', '48', '64', '128']
-
-foreach i : icon_sizes
- install_data(
- 'data' / i + '.svg',
- install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps',
- rename: meson.project_name() + '.svg'
- )
- install_data(
- 'data' / i + '.svg',
- install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps',
- rename: meson.project_name() + '.svg'
- )
-endforeach
+meson.add_install_script('meson/post_install.py')
diff --git a/templates/eos/meson/post_install.py b/templates/eos/meson/post_install.py
new file mode 100644
index 0000000..bf02d96
--- /dev/null
+++ b/templates/eos/meson/post_install.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+from os import path, environ
+import subprocess
+
+prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+schemadir = path.join(environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
+datadir = path.join(prefix, 'share')
+desktop_database_dir = path.join(datadir, 'applications')
+
+if not environ.get('DESTDIR'):
+ print('Compiling gsettings schemas…')
+ subprocess.call(['glib-compile-schemas', schemadir])
+ print('Updating desktop database…')
+ subprocess.call(['update-desktop-database', '-q', desktop_database_dir])
+ print('Updating icon cache…')
+ subprocess.call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
\ No newline at end of file
diff --git a/templates/eos/po/LINGUAS b/templates/eos/po/LINGUAS
new file mode 100644
index 0000000..e69de29
diff --git a/templates/eos/po/POTFILES b/templates/eos/po/POTFILES
new file mode 100644
index 0000000..93fe46c
--- /dev/null
+++ b/templates/eos/po/POTFILES
@@ -0,0 +1,5 @@
+src/Application.vala
+src/MainWindow.vala
+data/${APP_NAME}.desktop.in.in
+data/${APP_NAME}.metainfo.xml.in.in
+data/${APP_NAME}.gschema.xml.in
diff --git a/templates/eos/po/meson.build b/templates/eos/po/meson.build
new file mode 100644
index 0000000..8c40e2f
--- /dev/null
+++ b/templates/eos/po/meson.build
@@ -0,0 +1,5 @@
+i18n.gettext(
+ app_id,
+ args: '--directory=' + meson.source_root(),
+ preset: 'glib',
+)
diff --git a/templates/eos/src/Application.vala b/templates/eos/src/Application.vala
index fda3458..1cae74d 100644
--- a/templates/eos/src/Application.vala
+++ b/templates/eos/src/Application.vala
@@ -1,20 +1,34 @@
-public class MyApp : Gtk.Application {
- public MyApp () {
- Object (
- application_id: "com.github.${USERNAME}.${PROGRAM_NAME}",
- flags: ApplicationFlags.FLAGS_NONE
- );
+public class ${APP_NAMESPACE}.Application : Gtk.Application {
+ public Application () {
+ Object (application_id: Constants.APP_ID);
+ }
+
+ construct {
+ Intl.setlocale (GLib.LocaleCategory.ALL, "");
+ Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, Constants.LOCALEDIR);
+ Intl.bind_textdomain_codeset (Constants.GETTEXT_PACKAGE, "UTF-8");
+ Intl.textdomain (Constants.GETTEXT_PACKAGE);
}
protected override void activate () {
- var main_window = new Gtk.ApplicationWindow (this) {
- default_height = 300,
- default_width = 300,
- title = "Hello World"
- };
+ var main_window = this.get_active_window ();
- var gtk_settings = Gtk.Settings.get_default ();
+ if (main_window == null) {
+ main_window = new MainWindow (this) {
+ title = _("${APP_TITLE}")
+ };
+ }
+
+ main_window.present ();
+
+ // Setup color scheme change events and theming
var granite_settings = Granite.Settings.get_default ();
+ var gtk_settings = Gtk.Settings.get_default ();
+ gtk_settings.gtk_icon_theme_name = "elementary";
+
+ if (!(gtk_settings.gtk_theme_name.has_prefix ("io.elementary.stylesheet"))) {
+ gtk_settings.gtk_theme_name = "io.elementary.stylesheet.blueberry";
+ }
gtk_settings.gtk_application_prefer_dark_theme = (
granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK
@@ -26,10 +40,20 @@ public class MyApp : Gtk.Application {
);
});
- main_window.show_all ();
- }
+ // Remember window dimensions state
+ var settings = new Settings (Constants.APP_ID);
+ settings.bind ("window-height", main_window, "default-height", SettingsBindFlags.DEFAULT);
+ settings.bind ("window-width", main_window, "default-width", SettingsBindFlags.DEFAULT);
- public static int main (string[] args) {
- return new MyApp ().run (args);
+ if (settings.get_boolean ("window-maximized")) {
+ main_window.maximize ();
+ }
+
+ settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET);
}
}
+
+public static int main (string[] args) {
+ var my_app = new ${APP_NAMESPACE}.Application ();
+ return my_app.run (args);
+}
diff --git a/templates/eos/src/Config.vala.in b/templates/eos/src/Config.vala.in
new file mode 100644
index 0000000..8f3cb63
--- /dev/null
+++ b/templates/eos/src/Config.vala.in
@@ -0,0 +1,15 @@
+namespace Constants {
+ public const string APP_ID = "@APP_ID@";
+ public const string APP_PATH = "@APP_PATH@";
+ public const string APP_NAME = "@APP_NAME@";
+ public const string APP_TITLE = "@APP_TITLE@";
+ public const string APP_SUMMARY = "@APP_SUMMARY@";
+ public const string APP_VERSION = "@APP_VERSION@";
+ public const string APP_LICENSE_TYPE = "@APP_LICENSE_TYPE@";
+ public const string APP_DEVELOPER_NAME = "@APP_DEVELOPER_NAME@";
+ public const string APP_HOMEPAGE_URL = "@APP_HOMEPAGE_URL@";
+ public const string APP_BUG_TRACKER_URL = "@APP_BUG_TRACKER_URL@";
+
+ public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
+ public const string LOCALEDIR = "@LOCALEDIR@";
+}
diff --git a/templates/eos/src/MainWindow.vala b/templates/eos/src/MainWindow.vala
new file mode 100644
index 0000000..4a748aa
--- /dev/null
+++ b/templates/eos/src/MainWindow.vala
@@ -0,0 +1,30 @@
+public class ${APP_NAMESPACE}.MainWindow : Gtk.ApplicationWindow {
+ public MainWindow (Gtk.Application app) {
+ Object (
+ application: app
+ );
+ }
+
+ static construct {
+ var css_provider = new Gtk.CssProvider ();
+ css_provider.load_from_resource (Constants.APP_PATH + "style.css");
+
+ Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (),
+ css_provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
+ );
+ }
+
+ construct {
+ var label = new Gtk.Label (_("Hello World"));
+ label.vexpand = true;
+ label.valign = Gtk.Align.CENTER;
+ label.hexpand = true;
+ label.halign = Gtk.Align.CENTER;
+
+ var layout_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
+ layout_box.append (label);
+
+ this.set_child (layout_box);
+ }
+}
diff --git a/templates/eos/src/meson.build b/templates/eos/src/meson.build
new file mode 100644
index 0000000..136a56b
--- /dev/null
+++ b/templates/eos/src/meson.build
@@ -0,0 +1,7 @@
+app_dependencies = [
+ global_dependencies,
+ dependency('gtk4'),
+ dependency('granite-7'),
+]
+
+app_sources = [files('Application.vala', 'MainWindow.vala'), config_file]
diff --git a/templates/eos/template.json b/templates/eos/template.json
index 5b9cc1a..234b53f 100644
--- a/templates/eos/template.json
+++ b/templates/eos/template.json
@@ -1,31 +1,63 @@
{
- "description": "a starter elementary OS app",
+ "description": "a starter elementary OS 7 app",
"variables": {
- "PROGRAM_NAME": {
- "summary": "the name of the program",
+ "APP_NAME": {
+ "auto": true,
+ "default": "/${PROJECT_NAME}/\\s+//"
+ },
+ "APP_TITLE": {
+ "summary": "app title (used as name in appstream)",
+ "pattern": "[A-za-z ]+"
+ },
+ "APP_ID": {
+ "summary": "application ID",
+ "pattern": "[a-z]{2,}(\\.\\w+){3}",
+ "default":"io.github.${USERNAME}.${PROJECT_NAME}"
+ },
+ "APP_NAMESPACE": {
+ "summary": "the namespace to use for the application",
"default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/",
- "pattern": "^[[:word:]-]+$"
+ "pattern": "^[A-Za-z_]\\w*$"
},
- "PROJECT_SUMMARY": {
- "summary": "a very short summary of the project",
- "default": "a new app for elementary OS"
+ "APP_PATH": {
+ "auto": true,
+ "default": "/${APP_ID}/(\\.|^|$)/\\//"
},
- "PROJECT_CATEGORIES": {
+ "APP_SUMMARY": {
+ "summary": "application summary",
+ "default": "A new app for elementary OS"
+ },
+ "APP_CATEGORIES": {
"summary": "categories (semicolon-separated)",
"pattern": "^((AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Science|Settings|System|Utility);)+$"
},
- "PROJECT_KEYWORDS": {
+ "APP_KEYWORDS": {
"summary": "keywords (semicolon-separated)",
"default": "/${PROJECT_NAME}/\\W+/;/^;+//\\w+/\\L\\0\\E/[^;]$/\\0;/",
"pattern": "^(\\w+;)+$"
+ },
+ "APP_HOMEPAGE_URL": {
+ "summary": "homepage URL of app",
+ "default": "https://www.github.com/${USERNAME}/${PROJECT_NAME}",
+ "pattern": "(((http|https):\/\/)|(\/)|(..\/))(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\/|\/([\\w#!:.?+=&%@!\\-\/]))?"
+ },
+ "APP_BUG_TRACKER_URL": {
+ "summary":"bug tracker URL of app",
+ "default": "https://www.github.com/${USERNAME}/${PROJECT_NAME}/issues",
+ "pattern": "(((http|https):\/\/)|(\/)|(..\/))(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\/|\/([\\w#!:.?+=&%@!\\-\/]))?"
}
},
"templates": [
- "com.github.${USERNAME}.${PROGRAM_NAME}.yml",
+ ".github/workflows/main.yml",
+ "${APP_ID}.yml",
"meson.build",
+ "data/${APP_NAME}.desktop.in.in",
+ "src/Application.vala",
+ "src/MainWindow.vala",
+ "src/Config.vala.in",
+ "tests/test.vala",
+ "po/POTFILES",
"README.md",
- "data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml",
- "data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop",
- "src/Application.vala"
+ "meson.build"
]
}
diff --git a/templates/eos/tests/meson.build b/templates/eos/tests/meson.build
new file mode 100644
index 0000000..59d3f08
--- /dev/null
+++ b/templates/eos/tests/meson.build
@@ -0,0 +1,5 @@
+unit_test_dependencies = [
+ global_dependencies
+]
+
+unit_test_sources = [files('test.vala'), config_file]
diff --git a/templates/eos/tests/test.vala b/templates/eos/tests/test.vala
new file mode 100644
index 0000000..eb22ba3
--- /dev/null
+++ b/templates/eos/tests/test.vala
@@ -0,0 +1,11 @@
+void add_foo_tests () {
+ Test.add_func (Constants.APP_PATH + "test", () => {
+ assert ("foo" + "bar" == "foobar");
+ });
+}
+
+void main (string[] args) {
+ Test.init (ref args);
+ add_foo_tests ();
+ Test.run ();
+}
diff --git a/templates/eos6/.editorconfig b/templates/eos6/.editorconfig
new file mode 100644
index 0000000..677477f
--- /dev/null
+++ b/templates/eos6/.editorconfig
@@ -0,0 +1,16 @@
+# EditorConfig
+root = true
+
+# elementary defaults
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = tab
+indent_style = space
+insert_final_newline = true
+max_line_length = 80
+tab_width = 4
+
+# Markup files
+[{*.html,*.xml,*.xml.in,*.yml}]
+tab_width = 2
diff --git a/templates/eos6/README.md b/templates/eos6/README.md
new file mode 100644
index 0000000..2c899d1
--- /dev/null
+++ b/templates/eos6/README.md
@@ -0,0 +1,22 @@
+# ${PROJECT_NAME}
+
+${PROJECT_SUMMARY}
+
+## Building, Testing, and Installation
+
+You'll need the following dependencies to build:
+* libgtk-3-dev
+* meson
+* valac
+
+Run `meson build` to configure the build environment and run `ninja` to build
+```Bash
+ meson build --prefix=/usr
+ cd build
+ ninja
+```
+To install, use `ninja install`, then execute with `com.${USERNAME}.${PROGRAM_NAME}`
+```Bash
+ sudo ninja install
+ com.github.${USERNAME}.${PROGRAM_NAME}
+```
diff --git a/templates/eos/com.github.${USERNAME}.${PROGRAM_NAME}.yml b/templates/eos6/com.github.${USERNAME}.${PROGRAM_NAME}.yml
similarity index 100%
rename from templates/eos/com.github.${USERNAME}.${PROGRAM_NAME}.yml
rename to templates/eos6/com.github.${USERNAME}.${PROGRAM_NAME}.yml
diff --git a/templates/eos6/data/128.svg b/templates/eos6/data/128.svg
new file mode 100644
index 0000000..ffc11e8
--- /dev/null
+++ b/templates/eos6/data/128.svg
@@ -0,0 +1,502 @@
+
+
diff --git a/templates/eos6/data/16.svg b/templates/eos6/data/16.svg
new file mode 100644
index 0000000..ebad831
--- /dev/null
+++ b/templates/eos6/data/16.svg
@@ -0,0 +1,382 @@
+
+
diff --git a/templates/eos6/data/24.svg b/templates/eos6/data/24.svg
new file mode 100644
index 0000000..b72f0c1
--- /dev/null
+++ b/templates/eos6/data/24.svg
@@ -0,0 +1,412 @@
+
+
diff --git a/templates/eos6/data/32.svg b/templates/eos6/data/32.svg
new file mode 100644
index 0000000..7ce7538
--- /dev/null
+++ b/templates/eos6/data/32.svg
@@ -0,0 +1,414 @@
+
+
diff --git a/templates/eos6/data/48.svg b/templates/eos6/data/48.svg
new file mode 100644
index 0000000..d935433
--- /dev/null
+++ b/templates/eos6/data/48.svg
@@ -0,0 +1,428 @@
+
+
diff --git a/templates/eos6/data/64.svg b/templates/eos6/data/64.svg
new file mode 100644
index 0000000..6172541
--- /dev/null
+++ b/templates/eos6/data/64.svg
@@ -0,0 +1,413 @@
+
+
diff --git a/templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml b/templates/eos6/data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml
similarity index 100%
rename from templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml
rename to templates/eos6/data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml
diff --git a/templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop b/templates/eos6/data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop
similarity index 100%
rename from templates/eos/data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop
rename to templates/eos6/data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop
diff --git a/templates/eos6/meson.build b/templates/eos6/meson.build
new file mode 100644
index 0000000..7ee9a53
--- /dev/null
+++ b/templates/eos6/meson.build
@@ -0,0 +1,43 @@
+# project name and programming language
+project('com.github.${USERNAME}.${PROGRAM_NAME}', 'vala', 'c')
+
+# Create a new executable, list the files we want to compile, list the dependencies we need, and install
+executable(
+ meson.project_name(),
+ 'src' / 'Application.vala',
+ dependencies: [
+ dependency('gtk+-3.0'),
+ dependency('granite')
+ ],
+ install: true
+)
+
+# Install our .desktop file so the Applications Menu will see it
+install_data(
+ 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.desktop',
+ install_dir: get_option('datadir') / 'applications',
+ rename: meson.project_name() + '.desktop'
+)
+
+# Install our .appdata.xml file so AppCenter will see it
+install_data(
+ 'data' / 'com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml',
+ install_dir: get_option('datadir') / 'metainfo',
+ rename: meson.project_name() + '.appdata.xml'
+)
+
+# Install our icons in all the required sizes
+icon_sizes = ['16', '24', '32', '48', '64', '128']
+
+foreach i : icon_sizes
+ install_data(
+ 'data' / i + '.svg',
+ install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps',
+ rename: meson.project_name() + '.svg'
+ )
+ install_data(
+ 'data' / i + '.svg',
+ install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps',
+ rename: meson.project_name() + '.svg'
+ )
+endforeach
diff --git a/templates/eos6/src/Application.vala b/templates/eos6/src/Application.vala
new file mode 100644
index 0000000..fda3458
--- /dev/null
+++ b/templates/eos6/src/Application.vala
@@ -0,0 +1,35 @@
+public class MyApp : Gtk.Application {
+ public MyApp () {
+ Object (
+ application_id: "com.github.${USERNAME}.${PROGRAM_NAME}",
+ flags: ApplicationFlags.FLAGS_NONE
+ );
+ }
+
+ protected override void activate () {
+ var main_window = new Gtk.ApplicationWindow (this) {
+ default_height = 300,
+ default_width = 300,
+ title = "Hello World"
+ };
+
+ var gtk_settings = Gtk.Settings.get_default ();
+ var granite_settings = Granite.Settings.get_default ();
+
+ gtk_settings.gtk_application_prefer_dark_theme = (
+ granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK
+ );
+
+ granite_settings.notify["prefers-color-scheme"].connect (() => {
+ gtk_settings.gtk_application_prefer_dark_theme = (
+ granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK
+ );
+ });
+
+ main_window.show_all ();
+ }
+
+ public static int main (string[] args) {
+ return new MyApp ().run (args);
+ }
+}
diff --git a/templates/eos6/template.json b/templates/eos6/template.json
new file mode 100644
index 0000000..637381d
--- /dev/null
+++ b/templates/eos6/template.json
@@ -0,0 +1,31 @@
+{
+ "description": "a starter elementary OS 6 app",
+ "variables": {
+ "PROGRAM_NAME": {
+ "summary": "the name of the program",
+ "default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/",
+ "pattern": "^[[:word:]-]+$"
+ },
+ "PROJECT_SUMMARY": {
+ "summary": "a very short summary of the project",
+ "default": "a new app for elementary OS"
+ },
+ "PROJECT_CATEGORIES": {
+ "summary": "categories (semicolon-separated)",
+ "pattern": "^((AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Science|Settings|System|Utility);)+$"
+ },
+ "PROJECT_KEYWORDS": {
+ "summary": "keywords (semicolon-separated)",
+ "default": "/${PROJECT_NAME}/\\W+/;/^;+//\\w+/\\L\\0\\E/[^;]$/\\0;/",
+ "pattern": "^(\\w+;)+$"
+ }
+ },
+ "templates": [
+ "com.github.${USERNAME}.${PROGRAM_NAME}.yml",
+ "meson.build",
+ "README.md",
+ "data/com.github.${USERNAME}.${PROGRAM_NAME}.appdata.xml",
+ "data/com.github.${USERNAME}.${PROGRAM_NAME}.desktop",
+ "src/Application.vala"
+ ]
+}
diff --git a/templates/meson.build b/templates/meson.build
index 996b305..22f094b 100644
--- a/templates/meson.build
+++ b/templates/meson.build
@@ -1,4 +1,5 @@
install_subdir('eos', install_dir: templates_dir)
+install_subdir('eos6', install_dir: templates_dir)
install_subdir('gnome', install_dir: templates_dir)
install_subdir('gtk', install_dir: templates_dir)
install_subdir('gtk3', install_dir: templates_dir)