diff --git a/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml b/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml index 9fde31f3773e09a00fcf016c1cb0719e48474826..e687985e8ebc117b8f07ed903c6c77bd3c3902a8 100644 --- a/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml +++ b/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml @@ -5,11 +5,11 @@ edition = "2021" [dependencies] gettext-rs = { version = "0.7", features = ["gettext-system"] } -gtk = { version = "0.5", package = "gtk4" } +gtk = { version = "0.6", package = "gtk4" } {{if is_adwaita}} [dependencies.adw] package = "libadwaita" -version = "0.2" +version = "0.3" features = ["v1_2"] {{end}} diff --git a/src/plugins/meson-templates/resources/src/application-gtk4.rs b/src/plugins/meson-templates/resources/src/application-gtk4.rs index 7824eb733dcb2f59ff7f8b98b190e9164f921137..78eb9865e54ce174b8a294d68b21e0bd07b56648 100644 --- a/src/plugins/meson-templates/resources/src/application-gtk4.rs +++ b/src/plugins/meson-templates/resources/src/application-gtk4.rs @@ -27,7 +27,7 @@ mod imp { impl ObjectImpl for {{PreFix}}Application { fn constructed(&self) { self.parent_constructed(); - let obj = self.instance(); + let obj = self.obj(); obj.setup_gactions(); obj.set_accels_for_action("app.quit", &["q"]); } @@ -39,7 +39,7 @@ mod imp { // tries to launch a "second instance" of the application. When they try // to do that, we'll just present any existing window. fn activate(&self) { - let application = self.instance(); + let application = self.obj(); // Get the current window or create one if necessary let window = if let Some(window) = application.active_window() { window @@ -68,7 +68,10 @@ glib::wrapper! { impl {{PreFix}}Application { pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self { - glib::Object::new(&[("application-id", &application_id), ("flags", flags)]) + glib::Object::builder() + .property("application-id", application_id) + .property("flags", flags) + .build() } fn setup_gactions(&self) { @@ -78,7 +81,7 @@ impl {{PreFix}}Application { let about_action = gio::ActionEntry::builder("about") .activate(move |app: &Self, _, _| app.show_about()) .build(); - self.add_action_entries([quit_action, about_action]).unwrap(); + self.add_action_entries([quit_action, about_action]); } fn show_about(&self) { @@ -90,7 +93,7 @@ impl {{PreFix}}Application { .application_icon("{{appid}}") .developer_name("{{author}}") .version(VERSION) - .developers(vec!["{{author}}".into()]) + .developers(vec!["{{author}}"]) .copyright("© {{year}} {{author}}") .build(); {{else}} @@ -100,7 +103,7 @@ impl {{PreFix}}Application { .program_name("{{name}}") .logo_icon_name("{{appid}}") .version(VERSION) - .authors(vec!["{{author}}".into()]) + .authors(vec!["{{author}}"]) .copyright("© {{year}} {{author}}") .build(); {{end}} diff --git a/src/plugins/meson-templates/resources/src/main-gtk4.rs b/src/plugins/meson-templates/resources/src/main-gtk4.rs index 25e5dab9999488a9b8abe9e6671bc2c42d849e02..3d98cdfb859f514cc70239c599c93c7827370933 100644 --- a/src/plugins/meson-templates/resources/src/main-gtk4.rs +++ b/src/plugins/meson-templates/resources/src/main-gtk4.rs @@ -9,10 +9,10 @@ use self::window::{{PreFix}}Window; use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR}; use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain}; -use gtk::gio; +use gtk::{gio, glib}; use gtk::prelude::*; -fn main() { +fn main() -> glib::ExitCode { // Set up gettext translations bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8") @@ -33,5 +33,5 @@ fn main() { // exits. Upon return, we have our exit code to return to the shell. (This // is the code you see when you do `echo $?` after running a command in a // terminal. - std::process::exit(app.run()); + app.run() } diff --git a/src/plugins/meson-templates/resources/src/window-gtk4.rs b/src/plugins/meson-templates/resources/src/window-gtk4.rs index 1311e9cff32d1d54f020d05777487491f2c7d899..2e8535b0e212916df9b2aae7934b87bf0474d58b 100644 --- a/src/plugins/meson-templates/resources/src/window-gtk4.rs +++ b/src/plugins/meson-templates/resources/src/window-gtk4.rs @@ -53,6 +53,8 @@ glib::wrapper! { impl {{PreFix}}Window { pub fn new>(application: &P) -> Self { - glib::Object::new(&[("application", application)]) + glib::Object::builder() + .property("application", application) + .build() } }