From ea57ba7df78ce1d95d7a05cc6cfa9e0bbe98bf0c Mon Sep 17 00:00:00 2001 From: Lorenz Wildberg Date: Mon, 28 Feb 2022 18:30:10 +0000 Subject: [PATCH] meson-template: improve style of Vala-Gtk4 Template --- .../resources/src/application-gtk4.vala | 60 +++++++++---------- .../resources/src/main-gtk4.vala | 4 +- .../resources/src/window-gtk4.vala | 16 ++--- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/plugins/meson-templates/resources/src/application-gtk4.vala b/src/plugins/meson-templates/resources/src/application-gtk4.vala index 866f5ebe2..9ac33e639 100644 --- a/src/plugins/meson-templates/resources/src/application-gtk4.vala +++ b/src/plugins/meson-templates/resources/src/application-gtk4.vala @@ -1,40 +1,40 @@ {{include "license.vala"}} namespace {{PreFix}} { - public class Application : {{if is_adwaita}}Adw{{else}}Gtk{{end}}.Application { - private ActionEntry[] APP_ACTIONS = { - { "about", on_about_action }, - { "preferences", on_preferences_action }, - { "quit", quit } - }; + public class Application : {{if is_adwaita}}Adw{{else}}Gtk{{end}}.Application { + private ActionEntry[] APP_ACTIONS = { + { "about", this.on_about_action }, + { "preferences", this.on_preferences_action }, + { "quit", this.quit } + }; - public Application () { - Object (application_id: "{{appid}}", flags: ApplicationFlags.FLAGS_NONE); + public Application () { + Object (application_id: "{{appid}}", flags: ApplicationFlags.FLAGS_NONE); - this.add_action_entries(this.APP_ACTIONS, this); - this.set_accels_for_action("app.quit", {"q"}); - } + this.add_action_entries (this.APP_ACTIONS, this); + this.set_accels_for_action ("app.quit", {"q"}); + } - public override void activate () { - base.activate(); - var win = this.active_window; - if (win == null) { - win = new {{PreFix}}.Window (this); - } - win.present (); - } + public override void activate () { + base.activate (); + var win = this.active_window; + if (win == null) { + win = new {{PreFix}}.Window (this); + } + win.present (); + } - private void on_about_action () { - string[] authors = {"{{author}}"}; - Gtk.show_about_dialog(this.active_window, - "program-name", "{{name}}", - "authors", authors, - "version", "{{project_version}}"); - } + private void on_about_action () { + string[] authors = { "{{author}}" }; + Gtk.show_about_dialog (this.active_window, + "program-name", "{{name}}", + "authors", authors, + "version", "{{project_version}}"); + } - private void on_preferences_action () { - message("app.preferences action activated"); - } - } + private void on_preferences_action () { + message ("app.preferences action activated"); + } + } } diff --git a/src/plugins/meson-templates/resources/src/main-gtk4.vala b/src/plugins/meson-templates/resources/src/main-gtk4.vala index e8a05c989..5083b116f 100644 --- a/src/plugins/meson-templates/resources/src/main-gtk4.vala +++ b/src/plugins/meson-templates/resources/src/main-gtk4.vala @@ -1,6 +1,6 @@ {{include "license.vala"}} int main (string[] args) { - var app = new {{PreFix}}.Application (); - return app.run (args); + var app = new {{PreFix}}.Application (); + return app.run (args); } diff --git a/src/plugins/meson-templates/resources/src/window-gtk4.vala b/src/plugins/meson-templates/resources/src/window-gtk4.vala index 7ef3be410..4cacdb12f 100644 --- a/src/plugins/meson-templates/resources/src/window-gtk4.vala +++ b/src/plugins/meson-templates/resources/src/window-gtk4.vala @@ -1,13 +1,13 @@ {{include "license.vala"}} namespace {{PreFix}} { - [GtkTemplate (ui = "{{appid_path}}/{{ui_file}}")] - public class Window : Gtk.ApplicationWindow { - [GtkChild] - unowned Gtk.Label label; + [GtkTemplate (ui = "{{appid_path}}/{{ui_file}}")] + public class Window : Gtk.ApplicationWindow { + [GtkChild] + private unowned Gtk.Label label; - public Window (Gtk.Application app) { - Object (application: app); - } - } + public Window (Gtk.Application app) { + Object (application: app); + } + } } -- GitLab