From 305b50efaee429ea1162afc1a637c5dee3cddc4c Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 11 Feb 2023 11:40:02 +0100 Subject: [PATCH] templates: Bump GTK/Rust to latest release --- .../meson-templates/resources/src/Cargo-gtk4.toml | 4 ++-- .../resources/src/application-gtk4.rs | 15 +++++++++------ .../meson-templates/resources/src/main-gtk4.rs | 6 +++--- .../meson-templates/resources/src/window-gtk4.rs | 4 +++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml b/src/plugins/meson-templates/resources/src/Cargo-gtk4.toml index 9fde31f37..e687985e8 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 7824eb733..78eb9865e 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 25e5dab99..3d98cdfb8 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 1311e9cff..2e8535b0e 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() } } -- GitLab