Browse Source

chore: Remove once_cell dependency

Use the types in std instead. Bumps the MSRV to 1.80.
pipelines/767384
Kévin Commaille 1 year ago
parent
commit
efebc94ecf
No known key found for this signature in database
GPG Key ID: C971D9DBC9D678D
  1. 2
      CONTRIBUTING.md
  2. 1
      Cargo.lock
  3. 3
      Cargo.toml
  4. 6
      src/components/action_button.rs
  5. 8
      src/components/avatar/editable.rs
  6. 6
      src/components/avatar/image.rs
  7. 8
      src/components/crypto/identity_setup_view.rs
  8. 5
      src/components/crypto/recovery_setup_view.rs
  9. 5
      src/components/pill/search_entry.rs
  10. 6
      src/components/rows/entry_add_row.rs
  11. 7
      src/components/rows/loading_button_row.rs
  12. 7
      src/components/rows/loading_row.rs
  13. 7
      src/components/rows/removable_row.rs
  14. 5
      src/components/rows/substring_entry_row.rs
  15. 10
      src/components/scale_revealer.rs
  16. 7
      src/components/user_page.rs
  17. 5
      src/contrib/qr_code_scanner/camera/camera_paintable/mod.rs
  18. 6
      src/contrib/qr_code_scanner/camera/mod.rs
  19. 5
      src/contrib/qr_code_scanner/mod.rs
  20. 22
      src/contrib/qr_code_scanner/qr_code_detector.rs
  21. 8
      src/login/session_setup_view.rs
  22. 8
      src/main.rs
  23. 7
      src/session/model/room/aliases.rs
  24. 6
      src/session/model/room/event/mod.rs
  25. 10
      src/session/model/room/join_rule.rs
  26. 6
      src/session/model/room/mod.rs
  27. 10
      src/session/model/room/permissions.rs
  28. 6
      src/session/model/room/timeline/mod.rs
  29. 7
      src/session/model/room_list/mod.rs
  30. 4
      src/session/model/verification/identity_verification.rs
  31. 7
      src/session/model/verification/verification_list.rs
  32. 4
      src/session/view/content/room_details/invite_subpage/list.rs
  33. 7
      src/session/view/content/room_details/permissions/add_members_subpage.rs
  34. 9
      src/session/view/content/room_history/item_row.rs
  35. 5
      src/session/view/content/room_history/message_row/text/mod.rs
  36. 7
      src/session/view/content/room_history/message_toolbar/composer_state.rs
  37. 8
      src/session/view/sidebar/mod.rs
  38. 5
      src/utils/media/image/queue.rs
  39. 4
      src/utils/mod.rs

2
CONTRIBUTING.md

