From ab20d2e62f9d8db00f9d355f46efb0f683e17ca6 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Sat, 29 Jul 2023 11:03:01 +0200 Subject: [PATCH] :arrow_up: Update GTK (#153) --- Cargo.lock | 239 ++++++++++++------ Cargo.toml | 8 +- src/gui/feed/error_label.rs | 20 +- src/gui/feed/feed_item.rs | 24 +- src/gui/feed/feed_item_object.rs | 58 ++--- src/gui/feed/feed_list.rs | 37 +-- src/gui/feed/feed_page.rs | 42 +-- src/gui/feed/thumbnail.rs | 21 +- src/gui/filter/filter_item.rs | 22 +- src/gui/filter/filter_item_object.rs | 21 +- src/gui/filter/filter_list.rs | 28 +- src/gui/filter/filter_page.rs | 18 +- src/gui/header_bar.rs | 24 +- src/gui/import_window.rs | 6 +- src/gui/preferences_window.rs | 6 +- src/gui/subscription/platform.rs | 15 +- src/gui/subscription/subscription_item.rs | 32 +-- .../subscription/subscription_item_object.rs | 19 +- src/gui/subscription/subscription_list.rs | 35 +-- src/gui/subscription/subscription_page.rs | 34 +-- src/gui/watch_later.rs | 4 +- src/gui/window.rs | 14 +- src/main.rs | 4 +- 23 files changed, 342 insertions(+), 389 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a62cdaf..9250167 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,24 +146,25 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cairo-rs" -version = "0.15.12" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" +checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a" dependencies = [ "bitflags 1.3.2", "cairo-sys-rs", - "glib", + "glib 0.17.10", "libc", + "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.15.1" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" +checksum = "691d0c66b1fb4881be80a760cb8fe76ea97218312f9dfe2c9cc0f496ca279cb1" dependencies = [ - "glib-sys", + "glib-sys 0.17.10", "libc", "system-deps", ] @@ -550,59 +551,60 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.15.11" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" +checksum = "695d6bc846438c5708b07007537b9274d883373dd30858ca881d7d71b5540717" dependencies = [ "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", - "glib", + "glib 0.17.10", "libc", + "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" +checksum = "9285ec3c113c66d7d0ab5676599176f1f42f4944ca1b581852215bf5694870cb" dependencies = [ "gio-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "libc", "system-deps", ] [[package]] name = "gdk4" -version = "0.4.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabb7cf843c26b085a5d68abb95d0c0bf27a9ae2eeff9c4adb503a1eb580876" +checksum = "c3abf96408a26e3eddf881a7f893a1e111767137136e347745e8ea6ed12731ff" dependencies = [ "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk4-sys", "gio", - "glib", + "glib 0.17.10", "libc", - "pango", + "pango 0.17.10", ] [[package]] name = "gdk4-sys" -version = "0.4.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efe7dcb44f5c00aeabff3f69abfc5673de46559070f89bd3fbb7b66485d9cef2" +checksum = "1bc92aa1608c089c49393d014c38ac0390d01e4841e1fedaa75dbcef77aaed64" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", "gio-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "libc", - "pango-sys", + "pango-sys 0.17.10", "pkg-config", "system-deps", ] @@ -658,29 +660,32 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "gio" -version = "0.15.12" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" +checksum = "a6973e92937cf98689b6a054a9e56c657ed4ff76de925e36fc331a15f0c5d30a" dependencies = [ "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", + "futures-util", "gio-sys", - "glib", + "glib 0.17.10", "libc", "once_cell", + "pin-project-lite", + "smallvec", "thiserror", ] [[package]] name = "gio-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" +checksum = "0ccf87c30a12c469b6d958950f6a9c09f2be20b7773f7e70d20b867fdf2628c3" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "libc", "system-deps", "winapi", @@ -697,15 +702,38 @@ dependencies = [ "futures-core", "futures-executor", "futures-task", - "glib-macros", - "glib-sys", - "gobject-sys", + "glib-macros 0.15.13", + "glib-sys 0.15.10", + "gobject-sys 0.15.10", "libc", "once_cell", "smallvec", "thiserror", ] +[[package]] +name = "glib" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b" +dependencies = [ + "bitflags 1.3.2", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", + "glib-macros 0.17.10", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", + "libc", + "memchr", + "once_cell", + "smallvec", + "thiserror", +] + [[package]] name = "glib-macros" version = "0.15.13" @@ -721,6 +749,21 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "glib-macros" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26" +dependencies = [ + "anyhow", + "heck", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "glib-sys" version = "0.15.10" @@ -731,6 +774,16 @@ dependencies = [ "system-deps", ] +[[package]] +name = "glib-sys" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "glob" version = "0.3.1" @@ -743,29 +796,40 @@ version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" dependencies = [ - "glib-sys", + "glib-sys 0.15.10", + "libc", + "system-deps", +] + +[[package]] +name = "gobject-sys" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062" +dependencies = [ + "glib-sys 0.17.10", "libc", "system-deps", ] [[package]] name = "graphene-rs" -version = "0.15.1" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c54f9fbbeefdb62c99f892dfca35f83991e2cb5b46a8dc2a715e58612f85570" +checksum = "def4bb01265b59ed548b05455040d272d989b3012c42d4c1bbd39083cb9b40d9" dependencies = [ - "glib", + "glib 0.17.10", "graphene-sys", "libc", ] [[package]] name = "graphene-sys" -version = "0.15.10" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa691fc7337ba1df599afb55c3bcb85c04f1b3f17362570e9bb0ff0d1bc3028a" +checksum = "1856fc817e6a6675e36cea0bd9a3afe296f5d9709d1e2d3182803ac77f0ab21d" dependencies = [ - "glib-sys", + "glib-sys 0.17.10", "libc", "pkg-config", "system-deps", @@ -773,41 +837,41 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.4.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e9020d333280b3aa38d496495bfa9b50712eebf1ad63f0ec5bcddb5eb61be4" +checksum = "6f01ef44fa7cac15e2da9978529383e6bee03e570ba5bf7036b4c10a15cc3a3c" dependencies = [ "bitflags 1.3.2", "cairo-rs", "gdk4", - "glib", + "glib 0.17.10", "graphene-rs", "gsk4-sys", "libc", - "pango", + "pango 0.17.10", ] [[package]] name = "gsk4-sys" -version = "0.4.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7add39ccf60078508c838643a2dcc91f045c46ed63b5ea6ab701b2e25bda3fea" +checksum = "c07a84fb4dcf1323d29435aa85e2f5f58bef564342bef06775ec7bd0da1f01b0" dependencies = [ "cairo-sys-rs", "gdk4-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "graphene-sys", "libc", - "pango-sys", + "pango-sys 0.17.10", "system-deps", ] [[package]] name = "gtk4" -version = "0.4.9" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e8ae5aef2793bc3551b5e5e3fa062a5de54bb1eccf10dfa4effe9e4384fbbbc" +checksum = "b28a32a04cd75cef14a0983f8b0c669e0fe152a0a7725accdeb594e2c764c88b" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -816,47 +880,46 @@ dependencies = [ "gdk-pixbuf", "gdk4", "gio", - "glib", + "glib 0.17.10", "graphene-rs", "gsk4", "gtk4-macros", "gtk4-sys", "libc", "once_cell", - "pango", + "pango 0.17.10", ] [[package]] name = "gtk4-macros" -version = "0.4.10" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aba0b544e91a753068e279e99d34e9624b8cfd26282167024c8a5773b8a826c" +checksum = "6a4d6b61570f76d3ee542d984da443b1cd69b6105264c61afec3abed08c2500f" dependencies = [ "anyhow", "proc-macro-crate", "proc-macro-error", "proc-macro2", - "quick-xml", "quote", "syn 1.0.109", ] [[package]] name = "gtk4-sys" -version = "0.4.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc8006eea634b7c72da3ff79e24606e45f21b3b832a3c5a1f543f5f97eb0f63" +checksum = "5f8283f707b07e019e76c7f2934bdd4180c277e08aa93f4c0d8dd07b7a34e22f" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", "gdk4-sys", "gio-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "graphene-sys", "gsk4-sys", "libc", - "pango-sys", + "pango-sys 0.17.10", "system-deps", ] @@ -1137,36 +1200,34 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libadwaita" -version = "0.2.0-alpha.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73815fa30ca62d1db2713fe87cfd1cea41cad076ccdece6bb8328032db152f47" +checksum = "1ab9c0843f9f23ff25634df2743690c3a1faffe0a190e60c490878517eb81abf" dependencies = [ "bitflags 1.3.2", - "futures-channel", "gdk-pixbuf", "gdk4", "gio", - "glib", + "glib 0.17.10", "gtk4", "libadwaita-sys", "libc", - "once_cell", - "pango", + "pango 0.17.10", ] [[package]] name = "libadwaita-sys" -version = "0.2.0-alpha.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91960ec236b6fecdace0491ae1e4aac938d1c6adffd5939f811f3ed6592a59e" +checksum = "4231cb2499a9f0c4cdfa4885414b33e39901ddcac61150bc0bb4ff8a57ede404" dependencies = [ "gdk4-sys", "gio-sys", - "glib-sys", - "gobject-sys", + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "gtk4-sys", "libc", - "pango-sys", + "pango-sys 0.17.10", "system-deps", ] @@ -1492,10 +1553,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" dependencies = [ "bitflags 1.3.2", - "glib", + "glib 0.15.12", + "libc", + "once_cell", + "pango-sys 0.15.10", +] + +[[package]] +name = "pango" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35be456fc620e61f62dff7ff70fbd54dcbaf0a4b920c0f16de1107c47d921d48" +dependencies = [ + "bitflags 1.3.2", + "gio", + "glib 0.17.10", "libc", "once_cell", - "pango-sys", + "pango-sys 0.17.10", ] [[package]] @@ -1504,8 +1579,20 @@ version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" dependencies = [ - "glib-sys", - "gobject-sys", + "glib-sys 0.15.10", + "gobject-sys 0.15.10", + "libc", + "system-deps", +] + +[[package]] +name = "pango-sys" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da69f9f3850b0d8990d462f8c709561975e95f689c1cdf0fecdebde78b35195" +dependencies = [ + "glib-sys 0.17.10", + "gobject-sys 0.17.10", "libc", "system-deps", ] @@ -2423,7 +2510,7 @@ dependencies = [ "libadwaita", "log", "once_cell", - "pango", + "pango 0.15.10", "regex", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0eef9d8..054c858 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -gtk = { version = "0.4.9", package = "gtk4" } -gdk-pixbuf = "0.15.11" -gdk = { version = "0.4.8", package = "gdk4" } +gtk = { version = "0.6.6", package = "gtk4" } +gdk-pixbuf = "0.17.10" +gdk = { version = "0.6.3", package = "gdk4" } pango = "0.15.10" -libadwaita = { version = "0.2.0-alpha.3", features = ["v1_2"]} +libadwaita = { version = "0.4.4", features = ["v1_2"]} tokio = {version = "1.29.1", features = ["full"]} futures = "0.3.28" diff --git a/src/gui/feed/error_label.rs b/src/gui/feed/error_label.rs index 97c9f4c..37118c6 100644 --- a/src/gui/feed/error_label.rs +++ b/src/gui/feed/error_label.rs @@ -42,7 +42,6 @@ pub mod imp { use gdk::glib::clone; use gdk::glib::MainContext; - use gdk::glib::ParamFlags; use gdk::glib::ParamSpec; use gdk::glib::ParamSpecString; use gdk::glib::Sender; @@ -136,24 +135,17 @@ pub mod imp { } impl ObjectImpl for ErrorLabel { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecString::new( - "error", - "error", - "error", - None, - ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecString::builder("error").build()]); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "error" => { let value: Option = @@ -164,7 +156,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "error" => self.error.borrow().to_value(), _ => unimplemented!(), diff --git a/src/gui/feed/feed_item.rs b/src/gui/feed/feed_item.rs index 488944e..a1cb796 100644 --- a/src/gui/feed/feed_item.rs +++ b/src/gui/feed/feed_item.rs @@ -32,7 +32,7 @@ gtk::glib::wrapper! { impl FeedItem { pub fn new(playlist_manager: PlaylistManager) -> Self { - let s: Self = Object::new(&[]).expect("Failed to create FeedItem"); + let s: Self = Object::builder::().build(); s.imp().playlist_manager.replace(Some(playlist_manager)); s } @@ -47,7 +47,6 @@ pub mod imp { use gdk::glib::ParamSpecObject; use gdk::glib::Value; use glib::subclass::InitializingObject; - use glib::ParamFlags; use glib::ParamSpec; use gtk::glib; use gtk::prelude::*; @@ -134,37 +133,30 @@ pub mod imp { } impl ObjectImpl for FeedItem { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecObject::new( - "video", - "video", - "video", - VideoObject::static_type(), - ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecObject::builder::("video").build()]); PROPERTIES.as_ref() } - fn set_property(&self, obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "video" => { let value: Option = value.get().expect("Property video of incorrect type"); self.video.replace(value); self.bind_watch_later(); - self.setup_actions(obj); + self.setup_actions(&self.obj()); } _ => unimplemented!(), } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "video" => self.video.borrow().to_value(), _ => unimplemented!(), diff --git a/src/gui/feed/feed_item_object.rs b/src/gui/feed/feed_item_object.rs index fa74f4d..79d8e69 100644 --- a/src/gui/feed/feed_item_object.rs +++ b/src/gui/feed/feed_item_object.rs @@ -34,7 +34,7 @@ use crate::player::play; macro_rules! str_prop { ( $x:expr ) => { - ParamSpecString::new($x, $x, $x, None, ParamFlags::READWRITE) + ParamSpecString::builder($x).build() }; } @@ -75,22 +75,21 @@ gtk::glib::wrapper! { impl VideoObject { pub fn new(video: AnyVideo) -> Self { - let s: Self = Object::new(&[ - ("title", &video.title()), - ("url", &video.url()), - ("thumbnail-url", &video.thumbnail_url()), - ("author", &video.subscription().to_string()), - ("platform", &video.platform().to_string()), - ( + let s: Self = Object::builder::() + .property("title", &video.title()) + .property("url", &video.url()) + .property("thumbnail-url", &video.thumbnail_url()) + .property("author", &video.subscription().to_string()) + .property("platform", &video.platform().to_string()) + .property( "date", &video .uploaded() .format(&gettextrs::gettext("%F %T")) .to_string(), - ), - ("playing", &false), - ]) - .expect("Failed to create `VideoObject`."); + ) + .property("playing", &false) + .build(); s.imp().video.swap(&RefCell::new(Some(video))); s } @@ -144,18 +143,18 @@ impl VideoObject { } mod imp { - use gtk::glib; + use gtk::glib::{self, Object}; use std::cell::{Cell, RefCell}; use tf_join::AnyVideo; use gdk::{ - glib::{ParamFlags, ParamSpec, ParamSpecBoolean, ParamSpecString, Value}, + glib::{ParamSpec, ParamSpecBoolean, ParamSpecString, Value}, prelude::ToValue, subclass::prelude::{ObjectImpl, ObjectSubclass}, }; use once_cell::sync::Lazy; - #[derive(Default, Clone)] + #[derive(Default)] pub struct VideoObject { title: RefCell>, author: RefCell>, @@ -175,6 +174,7 @@ mod imp { impl ObjectSubclass for VideoObject { const NAME: &'static str = "TFVideoObject"; type Type = super::VideoObject; + type ParentType = Object; } impl ObjectImpl for VideoObject { @@ -188,33 +188,15 @@ mod imp { str_prop!("platform"), str_prop!("date"), str_prop!("local-path"), - ParamSpecBoolean::new( - "playing", - "playing", - "playing", - false, - ParamFlags::READWRITE, - ), - ParamSpecBoolean::new( - "downloading", - "downloading", - "downloading", - false, - ParamFlags::READWRITE, - ), - ParamSpecBoolean::new( - "is-local", - "is-local", - "is-local", - false, - ParamFlags::READABLE, - ), + ParamSpecBoolean::builder("playing").build(), + ParamSpecBoolean::builder("downloading").build(), + ParamSpecBoolean::builder("is-local").build(), ] }); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { if pspec.name() == "playing" { self.playing .set(value.get().expect("Expect 'playing' to be a boolean.")); @@ -245,7 +227,7 @@ mod imp { ); } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { if pspec.name() == "playing" { return self.playing.get().to_value(); } diff --git a/src/gui/feed/feed_list.rs b/src/gui/feed/feed_list.rs index 702a30c..eb44107 100644 --- a/src/gui/feed/feed_list.rs +++ b/src/gui/feed/feed_list.rs @@ -152,7 +152,6 @@ pub mod imp { use std::cell::{Cell, RefCell}; use gdk::gio::ListStore; - use gdk::glib::ParamFlags; use gdk::glib::ParamSpec; use gdk::glib::ParamSpecBoolean; use gdk::glib::Value; @@ -192,7 +191,7 @@ pub mod imp { impl FeedList { pub(super) fn setup(&self) { let model = gtk::gio::ListStore::new(VideoObject::static_type()); - let selection_model = gtk::NoSelection::new(Some(&model)); + let selection_model = gtk::NoSelection::new(Some(model.clone())); self.feed_list.get().set_model(Some(&selection_model)); self.model.replace(model); @@ -225,7 +224,7 @@ pub mod imp { video_object.play(); }); - self.instance().setup_autoload(); + self.obj().setup_autoload(); } } @@ -234,7 +233,11 @@ pub mod imp { #[template_callback] fn edge_reached(&self, pos: PositionType) { if pos == PositionType::Bottom { - let _ = WidgetExt::activate_action(&self.instance(), "feed.more", None); + let _ = gtk::prelude::WidgetExt::activate_action( + self.obj().as_ref(), + "feed.more", + None, + ); } } } @@ -256,34 +259,22 @@ pub mod imp { } impl ObjectImpl for FeedList { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - obj.add_actions(); + fn constructed(&self) { + self.parent_constructed(); + self.obj().add_actions(); } fn properties() -> &'static [ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - ParamSpecBoolean::new( - "more-available", - "more-available", - "more-available", - false, - ParamFlags::READWRITE, - ), - ParamSpecBoolean::new( - "is-empty", - "is-empty", - "is-empty", - false, - ParamFlags::READABLE, - ), + ParamSpecBoolean::builder("more-available").build(), + ParamSpecBoolean::builder("is-empty").build(), ] }); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "more-available" => { let value: bool = value @@ -295,7 +286,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "more-available" => self.more_available.get().to_value(), "is-empty" => (self.model.borrow().n_items() == 0).to_value(), diff --git a/src/gui/feed/feed_page.rs b/src/gui/feed/feed_page.rs index b9a1de6..2d13172 100644 --- a/src/gui/feed/feed_page.rs +++ b/src/gui/feed/feed_page.rs @@ -47,14 +47,13 @@ pub mod imp { use gdk::glib::clone; use gdk::glib::MainContext; - use gdk::glib::ParamFlags; use gdk::glib::ParamSpec; use gdk::glib::ParamSpecBoolean; use gdk::glib::PRIORITY_DEFAULT; - use gdk_pixbuf::gio::Settings; - use gdk_pixbuf::glib::subclass::Signal; use glib::subclass::InitializingObject; + use gtk::gio::Settings; use gtk::glib; + use gtk::glib::subclass::Signal; use gtk::prelude::*; use gtk::subclass::prelude::*; @@ -207,30 +206,17 @@ pub mod imp { } impl ObjectImpl for FeedPage { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [glib::ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecBoolean::new( - "reloading", - "reloading", - "reloading", - false, - ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecBoolean::builder("reloading").build()]); PROPERTIES.as_ref() } - fn set_property( - &self, - _obj: &Self::Type, - _id: usize, - value: &glib::Value, - pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { match pspec.name() { "reloading" => { let _ = self.reloading.replace( @@ -243,7 +229,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { "reloading" => self.reloading.get().to_value(), _ => unimplemented!(), @@ -251,16 +237,8 @@ pub mod imp { } fn signals() -> &'static [Signal] { - static SIGNALS: Lazy> = Lazy::new(|| { - vec![Signal::builder( - "add-subscription", - // Types of the values which will be sent to the signal handler - &[], - // Type of the value the signal handler sends back - <()>::static_type().into(), - ) - .build()] - }); + static SIGNALS: Lazy> = + Lazy::new(|| vec![Signal::builder("add-subscription").build()]); SIGNALS.as_ref() } } diff --git a/src/gui/feed/thumbnail.rs b/src/gui/feed/thumbnail.rs index 3eb6552..817bb59 100644 --- a/src/gui/feed/thumbnail.rs +++ b/src/gui/feed/thumbnail.rs @@ -105,7 +105,6 @@ pub mod imp { use gdk::glib::ParamSpecObject; use gdk::glib::Value; use glib::subclass::InitializingObject; - use glib::ParamFlags; use glib::ParamSpec; use gtk::glib; use gtk::prelude::*; @@ -140,8 +139,9 @@ pub mod imp { } impl ObjectImpl for Thumbnail { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + let obj = self.obj(); + self.parent_constructed(); obj.connect_notify_local( Some("video"), clone!(@strong obj => move |_, _| { @@ -151,19 +151,12 @@ pub mod imp { } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecObject::new( - "video", - "video", - "video", - Option::::static_type(), - ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecObject::builder::("video").build()]); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "video" => { let value: Option = @@ -174,7 +167,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "video" => self.video.borrow().to_value(), _ => unimplemented!(), diff --git a/src/gui/filter/filter_item.rs b/src/gui/filter/filter_item.rs index 5ee93e8..b0f0f91 100644 --- a/src/gui/filter/filter_item.rs +++ b/src/gui/filter/filter_item.rs @@ -34,7 +34,7 @@ gtk::glib::wrapper! { impl FilterItem { pub fn new(filter_group: Arc>>) -> Self { - let s: Self = Object::new(&[]).expect("Failed to create FilterItem"); + let s: Self = Object::builder::().build(); s.imp().filter_group.replace(Some(filter_group)); s } @@ -49,7 +49,6 @@ pub mod imp { use gdk::glib::ParamSpecObject; use gdk::glib::Value; use glib::subclass::InitializingObject; - use glib::ParamFlags; use glib::ParamSpec; use gtk::glib; use gtk::prelude::*; @@ -108,24 +107,17 @@ pub mod imp { } impl ObjectImpl for FilterItem { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecObject::new( - "filter", - "filter", - "filter", - FilterObject::static_type(), - ParamFlags::READWRITE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecObject::builder::("filter").build()]); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "filter" => { let value: Option = @@ -137,7 +129,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "filter" => self.filter.borrow().to_value(), _ => unimplemented!(), diff --git a/src/gui/filter/filter_item_object.rs b/src/gui/filter/filter_item_object.rs index 7e9af57..4c47cfa 100644 --- a/src/gui/filter/filter_item_object.rs +++ b/src/gui/filter/filter_item_object.rs @@ -26,7 +26,7 @@ use tf_join::AnyVideoFilter; macro_rules! str_prop { ( $x:expr ) => { - ParamSpecString::new($x, $x, $x, None, ParamFlags::READWRITE) + ParamSpecString::builder($x).build() }; } @@ -67,14 +67,13 @@ gtk::glib::wrapper! { impl FilterObject { pub fn new(filter: AnyVideoFilter) -> Self { - let s: Self = Object::new(&[ - ("title", &filter.title_str().unwrap_or_default().to_string()), - ( + let s: Self = Object::builder::() + .property("title", &filter.title_str().unwrap_or_default().to_string()) + .property( "channel", &filter.subscription_str().unwrap_or_default().to_string(), - ), - ]) - .expect("Failed to create `FilterObject`."); + ) + .build(); s.imp().filter.swap(&RefCell::new(Some(filter))); s } @@ -90,13 +89,13 @@ mod imp { use tf_join::AnyVideoFilter; use gdk::{ - glib::{ParamFlags, ParamSpec, ParamSpecString, Value}, + glib::{ParamSpec, ParamSpecString, Value}, prelude::ToValue, subclass::prelude::{ObjectImpl, ObjectSubclass}, }; use once_cell::sync::Lazy; - #[derive(Default, Clone)] + #[derive(Default)] pub struct FilterObject { title: RefCell>, channel: RefCell>, @@ -117,11 +116,11 @@ mod imp { PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { prop_set_all!(value, pspec, "title", self.title, "channel", self.channel); } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { prop_get_all!(pspec, "title", self.title, "channel", self.channel) } } diff --git a/src/gui/filter/filter_list.rs b/src/gui/filter/filter_list.rs index c3df136..86b07f4 100644 --- a/src/gui/filter/filter_list.rs +++ b/src/gui/filter/filter_list.rs @@ -86,12 +86,11 @@ pub mod imp { use gdk::glib::MainContext; use gdk::glib::Sender; use gdk::glib::PRIORITY_DEFAULT; - use gdk_pixbuf::glib::ParamFlags; - use gdk_pixbuf::glib::ParamSpec; - use gdk_pixbuf::glib::ParamSpecBoolean; - use gdk_pixbuf::glib::Value; use glib::subclass::InitializingObject; use gtk::glib; + use gtk::glib::ParamSpec; + use gtk::glib::ParamSpecBoolean; + use gtk::glib::Value; use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::SignalListItemFactory; @@ -167,7 +166,7 @@ pub mod imp { pub fn setup_list(&self) { let model = gtk::gio::ListStore::new(FilterObject::static_type()); - let selection_model = gtk::NoSelection::new(Some(&model)); + let selection_model = gtk::NoSelection::new(Some(model.clone())); self.filter_list.get().set_model(Some(&selection_model)); self.model.replace(model); @@ -206,28 +205,21 @@ pub mod imp { } impl ObjectImpl for FilterList { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecBoolean::new( - "is-empty", - "is-empty", - "is-empty", - false, - ParamFlags::READABLE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecBoolean::builder("is-empty").build()]); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, _value: &Value, _pspec: &ParamSpec) { + fn set_property(&self, _id: usize, _value: &Value, _pspec: &ParamSpec) { unimplemented!() } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "is-empty" => (self.model.borrow().n_items() == 0).to_value(), _ => unimplemented!(), diff --git a/src/gui/filter/filter_page.rs b/src/gui/filter/filter_page.rs index 1ccda70..5abc0c3 100644 --- a/src/gui/filter/filter_page.rs +++ b/src/gui/filter/filter_page.rs @@ -96,7 +96,7 @@ pub mod imp { // Theoretically only needs to be done once, but when setting up the page does // not yet have a root. - let window = self.instance().window(); + let window = self.obj().window(); self.dialog_add.set_transient_for(Some(&window)); self.dialog_add.present(); } @@ -182,9 +182,9 @@ pub mod imp { } impl ObjectImpl for FilterPage { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - self.setup_toggle_add_filter(obj); + fn constructed(&self) { + self.parent_constructed(); + self.setup_toggle_add_filter(&self.obj()); } fn properties() -> &'static [glib::ParamSpec] { @@ -192,17 +192,11 @@ pub mod imp { PROPERTIES.as_ref() } - fn set_property( - &self, - _obj: &Self::Type, - _id: usize, - _value: &glib::Value, - _pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, _value: &glib::Value, _pspec: &glib::ParamSpec) { unimplemented!() } - fn property(&self, _obj: &Self::Type, _id: usize, _pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, _pspec: &glib::ParamSpec) -> glib::Value { unimplemented!() } } diff --git a/src/gui/header_bar.rs b/src/gui/header_bar.rs index 976e0f6..8419dd2 100644 --- a/src/gui/header_bar.rs +++ b/src/gui/header_bar.rs @@ -31,7 +31,7 @@ gtk::glib::wrapper! { impl HeaderBar { pub fn new() -> Self { - Object::new(&[]).expect("Failed to create HeaderBar") + Object::builder::().build() } fn window(&self) -> crate::gui::window::Window { @@ -49,7 +49,6 @@ pub mod imp { use gdk::gio::SimpleActionGroup; use gdk::glib::clone; use gdk::glib::Object; - use gdk::glib::ParamFlags; use gdk::glib::ParamSpec; use gdk::glib::ParamSpecObject; use gdk::glib::ParamSpecString; @@ -133,9 +132,10 @@ pub mod imp { } impl ObjectImpl for HeaderBar { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - self.setup_actions(obj); + fn constructed(&self) { + let obj = self.obj(); + self.parent_constructed(); + self.setup_actions(&obj); obj.connect_root_notify(clone!(@strong self.titlebar as titlebar => move |o| { if let Some(root) = o.root() { @@ -165,20 +165,14 @@ pub mod imp { fn properties() -> &'static [ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - ParamSpecString::new("title", "title", "title", None, ParamFlags::READWRITE), - ParamSpecObject::new( - "child", - "child", - "child", - Widget::static_type(), - ParamFlags::READWRITE, - ), + ParamSpecString::builder("title").build(), + ParamSpecObject::builder::("child").build(), ] }); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "title" => { let value: Option = @@ -194,7 +188,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "title" => self.title.borrow().to_value(), "child" => self.child.borrow().to_value(), diff --git a/src/gui/import_window.rs b/src/gui/import_window.rs index 36ba923..d3f1008 100644 --- a/src/gui/import_window.rs +++ b/src/gui/import_window.rs @@ -1,9 +1,9 @@ use gdk_pixbuf::glib::clone; -use gtk::builders::FileChooserNativeBuilder; use gtk::glib; use gtk::prelude::*; use gtk::Builder; use gtk::FileChooserAction; +use gtk::FileChooserNative; use gtk::FileFilter; use gtk::ResponseType; use libadwaita::traits::MessageDialogExt; @@ -32,7 +32,7 @@ fn handle_response(joiner: &Joiner, response: &str, parent: &crate::gui::window: log::debug!("Import from NewPipe"); let filter = FileFilter::new(); filter.add_mime_type("application/json"); - let chooser = FileChooserNativeBuilder::new() + let chooser = FileChooserNative::builder() .title(&gettextrs::gettext("Select NewPipe subscriptions file")) .transient_for(parent) .modal(true) @@ -62,7 +62,7 @@ fn handle_response(joiner: &Joiner, response: &str, parent: &crate::gui::window: log::debug!("Import from YouTube"); let filter = FileFilter::new(); filter.add_mime_type("text/csv"); - let chooser = FileChooserNativeBuilder::new() + let chooser = FileChooserNative::builder() .title(&gettextrs::gettext("Select YouTube subscription file")) .transient_for(parent) .filter(&filter) diff --git a/src/gui/preferences_window.rs b/src/gui/preferences_window.rs index e6e9d41..068d60b 100644 --- a/src/gui/preferences_window.rs +++ b/src/gui/preferences_window.rs @@ -9,7 +9,7 @@ gtk::glib::wrapper! { impl PreferencesWindow { pub fn new() -> Self { - Object::new(&[]).expect("Failed to create PreferencesWindow") + Object::builder().build() } } @@ -111,8 +111,8 @@ pub mod imp { } impl ObjectImpl for PreferencesWindow { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); self.init_settings(); if crate::config::FLATPAK { self.init_flatpak(); diff --git a/src/gui/subscription/platform.rs b/src/gui/subscription/platform.rs index b216ff5..35196d6 100644 --- a/src/gui/subscription/platform.rs +++ b/src/gui/subscription/platform.rs @@ -26,7 +26,7 @@ use tf_join::Platform; macro_rules! str_prop { ( $x:expr ) => { - ParamSpecString::new($x, $x, $x, None, ParamFlags::READWRITE) + ParamSpecString::builder($x).build() }; } @@ -67,8 +67,9 @@ gtk::glib::wrapper! { impl PlatformObject { pub fn new(platform: Platform) -> Self { - let s: Self = Object::new(&[("name", &platform.to_string())]) - .expect("Failed to create `PlatformObject`."); + let s: Self = Object::builder::() + .property("name", &platform.to_string()) + .build(); s.imp().platform.swap(&RefCell::new(Some(platform))); s } @@ -84,13 +85,13 @@ mod imp { use tf_join::Platform; use gdk::{ - glib::{ParamFlags, ParamSpec, ParamSpecString, Value}, + glib::{ParamSpec, ParamSpecString, Value}, prelude::ToValue, subclass::prelude::{ObjectImpl, ObjectSubclass}, }; use once_cell::sync::Lazy; - #[derive(Default, Clone)] + #[derive(Default)] pub struct PlatformObject { name: RefCell>, @@ -109,11 +110,11 @@ mod imp { PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { prop_set_all!(value, pspec, "name", self.name); } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { prop_get_all!(pspec, "name", self.name) } } diff --git a/src/gui/subscription/subscription_item.rs b/src/gui/subscription/subscription_item.rs index 4e444d1..86f5ab3 100644 --- a/src/gui/subscription/subscription_item.rs +++ b/src/gui/subscription/subscription_item.rs @@ -31,7 +31,7 @@ gtk::glib::wrapper! { impl SubscriptionItem { pub fn new(subscription_list: AnySubscriptionList) -> Self { - let s: Self = Object::new(&[]).expect("Failed to create SubscriptionItem"); + let s: Self = Object::builder().build(); s.imp().subscription_list.replace(Some(subscription_list)); s } @@ -45,7 +45,6 @@ pub mod imp { use gdk::glib::Value; use gdk_pixbuf::glib::subclass::Signal; use glib::subclass::InitializingObject; - use glib::ParamFlags; use glib::ParamSpec; use gtk::glib; use gtk::prelude::*; @@ -90,7 +89,7 @@ pub mod imp { #[template_callback] fn handle_go_to_videos(&self) { if let Some(sub) = self.subscription.borrow().as_ref() { - self.instance().emit_by_name::<()>("go-to-videos", &[&sub]); + self.obj().emit_by_name::<()>("go-to-videos", &[&sub]); } } } @@ -115,24 +114,18 @@ pub mod imp { impl SubscriptionItem {} impl ObjectImpl for SubscriptionItem { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecObject::new( - "subscription", - "subscription", - "subscription", - SubscriptionObject::static_type(), - ParamFlags::READWRITE, - )] + vec![ParamSpecObject::builder::("subscription").build()] }); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { match pspec.name() { "subscription" => { let value: Option = value @@ -145,7 +138,7 @@ pub mod imp { } } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "subscription" => self.subscription.borrow().to_value(), _ => unimplemented!(), @@ -154,14 +147,9 @@ pub mod imp { fn signals() -> &'static [Signal] { static SIGNALS: Lazy> = Lazy::new(|| { - vec![Signal::builder( - "go-to-videos", - // Types of the values which will be sent to the signal handler - &[SubscriptionObject::static_type().into()], - // Type of the value the signal handler sends back - <()>::static_type().into(), - ) - .build()] + vec![Signal::builder("go-to-videos") + .param_types([SubscriptionObject::static_type()]) + .build()] }); SIGNALS.as_ref() } diff --git a/src/gui/subscription/subscription_item_object.rs b/src/gui/subscription/subscription_item_object.rs index 08ba460..690cf69 100644 --- a/src/gui/subscription/subscription_item_object.rs +++ b/src/gui/subscription/subscription_item_object.rs @@ -28,7 +28,7 @@ use tf_join::AnySubscription; macro_rules! str_prop { ( $x:expr ) => { - ParamSpecString::new($x, $x, $x, None, ParamFlags::READWRITE) + ParamSpecString::builder($x).build() }; } @@ -69,11 +69,10 @@ gtk::glib::wrapper! { impl SubscriptionObject { pub fn new(subscription: AnySubscription) -> Self { - let s: Self = Object::new(&[ - ("name", &subscription.to_string()), - ("platform", &subscription.platform().to_string()), - ]) - .expect("Failed to create `SubscriptionObject`."); + let s: Self = Object::builder::() + .property("name", &subscription.to_string()) + .property("platform", &subscription.platform().to_string()) + .build(); s.imp().subscription.swap(&RefCell::new(Some(subscription))); s } @@ -93,13 +92,13 @@ mod imp { use tf_join::AnySubscription; use gdk::{ - glib::{ParamFlags, ParamSpec, ParamSpecString, Value}, + glib::{ParamSpec, ParamSpecString, Value}, prelude::ToValue, subclass::prelude::{ObjectImpl, ObjectSubclass}, }; use once_cell::sync::Lazy; - #[derive(Default, Clone)] + #[derive(Default)] pub struct SubscriptionObject { name: RefCell>, platform: RefCell>, @@ -120,11 +119,11 @@ mod imp { PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) { prop_set_all!(value, pspec, "name", self.name, "platform", self.platform); } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { prop_get_all!(pspec, "name", self.name, "platform", self.platform) } } diff --git a/src/gui/subscription/subscription_list.rs b/src/gui/subscription/subscription_list.rs index bc10c38..f43982e 100644 --- a/src/gui/subscription/subscription_list.rs +++ b/src/gui/subscription/subscription_list.rs @@ -108,7 +108,6 @@ pub mod imp { use gdk::glib::Sender; use gdk::glib::PRIORITY_DEFAULT; use gdk_pixbuf::glib::subclass::Signal; - use gdk_pixbuf::glib::ParamFlags; use gdk_pixbuf::glib::ParamSpec; use gdk_pixbuf::glib::ParamSpecBoolean; use gdk_pixbuf::glib::Value; @@ -215,9 +214,9 @@ pub mod imp { name_1.cmp(&name_2).into() }); - let sort_model = SortListModel::new(Some(&model), Some(&sorter)); + let sort_model = SortListModel::new(Some(model.clone()), Some(sorter.clone())); - let selection_model = gtk::NoSelection::new(Some(&sort_model)); + let selection_model = gtk::NoSelection::new(Some(sort_model)); self.subscription_list .get() .set_model(Some(&selection_model)); @@ -231,7 +230,7 @@ pub mod imp { .borrow() .clone() .expect("AnySubscriptionList should be set up"); - let instance = self.instance(); + let instance = self.obj(); factory.connect_setup(clone!(@strong instance, @strong sorter => move |_, list_item| { let subscription_item = SubscriptionItem::new(any_subscription_list.clone()); list_item.set_child(Some(&subscription_item)); @@ -279,28 +278,21 @@ pub mod imp { } impl ObjectImpl for SubscriptionList { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { - vec![ParamSpecBoolean::new( - "is-empty", - "is-empty", - "is-empty", - false, - ParamFlags::READABLE, - )] - }); + static PROPERTIES: Lazy> = + Lazy::new(|| vec![ParamSpecBoolean::builder("is-empty").read_only().build()]); PROPERTIES.as_ref() } - fn set_property(&self, _obj: &Self::Type, _id: usize, _value: &Value, _pspec: &ParamSpec) { + fn set_property(&self, _id: usize, _value: &Value, _pspec: &ParamSpec) { unimplemented!() } - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property(&self, _id: usize, pspec: &ParamSpec) -> Value { match pspec.name() { "is-empty" => (self.model.borrow().n_items() == 0).to_value(), _ => unimplemented!(), @@ -309,12 +301,9 @@ pub mod imp { fn signals() -> &'static [Signal] { static SIGNALS: Lazy> = Lazy::new(|| { - vec![Signal::builder( - "go-to-videos", - &[SubscriptionObject::static_type().into()], - <()>::static_type().into(), - ) - .build()] + vec![Signal::builder("go-to-videos") + .param_types([SubscriptionObject::static_type()]) + .build()] }); SIGNALS.as_ref() } diff --git a/src/gui/subscription/subscription_page.rs b/src/gui/subscription/subscription_page.rs index 0c6be26..a32d225 100644 --- a/src/gui/subscription/subscription_page.rs +++ b/src/gui/subscription/subscription_page.rs @@ -131,7 +131,7 @@ pub mod imp { // Theoretically only needs to be done once, but when setting up the page does // not yet have a root. - let window = self.instance().window(); + let window = self.obj().window(); self.dialog_add.set_transient_for(Some(&window)); self.dialog_add.present(); } @@ -217,7 +217,7 @@ pub mod imp { } }); - let obj = self.instance(); + let obj = self.obj(); receiver.attach( None, clone!(@strong self.any_subscription_list as list, @strong obj => @@ -253,7 +253,7 @@ pub mod imp { let videos = joiner.generate(&error_store).await; let _ = sender.send(videos); }); - let obj = self.instance(); + let obj = self.obj(); receiver.attach( None, clone!(@strong obj as s => @default-return Continue(false), move |videos| { @@ -303,9 +303,9 @@ pub mod imp { } impl ObjectImpl for SubscriptionPage { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); - self.setup_toggle_add_subscription(obj); + fn constructed(&self) { + self.parent_constructed(); + self.setup_toggle_add_subscription(&self.obj()); self.setup_platform_dropdown(); } @@ -314,31 +314,17 @@ pub mod imp { PROPERTIES.as_ref() } - fn set_property( - &self, - _obj: &Self::Type, - _id: usize, - _value: &glib::Value, - _pspec: &glib::ParamSpec, - ) { + fn set_property(&self, _id: usize, _value: &glib::Value, _pspec: &glib::ParamSpec) { unimplemented!() } - fn property(&self, _obj: &Self::Type, _id: usize, _pspec: &glib::ParamSpec) -> glib::Value { + fn property(&self, _id: usize, _pspec: &glib::ParamSpec) -> glib::Value { unimplemented!() } fn signals() -> &'static [Signal] { - static SIGNALS: Lazy> = Lazy::new(|| { - vec![Signal::builder( - "subscription-added", - // Types of the values which will be sent to the signal handler - &[], - // Type of the value the signal handler sends back - <()>::static_type().into(), - ) - .build()] - }); + static SIGNALS: Lazy> = + Lazy::new(|| vec![Signal::builder("subscription-added").build()]); SIGNALS.as_ref() } } diff --git a/src/gui/watch_later.rs b/src/gui/watch_later.rs index dd058a1..45a4db0 100644 --- a/src/gui/watch_later.rs +++ b/src/gui/watch_later.rs @@ -137,8 +137,8 @@ pub mod imp { } impl ObjectImpl for WatchLaterPage { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); } } diff --git a/src/gui/window.rs b/src/gui/window.rs index 70254c2..35889c1 100644 --- a/src/gui/window.rs +++ b/src/gui/window.rs @@ -39,7 +39,9 @@ gtk::glib::wrapper! { impl Window { pub fn new(app: >k::Application) -> Self { - Object::new(&[("application", app)]).expect("Failed to create Window") + Object::builder::() + .property("application", app) + .build() } pub fn reload(&self) { @@ -314,13 +316,14 @@ pub mod imp { } impl ObjectImpl for Window { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); self.setup_feed(); self.setup_watch_later(); self.setup_subscriptions(); self.setup_filter(); + let obj = self.obj(); if PROFILE == "Devel" { obj.add_css_class("devel"); } @@ -330,7 +333,7 @@ pub mod imp { impl WidgetImpl for Window {} impl WindowImpl for Window { - fn close_request(&self, obj: &Self::Type) -> Inhibit { + fn close_request(&self) -> Inhibit { let mut user_cache_dir = glib::user_cache_dir(); user_cache_dir.push("tubefeeder"); @@ -338,11 +341,12 @@ pub mod imp { std::fs::remove_dir_all(user_cache_dir).unwrap_or(()); } + let obj = self.obj(); if let Err(err) = obj.save_window_size() { log::warn!("Failed to save window state, {}", &err); } - self.parent_close_request(obj) + self.parent_close_request() } } impl ApplicationWindowImpl for Window {} diff --git a/src/main.rs b/src/main.rs index 649bb3d..a2246d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ use gdk::{ Display, }; use gdk_pixbuf::{gio::Settings, prelude::SettingsExt}; -use gtk::{traits::GtkWindowExt, CssProvider, StyleContext}; +use gtk::{traits::GtkWindowExt, CssProvider}; mod config; use self::config::{APP_ID, GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_BYTES}; @@ -82,7 +82,7 @@ fn init_css() { provider.load_from_resource("/de/schmidhuberj/tubefeeder/style.css"); // Add the provider to the default screen - StyleContext::add_provider_for_display( + gtk::style_context_add_provider_for_display( &Display::default().expect("Could not connect to a display."), &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,