commit 30e7b03892ef25e3caeb82d1745eb0a3aadf2ba0 Author: thetek42 Date: Mon May 1 12:36:16 2023 +0200 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..646c889 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.vscode +/build +/subprojects/blueprint-compiler diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eede0ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 thetek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/data/de.thetek.vala-gtk-template.appdata.xml.in b/data/de.thetek.vala-gtk-template.appdata.xml.in new file mode 100644 index 0000000..47e6914 --- /dev/null +++ b/data/de.thetek.vala-gtk-template.appdata.xml.in @@ -0,0 +1,9 @@ + + + de.thetek.vala-gtk-template.desktop + CC0-1.0 + MIT + +

No description

+
+
diff --git a/data/de.thetek.vala-gtk-template.desktop.in b/data/de.thetek.vala-gtk-template.desktop.in new file mode 100644 index 0000000..dc56a2a --- /dev/null +++ b/data/de.thetek.vala-gtk-template.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=ValaGtkTemplate +Exec=ValaGtkTemplate +Icon=de.thetek.vala-gtk-template +Terminal=false +Type=Application +Categories=GTK; +StartupNotify=true diff --git a/data/de.thetek.vala-gtk-template.gschema.xml b/data/de.thetek.vala-gtk-template.gschema.xml new file mode 100644 index 0000000..99362fb --- /dev/null +++ b/data/de.thetek.vala-gtk-template.gschema.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/data/icons/hicolor/scalable/apps/de.thetek.vala-gtk-template.svg b/data/icons/hicolor/scalable/apps/de.thetek.vala-gtk-template.svg new file mode 100644 index 0000000..a74c4df --- /dev/null +++ b/data/icons/hicolor/scalable/apps/de.thetek.vala-gtk-template.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + application-x-executable + + + + + + + + + + + + + + + + diff --git a/data/icons/hicolor/symbolic/apps/de.thetek.vala-gtk-template-symbolic.svg b/data/icons/hicolor/symbolic/apps/de.thetek.vala-gtk-template-symbolic.svg new file mode 100644 index 0000000..0444828 --- /dev/null +++ b/data/icons/hicolor/symbolic/apps/de.thetek.vala-gtk-template-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/icons/meson.build b/data/icons/meson.build new file mode 100644 index 0000000..a0c748d --- /dev/null +++ b/data/icons/meson.build @@ -0,0 +1,13 @@ +application_id = 'de.thetek.vala-gtk-template' + +scalable_dir = join_paths ('hicolor', 'scalable', 'apps') +install_data ( + join_paths (scalable_dir, ('@0@.svg').format (application_id)), + install_dir: join_paths (get_option ('datadir'), 'icons', scalable_dir) +) + +symbolic_dir = join_paths ('hicolor', 'symbolic', 'apps') +install_data ( + join_paths (symbolic_dir, ('@0@-symbolic.svg').format (application_id)), + install_dir: join_paths (get_option ('datadir'), 'icons', symbolic_dir) +) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..3db3fc3 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,39 @@ +desktop_file = i18n.merge_file ( + input: 'de.thetek.vala-gtk-template.desktop.in', + output: 'de.thetek.vala-gtk-template.desktop', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths (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 + +appstream_file = i18n.merge_file ( + input: 'de.thetek.vala-gtk-template.appdata.xml.in', + output: 'de.thetek.vala-gtk-template.appdata.xml', + po_dir: '../po', + install: true, + install_dir: join_paths (get_option ('datadir'), 'appdata') +) + +appstream_util = find_program ('appstream-util', required: false) +if appstream_util.found () + test ('Validate appstream file', appstream_util, args: [ 'validate', appstream_file ]) +endif + +install_data('de.thetek.vala-gtk-template.gschema.xml', + install_dir: join_paths (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_source_dir () ]) +endif + +subdir ('icons') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..cba3a81 --- /dev/null +++ b/meson.build @@ -0,0 +1,18 @@ +project ('vala-gtk4-template', ['c', 'vala'], + version: '0.1.0', + meson_version: '>= 0.59.0', + default_options: [ 'warning_level=2', 'werror=false' ], +) + +i18n = import ('i18n') +gnome = import ('gnome') + +subdir ('data') +subdir ('src') +subdir ('po') + +gnome.post_install ( + glib_compile_schemas: true, + gtk_update_icon_cache: true, + update_desktop_database: true, +) diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e69de29 diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..c55ece8 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,6 @@ +data/de.thetek.vala-gtk-template.desktop.in +data/de.thetek.vala-gtk-template.appdata.xml.in +data/de.thetek.vala-gtk-template.gschema.xml +src/main.vala +src/window.vala +src/ui/window.ui diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..a1d5e2f --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext ('vala-gtk-template', preset: 'glib') diff --git a/src/app.vala b/src/app.vala new file mode 100644 index 0000000..0c9ebc8 --- /dev/null +++ b/src/app.vala @@ -0,0 +1,50 @@ +namespace ValaGtkTemplate { + public class Application : Adw.Application { + public Application () { + Object ( + application_id: "de.thetek.vala-gtk-template", + flags: ApplicationFlags.FLAGS_NONE + ); + } + + construct { + ActionEntry[] action_entries = { + { "about", this.on_about_action }, + { "preferences", this.on_preferences_action }, + { "quit", this.quit }, + }; + this.add_action_entries (action_entries, this); + this.set_accels_for_action ("app.quit", { "q" }); + } + + public override void activate () { + base.activate (); + var win = this.active_window ?? new ValaGtkTemplate.Window (this); + + var css_provider = new Gtk.CssProvider (); + css_provider.load_from_resource ("/de/thetek/vala-gtk-template/css/style.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER); + + win.present (); + } + + private void on_about_action () { + string[] developers = { "thetek" }; + var about = new Adw.AboutWindow () { + transient_for = this.active_window, + application_name = "vala-gtk-template", + application_icon = "de.thetek.vala-gtk-template", + developer_name = "thetek", + version = "0.1.0", + developers = developers, + copyright = "© 2023 thetek", + }; + + about.present (); + } + + private void on_preferences_action () { + message ("app.preferences action activated"); + } + } +} diff --git a/src/css/style.css b/src/css/style.css new file mode 100644 index 0000000..c6dd2c8 --- /dev/null +++ b/src/css/style.css @@ -0,0 +1,3 @@ +.red { + color: red; +} diff --git a/src/main.vala b/src/main.vala new file mode 100644 index 0000000..ba0158c --- /dev/null +++ b/src/main.vala @@ -0,0 +1,4 @@ +int main (string[] args) { + var app = new ValaGtkTemplate.Application (); + return app.run (args); +} diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..4b81198 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,30 @@ +sources = [ + 'main.vala', + 'app.vala', + 'window.vala', +] + +deps = [ + dependency ('gtk4'), + dependency ('libadwaita-1'), +] + +blueprints = custom_target ('blueprints', + input: files ( + 'ui/window.blp', + ), + output: '.', + command: [ find_program ('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@' ], +) + +sources += gnome.compile_resources ('vala-gtk-template-resources', + 'vala-gtk-template.gresource.xml', + c_name: 'vala_gtk_template', + dependencies: blueprints, +) + +executable ('vala-gtk-template', sources, + dependencies: deps, + vala_args: [ '--gresourcesdir=src/' ], + install: true, +) diff --git a/src/ui/window.blp b/src/ui/window.blp new file mode 100644 index 0000000..2d3d15f --- /dev/null +++ b/src/ui/window.blp @@ -0,0 +1,40 @@ +using Gtk 4.0; +using Adw 1; + +template ValaGtkTemplateWindow : Adw.ApplicationWindow { + title: _("ValaGtkTemplate"); + default-width: 1280; + default-height: 720; + + Gtk.Box { + orientation: vertical; + + Adw.HeaderBar { + [end] + Gtk.MenuButton { + icon-name: "open-menu-symbolic"; + menu-model: primary_menu; + } + } + + Gtk.Label { + styles ["red"] + hexpand: true; + vexpand: true; + label: "ValaGtkTemplate"; + } + } +} + +menu primary_menu { + section { + item { + label: _("Preferences"); + action: "app.preferences"; + } + item { + label: _("About ValaGtkTemplate"); + action: "app.about"; + } + } +} diff --git a/src/vala-gtk-template.gresource.xml b/src/vala-gtk-template.gresource.xml new file mode 100644 index 0000000..9f769df --- /dev/null +++ b/src/vala-gtk-template.gresource.xml @@ -0,0 +1,9 @@ + + + + + ui/window.ui + + css/style.css + + diff --git a/src/window.vala b/src/window.vala new file mode 100644 index 0000000..cd3b923 --- /dev/null +++ b/src/window.vala @@ -0,0 +1,8 @@ +namespace ValaGtkTemplate { + [GtkTemplate (ui = "/de/thetek/vala-gtk-template/ui/window.ui")] + public class Window : Adw.ApplicationWindow { + public Window (Gtk.Application app) { + Object (application: app); + } + } +} diff --git a/subprojects/blueprint-compiler.wrap b/subprojects/blueprint-compiler.wrap new file mode 100644 index 0000000..5c978d6 --- /dev/null +++ b/subprojects/blueprint-compiler.wrap @@ -0,0 +1,8 @@ +[wrap-git] +directory = blueprint-compiler +url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git +revision = main +depth = 1 + +[provide] +program_names = blueprint-compiler