@ -22,7 +22,7 @@ can also provide general help about using Rust in GNOME.
### Prerequisites
Fractal is written in Rust, so you will need to have at least Rust 1.76 and Cargo available on your
Fractal is written in Rust, so you will need to have at least Rust 1.80 and Cargo available on your
system. You will also need to install the Rust nightly toolchain to be able to run our
[pre-commit hook](#pre-commit), which can be done with:

1
Cargo.lock generated

@ -1373,7 +1373,6 @@ dependencies = [
"matrix-sdk-ui",
"mime",
"mime_guess",
"once_cell",
"oo7",
"pulldown-cmark",
"qrcode",

3
Cargo.toml

@ -3,7 +3,7 @@ name = "fractal"
version = "9.0.0"
authors = ["Julian Sparber <julian@sparber.net>"]
edition = "2021"
rust-version = "1.76"
rust-version = "1.80"
publish = false
[profile.release]
@ -31,7 +31,6 @@ indexmap = "2"
linkify = "0.10.0"
mime = "0.3"
mime_guess = "2"
once_cell = "1"
pulldown-cmark = "0.12"
qrcode = "0.14"
rand = "0.8"

6
src/components/action_button.rs

@ -33,10 +33,10 @@ mod imp {
use std::{
cell::{Cell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -89,8 +89,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for ActionButton {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("clicked").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("clicked").build()]);
SIGNALS.as_ref()
}
}

8
src/components/avatar/editable.rs

@ -38,10 +38,12 @@ pub enum EditableAvatarState {
}
mod imp {
use std::cell::{Cell, RefCell};
use std::{
cell::{Cell, RefCell},
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -120,7 +122,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for EditableAvatar {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
Signal::builder("edit-avatar")
.param_types([gio::File::static_type()])

6
src/components/avatar/image.rs

@ -34,10 +34,10 @@ mod imp {
use std::{
cell::{Cell, OnceCell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -78,8 +78,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for AvatarImage {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("error-changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("error-changed").build()]);
SIGNALS.as_ref()
}
}

8
src/components/crypto/identity_setup_view.rs

@ -47,10 +47,12 @@ pub enum CryptoIdentitySetupNextStep {
}
mod imp {
use std::cell::{OnceCell, RefCell};
use std::{
cell::{OnceCell, RefCell},
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -102,7 +104,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for CryptoIdentitySetupView {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
// The crypto identity setup is done.
Signal::builder("completed")

5
src/components/crypto/recovery_setup_view.rs

@ -44,8 +44,9 @@ pub enum CryptoRecoverySetupInitialPage {
}
mod imp {
use std::sync::LazyLock;
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -111,7 +112,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for CryptoRecoverySetupView {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
// Recovery is enabled.
Signal::builder("completed").build(),

5
src/components/pill/search_entry.rs

@ -11,10 +11,9 @@ use crate::{
};
mod imp {
use std::{cell::RefCell, collections::HashMap, marker::PhantomData};
use std::{cell::RefCell, collections::HashMap, marker::PhantomData, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -56,7 +55,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for PillSearchEntry {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![Signal::builder("pill-removed")
.param_types([PillSource::static_type()])
.build()]

6
src/components/rows/entry_add_row.rs

@ -4,10 +4,9 @@ use gtk::{glib, glib::closure_local, CompositeTemplate};
use crate::components::LoadingButton;
mod imp {
use std::{cell::Cell, marker::PhantomData};
use std::{cell::Cell, marker::PhantomData, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -47,7 +46,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for EntryAddRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| vec![Signal::builder("add").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("add").build()]);
SIGNALS.as_ref()
}
}

7
src/components/rows/loading_button_row.rs

@ -9,10 +9,9 @@ use gtk::{
use crate::components::LoadingBin;
mod imp {
use std::marker::PhantomData;
use std::{marker::PhantomData, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -47,8 +46,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for LoadingButtonRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("activated").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("activated").build()]);
SIGNALS.as_ref()
}

7
src/components/rows/loading_row.rs

@ -10,10 +10,9 @@ use gtk::{
use crate::components::LoadingBin;
mod imp {
use std::marker::PhantomData;
use std::{marker::PhantomData, sync::LazyLock};
use glib::subclass::InitializingObject;
use once_cell::sync::Lazy;
use super::*;
@ -50,8 +49,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for LoadingRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("retry").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("retry").build()]);
SIGNALS.as_ref()
}

7
src/components/rows/removable_row.rs

@ -4,10 +4,9 @@ use gtk::{glib, glib::closure_local, CompositeTemplate};
use crate::components::LoadingButton;
mod imp {
use std::{cell::RefCell, marker::PhantomData};
use std::{cell::RefCell, marker::PhantomData, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -54,8 +53,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for RemovableRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("remove").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("remove").build()]);
SIGNALS.as_ref()
}
}

5
src/components/rows/substring_entry_row.rs

@ -11,10 +11,10 @@ mod imp {
use std::{
cell::{Cell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -102,7 +102,8 @@ mod imp {
impl ObjectImpl for SubstringEntryRow {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| vec![Signal::builder("add").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("add").build()]);
SIGNALS.as_ref()
}

10
src/components/scale_revealer.rs

@ -5,10 +5,12 @@ use tracing::warn;
const ANIMATION_DURATION: u32 = 250;
mod imp {
use std::cell::{Cell, OnceCell, RefCell};
use std::{
cell::{Cell, OnceCell, RefCell},
sync::LazyLock,
};
use glib::{clone, subclass::Signal};
use once_cell::sync::Lazy;
use super::*;
@ -35,8 +37,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for ScaleRevealer {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("transition-done").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("transition-done").build()]);
SIGNALS.as_ref()
}

7
src/components/user_page.rs

@ -23,10 +23,9 @@ use crate::{
};
mod imp {
use std::cell::RefCell;
use std::{cell::RefCell, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -109,8 +108,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for UserPage {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("close").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("close").build()]);
SIGNALS.as_ref()
}

5
src/contrib/qr_code_scanner/camera/camera_paintable/mod.rs

@ -12,8 +12,9 @@ pub enum Action {
}
mod imp {
use std::sync::LazyLock;
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -39,7 +40,7 @@ mod imp {
impl ObjectImpl for CameraPaintable {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![Signal::builder("code-detected")
.param_types([QrVerificationDataBoxed::static_type()])
.run_first()

6
src/contrib/qr_code_scanner/camera/mod.rs

@ -1,8 +1,9 @@
//! Camera API.
use std::sync::LazyLock;
use futures_util::{future::LocalBoxFuture, FutureExt};
use gtk::{glib, prelude::*, subclass::prelude::*};
use once_cell::sync::Lazy;
use tracing::error;
mod camera_paintable;
@ -13,7 +14,6 @@ pub use self::camera_paintable::Action;
use self::camera_paintable::CameraPaintable;
mod imp {
use super::*;
#[repr(C)]
@ -74,7 +74,7 @@ impl Camera {
impl Default for Camera {
fn default() -> Self {
static CAMERA: Lazy<Camera> = Lazy::new(Camera::new);
static CAMERA: LazyLock<Camera> = LazyLock::new(Camera::new);
CAMERA.to_owned()
}

5
src/contrib/qr_code_scanner/mod.rs

@ -8,12 +8,11 @@ mod qr_code_detector;
pub use camera::{Camera, CameraExt};
mod imp {
use std::cell::RefCell;
use std::{cell::RefCell, sync::LazyLock};
use adw::subclass::prelude::*;
use glib::subclass::{InitializingObject, Signal};
use gtk::CompositeTemplate;
use once_cell::sync::Lazy;
use super::*;
@ -43,7 +42,7 @@ mod imp {
}
impl ObjectImpl for QrCodeScanner {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![Signal::builder("code-detected")
.param_types([QrVerificationDataBoxed::static_type()])
.run_first()

22
src/contrib/qr_code_scanner/qr_code_detector.rs

@ -11,11 +11,10 @@ use crate::contrib::qr_code_scanner::camera::Action;
const HEADER: &[u8] = b"MATRIX";
mod imp {
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
use gst::subclass::prelude::*;
use gst_video::subclass::prelude::*;
use once_cell::sync::Lazy;
use super::*;
@ -37,20 +36,21 @@ mod imp {
impl GstObjectImpl for QrCodeDetector {}
impl ElementImpl for QrCodeDetector {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"Matrix Qr Code detector Sink",
"Sink/Video/QrCode/Matrix",
"A Qr code detector for Matrix",
"Julian Sparber <julian@sparber.net>",
)
});
static ELEMENT_METADATA: LazyLock<gst::subclass::ElementMetadata> =
LazyLock::new(|| {
gst::subclass::ElementMetadata::new(
"Matrix Qr Code detector Sink",
"Sink/Video/QrCode/Matrix",
"A Qr code detector for Matrix",
"Julian Sparber <julian@sparber.net>",
)
});
Some(&*ELEMENT_METADATA)
}
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
static PAD_TEMPLATES: LazyLock<Vec<gst::PadTemplate>> = LazyLock::new(|| {
let caps = gst_video::video_make_raw_caps(&[gst_video::VideoFormat::Gray8])
.any_features()
.build();

8
src/login/session_setup_view.rs

@ -26,10 +26,12 @@ enum SessionSetupPage {
}
mod imp {
use std::cell::{OnceCell, RefCell};
use std::{
cell::{OnceCell, RefCell},
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -71,7 +73,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for SessionSetupView {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
// The session setup is done.
Signal::builder("completed").build(),

8
src/main.rs

@ -25,16 +25,18 @@ mod user_facing_error;
mod utils;
mod window;
use std::sync::LazyLock;
use gettextrs::*;
use gtk::{gdk::Display, gio, IconTheme};
use once_cell::sync::Lazy;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use self::{application::*, config::*, i18n::*, window::Window};
/// The default tokio runtime to be used for async tasks
pub static RUNTIME: Lazy<tokio::runtime::Runtime> =
Lazy::new(|| tokio::runtime::Runtime::new().unwrap());
pub static RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
tokio::runtime::Runtime::new().expect("creating tokio runtime should succeed")
});
fn main() {
// Initialize logger, debug is carried out via debug!, info!, warn! and error!.

7
src/session/model/room/aliases.rs

@ -14,10 +14,9 @@ use super::Room;
use crate::spawn_tokio;
mod imp {
use std::{cell::RefCell, marker::PhantomData};
use std::{cell::RefCell, marker::PhantomData, sync::LazyLock};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -53,8 +52,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for RoomAliases {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("changed").build()]);
SIGNALS.as_ref()
}
}

6
src/session/model/room/event/mod.rs

@ -112,10 +112,10 @@ mod imp {
use std::{
cell::{Cell, OnceCell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -219,8 +219,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for Event {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("item-changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("item-changed").build()]);
SIGNALS.as_ref()
}
}

10
src/session/model/room/join_rule.rs

@ -52,10 +52,12 @@ impl From<&MatrixJoinRule> for JoinRuleValue {
}
mod imp {
use std::cell::{Cell, RefCell};
use std::{
cell::{Cell, RefCell},
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -102,8 +104,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for JoinRule {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("changed").build()]);
SIGNALS.as_ref()
}

6
src/session/model/room/mod.rs

@ -74,11 +74,11 @@ mod imp {
cell::{Cell, OnceCell},
marker::PhantomData,
ops::ControlFlow,
sync::LazyLock,
time::SystemTime,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -232,8 +232,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for Room {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("room-forgotten").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("room-forgotten").build()]);
SIGNALS.as_ref()
}
}

10
src/session/model/room/permissions.rs

@ -78,10 +78,12 @@ impl fmt::Display for MemberRole {
}
mod imp {
use std::cell::{Cell, OnceCell, RefCell};
use std::{
cell::{Cell, OnceCell, RefCell},
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use ruma::events::room::power_levels::NotificationPowerLevelType;
use super::*;
@ -167,8 +169,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for Permissions {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("changed").build()]);
SIGNALS.as_ref()
}
}

6
src/session/model/room/timeline/mod.rs

@ -58,10 +58,10 @@ mod imp {
use std::{
cell::{Cell, OnceCell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -136,8 +136,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for Timeline {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("read-change-trigger").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("read-change-trigger").build()]);
SIGNALS.as_ref()
}

7
src/session/model/room_list/mod.rs

@ -26,10 +26,9 @@ use crate::{
};
mod imp {
use std::cell::RefCell;
use std::{cell::RefCell, sync::LazyLock};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -64,8 +63,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for RoomList {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("pending-rooms-changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("pending-rooms-changed").build()]);
SIGNALS.as_ref()
}

4
src/session/model/verification/identity_verification.rs

@ -120,10 +120,10 @@ mod imp {
use std::{
cell::{Cell, OnceCell, RefCell},
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -188,7 +188,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for IdentityVerification {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
// The SAS data changed.
Signal::builder("sas-data-changed").build(),

7
src/session/model/verification/verification_list.rs

@ -18,11 +18,10 @@ use crate::{
};
mod imp {
use std::cell::RefCell;
use std::{cell::RefCell, sync::LazyLock};
use glib::subclass::Signal;
use indexmap::IndexMap;
use once_cell::sync::Lazy;
use super::*;
@ -46,8 +45,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for VerificationList {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("secret-received").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("secret-received").build()]);
SIGNALS.as_ref()
}
}

4
src/session/view/content/room_details/invite_subpage/list.rs

@ -34,10 +34,10 @@ mod imp {
cell::{Cell, OnceCell, RefCell},
collections::HashMap,
marker::PhantomData,
sync::LazyLock,
};
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -71,7 +71,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for InviteList {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
Signal::builder("invitee-added")
.param_types([InviteItem::static_type()])

7
src/session/view/content/room_details/permissions/add_members_subpage.rs

@ -16,10 +16,9 @@ use crate::{
};
mod imp {
use std::{cell::RefCell, collections::HashMap};
use std::{cell::RefCell, collections::HashMap, sync::LazyLock};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -70,8 +69,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for PermissionsAddMembersSubpage {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("selection-changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("selection-changed").build()]);
SIGNALS.as_ref()
}

9
src/session/view/content/room_history/item_row.rs

@ -1,8 +1,9 @@
use std::sync::LazyLock;
use adw::{prelude::*, subclass::prelude::*};
use gettextrs::gettext;
use gtk::{gio, glib, glib::clone};
use matrix_sdk_ui::timeline::TimelineItemContent;
use once_cell::sync::Lazy;
use ruma::events::room::message::MessageType;
use tracing::error;
@ -975,7 +976,7 @@ unsafe impl Sync for MenuModelSendSync {}
/// The `MenuModel` for common message event actions, including reactions.
fn event_message_menu_model_with_reactions() -> &'static gio::MenuModel {
static MODEL: Lazy<MenuModelSendSync> = Lazy::new(|| {
static MODEL: LazyLock<MenuModelSendSync> = LazyLock::new(|| {
MenuModelSendSync(
gtk::Builder::from_resource(
"/org/gnome/Fractal/ui/session/view/content/room_history/event_actions.ui",
@ -989,7 +990,7 @@ fn event_message_menu_model_with_reactions() -> &'static gio::MenuModel {
/// The `MenuModel` for common message event actions, without reactions.
fn event_message_menu_model_no_reactions() -> &'static gio::MenuModel {
static MODEL: Lazy<MenuModelSendSync> = Lazy::new(|| {
static MODEL: LazyLock<MenuModelSendSync> = LazyLock::new(|| {
MenuModelSendSync(
gtk::Builder::from_resource(
"/org/gnome/Fractal/ui/session/view/content/room_history/event_actions.ui",
@ -1003,7 +1004,7 @@ fn event_message_menu_model_no_reactions() -> &'static gio::MenuModel {
/// The `MenuModel` for common state event actions.
fn event_state_menu_model() -> &'static gio::MenuModel {
static MODEL: Lazy<MenuModelSendSync> = Lazy::new(|| {
static MODEL: LazyLock<MenuModelSendSync> = LazyLock::new(|| {
MenuModelSendSync(
gtk::Builder::from_resource(
"/org/gnome/Fractal/ui/session/view/content/room_history/event_actions.ui",

5
src/session/view/content/room_history/message_row/text/mod.rs

@ -1,7 +1,8 @@
use std::sync::LazyLock;
use adw::{prelude::BinExt, subclass::prelude::*};
use gtk::{glib, glib::clone, pango, prelude::*};
use matrix_sdk::ruma::events::room::message::FormattedBody;
use once_cell::sync::Lazy;
use ruma::{
events::room::message::MessageFormat,
html::{Html, ListBehavior, SanitizerConfig},
@ -433,7 +434,7 @@ const SUPPORTED_BLOCK_ELEMENTS: &[&str] = &[
];
/// HTML sanitizer config for HTML messages.
static HTML_MESSAGE_SANITIZER_CONFIG: Lazy<SanitizerConfig> = Lazy::new(|| {
static HTML_MESSAGE_SANITIZER_CONFIG: LazyLock<SanitizerConfig> = LazyLock::new(|| {
SanitizerConfig::compat()
.allow_elements(
SUPPORTED_INLINE_ELEMENTS

7
src/session/view/content/room_history/message_toolbar/composer_state.rs

@ -30,11 +30,10 @@ const MENTION_START_TAG: &str = "<org.gnome.fractal.mention>";
const MENTION_END_TAG: &str = "</org.gnome.fractal.mention>";
mod imp {
use std::{cell::RefCell, marker::PhantomData};
use std::{cell::RefCell, marker::PhantomData, sync::LazyLock};
use futures_util::lock::Mutex;
use glib::subclass::Signal;
use once_cell::sync::Lazy;
use super::*;
@ -76,8 +75,8 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for ComposerState {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> =
Lazy::new(|| vec![Signal::builder("related-to-changed").build()]);
static SIGNALS: LazyLock<Vec<Signal>> =
LazyLock::new(|| vec![Signal::builder("related-to-changed").build()]);
SIGNALS.as_ref()
}

8
src/session/view/sidebar/mod.rs

@ -29,10 +29,12 @@ use crate::{
};
mod imp {
use std::cell::{Cell, OnceCell, RefCell};
use std::{
cell::{Cell, OnceCell, RefCell},
sync::LazyLock,
};
use glib::subclass::{InitializingObject, Signal};
use once_cell::sync::Lazy;
use super::*;
@ -94,7 +96,7 @@ mod imp {
#[glib::derived_properties]
impl ObjectImpl for Sidebar {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
vec![
Signal::builder("drop-source-category-changed").build(),
Signal::builder("drop-active-target-category-changed").build(),

5
src/utils/media/image/queue.rs

@ -3,7 +3,7 @@ use std::{
fmt,
future::IntoFuture,
path::PathBuf,
sync::{Arc, Mutex},
sync::{Arc, LazyLock, Mutex},
time::{Duration, Instant},
};
@ -13,7 +13,6 @@ use matrix_sdk::{
media::{MediaRequest, UniqueKey},
Client,
};
use once_cell::sync::Lazy;
use tokio::{
sync::{broadcast, Mutex as AsyncMutex},
task::{spawn_blocking, AbortHandle},
@ -27,7 +26,7 @@ use crate::{
};
/// The default image request queue.
pub static IMAGE_QUEUE: Lazy<ImageRequestQueue> = Lazy::new(ImageRequestQueue::new);
pub static IMAGE_QUEUE: LazyLock<ImageRequestQueue> = LazyLock::new(ImageRequestQueue::new);
/// The default limit of the [`ImageRequestQueue`], aka the maximum number of
/// concurrent image requests.

4
src/utils/mod.rs

@ -19,6 +19,7 @@ use std::{
fmt,
path::PathBuf,
rc::{Rc, Weak},
sync::LazyLock,
};
use futures_util::{
@ -26,7 +27,6 @@ use futures_util::{
pin_mut,
};
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
use once_cell::sync::Lazy;
use regex::Regex;
pub use self::{
@ -98,7 +98,7 @@ pub fn freplace(s: String, args: &[(&str, &str)]) -> String {
}
/// Regex that matches a string that only includes emojis.
pub static EMOJI_REGEX: Lazy<Regex> = Lazy::new(|| {
pub static EMOJI_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(
r"(?x)
^

Loading…
Cancel
Save