cargo: Remove gtk-macros dependency
Using the crate is depreacted. Replaced spawn! macro with our own spawn function
This commit is contained in:
parent
ca672552be
commit
8b3cfd000a
8 changed files with 21 additions and 20 deletions
|
|
@ -198,3 +198,10 @@ pub fn contrast_ratio(color1: &gdk::RGBA, color2: &gdk::RGBA) -> f32 {
|
|||
|
||||
(l1 + 0.05) / (l2 + 0.05)
|
||||
}
|
||||
|
||||
pub fn spawn<R: 'static, F: std::future::Future<Output = R> + 'static>(
|
||||
f: F,
|
||||
) -> glib::JoinHandle<R> {
|
||||
let ctx = glib::MainContext::default();
|
||||
ctx.spawn_local(f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ use crate::i18n::i18n;
|
|||
use crate::image_metadata::LpImageMetadata;
|
||||
use crate::util::Gesture;
|
||||
|
||||
use crate::util::spawn;
|
||||
use adw::{prelude::*, subclass::prelude::*};
|
||||
use arc_swap::ArcSwap;
|
||||
use futures::prelude::*;
|
||||
use gtk_macros::spawn;
|
||||
use once_cell::sync::Lazy;
|
||||
use once_cell::unsync::OnceCell;
|
||||
|
||||
|
|
@ -765,7 +765,7 @@ impl LpImage {
|
|||
};
|
||||
|
||||
let weak_obj = self.downgrade();
|
||||
spawn!(async move {
|
||||
spawn(async move {
|
||||
while let Some(update) = decoder_update.next().await {
|
||||
if let Some(obj) = weak_obj.upgrade() {
|
||||
obj.update(update);
|
||||
|
|
@ -811,7 +811,7 @@ impl LpImage {
|
|||
new_tiles
|
||||
});
|
||||
if imp.background_color.borrow().is_none() {
|
||||
spawn!(glib::clone!(@weak self as obj => async move {
|
||||
spawn(glib::clone!(@weak self as obj => async move {
|
||||
let color = obj.background_color_guess().await;
|
||||
obj.set_background_color(color);
|
||||
if obj.is_mapped() {
|
||||
|
|
@ -962,7 +962,9 @@ impl LpImage {
|
|||
let obj = self.clone();
|
||||
let file = file_a.clone();
|
||||
// TODO: error handling is missing
|
||||
spawn! {async move { obj.load(&file.path().unwrap()).await; }};
|
||||
spawn(async move {
|
||||
obj.load(&file.path().unwrap()).await;
|
||||
});
|
||||
}
|
||||
gio::FileMonitorEvent::Deleted
|
||||
| gio::FileMonitorEvent::MovedOut
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@
|
|||
use crate::deps::*;
|
||||
use crate::widgets::LpImage;
|
||||
|
||||
use crate::util::spawn;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::clone;
|
||||
use gtk::prelude::*;
|
||||
use gtk::CompositeTemplate;
|
||||
use gtk_macros::spawn;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
@ -155,7 +155,7 @@ impl LpImagePage {
|
|||
|
||||
obj.imp().image.set_file(&file);
|
||||
|
||||
spawn!(clone!(@weak obj, @strong path => async move {
|
||||
spawn(clone!(@weak obj, @strong path => async move {
|
||||
let imp = obj.imp();
|
||||
imp.image.load(&path).await;
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use crate::i18n::*;
|
|||
use crate::util::{Direction, Position};
|
||||
use crate::widgets::{LpImage, LpImagePage, LpSlidingView};
|
||||
|
||||
use crate::util::spawn;
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use anyhow::Context;
|
||||
|
|
@ -40,7 +41,6 @@ use ashpd::Error;
|
|||
use ashpd::WindowIdentifier;
|
||||
use glib::clone;
|
||||
use gtk::CompositeTemplate;
|
||||
use gtk_macros::spawn;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
@ -268,7 +268,7 @@ impl LpImageView {
|
|||
// List other files in directory
|
||||
if let Some(directory) = directory {
|
||||
let path = path.to_path_buf();
|
||||
spawn!(glib::clone!(@weak self as obj, @strong path => async move {
|
||||
spawn(glib::clone!(@weak self as obj, @strong path => async move {
|
||||
if let Err(err) = obj.model().load_directory(directory).await {
|
||||
log::warn!("Failed to load directory: {err}");
|
||||
obj.activate_action("win.show-toast", Some(&(err.to_string(), 1).to_variant()))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use futures::future::{AbortHandle, Abortable};
|
|||
use once_cell::sync::Lazy;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use gtk_macros::spawn;
|
||||
use crate::util::spawn;
|
||||
|
||||
use crate::image_metadata::LpImageMetadata;
|
||||
use crate::widgets::image::LpImage;
|
||||
|
|
@ -234,7 +234,7 @@ impl LpPropertiesView {
|
|||
imp.info_handle.replace(Some(handle));
|
||||
|
||||
// ...then spawn the future.
|
||||
spawn!(async {
|
||||
spawn(async {
|
||||
let _ = fut.await;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@
|
|||
use crate::deps::*;
|
||||
use crate::i18n::*;
|
||||
|
||||
use crate::util::spawn;
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::clone;
|
||||
use gtk::CompositeTemplate;
|
||||
use gtk_macros::spawn;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ impl LpWindow {
|
|||
.build();
|
||||
toast.connect_button_clicked(glib::clone!(@weak self as win => move |_| {
|
||||
let path = path.clone();
|
||||
spawn!(async move {
|
||||
spawn(async move {
|
||||
let result = crate::util::untrash(&path).await;
|
||||
match result {
|
||||
Ok(()) => win.image_view().set_image_from_path(&path),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue